Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
655c2813
Commit
655c2813
authored
Jul 08, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disambiguate typedefs in export blocks of .6 files
SVN=126366
parent
6810f39e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
31 deletions
+32
-31
dcl.c
src/cmd/gc/dcl.c
+3
-3
vector.go
src/lib/container/vector.go
+2
-2
fmt.go
src/lib/fmt.go
+22
-22
main.go
src/lib/math/main.go
+3
-2
golden.out
test/golden.out
+2
-2
No files found.
src/cmd/gc/dcl.c
View file @
655c2813
...
...
@@ -153,7 +153,7 @@ funcnam(Type *t, char *nam)
if
(
t
->
thistuple
>
0
)
{
vargen
++
;
snprint
(
namebuf
,
sizeof
(
namebuf
),
"_t%
.3ld"
,
vargen
);
snprint
(
namebuf
,
sizeof
(
namebuf
),
"_t%
s%.3ld"
,
nam
,
vargen
);
s
=
lookup
(
namebuf
);
addtyp
(
newtype
(
s
),
t
->
type
,
PEXTERN
);
n
=
newname
(
s
);
...
...
@@ -162,7 +162,7 @@ funcnam(Type *t, char *nam)
}
if
(
t
->
outtuple
>
0
)
{
vargen
++
;
snprint
(
namebuf
,
sizeof
(
namebuf
),
"_o%
.3ld"
,
vargen
);
snprint
(
namebuf
,
sizeof
(
namebuf
),
"_o%
s%.3ld"
,
nam
,
vargen
);
s
=
lookup
(
namebuf
);
addtyp
(
newtype
(
s
),
t
->
type
->
down
,
PEXTERN
);
n
=
newname
(
s
);
...
...
@@ -171,7 +171,7 @@ funcnam(Type *t, char *nam)
}
if
(
t
->
intuple
>
0
)
{
vargen
++
;
snprint
(
namebuf
,
sizeof
(
namebuf
),
"_i%
.3ld"
,
vargen
);
snprint
(
namebuf
,
sizeof
(
namebuf
),
"_i%
s%.3ld"
,
nam
,
vargen
);
s
=
lookup
(
namebuf
);
addtyp
(
newtype
(
s
),
t
->
type
->
down
->
down
,
PEXTERN
);
n
=
newname
(
s
);
...
...
src/lib/container/vector.go
View file @
655c2813
...
...
@@ -63,8 +63,8 @@ func (v *Vector) Len() int {
func
(
v
*
Vector
)
At
(
i
int
)
Element
{
if
i
<
0
||
i
>=
v
.
nelem
{
//return nil; // BUG
panic
"At out of range
\n
"
;
panic
"Vector.At("
,
i
,
") out of range (size "
,
v
.
nelem
,
")
\n
"
;
return
nil
;
}
return
v
.
elem
[
i
];
}
...
...
src/lib/fmt.go
View file @
655c2813
...
...
@@ -15,10 +15,13 @@ package fmt
export
Fmt
,
New
;
const
NByte
=
64
;
const
NPows10
=
160
;
// BUG: why not nelem(pows10);
var
ldigits
string
;
var
udigits
string
;
var
inited
bool
;
var
pows10
[
16
0
]
double
;
var
pows10
[
NPows1
0
]
double
;
type
Fmt
struct
{
buf
string
;
...
...
@@ -47,7 +50,7 @@ func (f *Fmt) init() {
udigits
=
"0123456789ABCDEF"
;
// BUG: should be initialized const
// BUG: should be done with initialization
var
p
double
=
1.0
;
for
i
:=
0
;
i
<
160
;
i
++
{
// BUG: len(pows10)
for
i
:=
0
;
i
<
NPows10
;
i
++
{
pows10
[
i
]
=
p
;
p
*=
10.0
;
}
...
...
@@ -112,10 +115,10 @@ func (f *Fmt) pad(s string) {
}
w
-=
len
(
s
);
if
w
>
0
{
if
w
>
64
{
// BUG: should be able to use a const
w
=
64
;
if
w
>
NByte
{
w
=
NByte
;
}
var
buf
[
64
]
byte
;
// BUG: should be able to allocate a
size
var
buf
[
NByte
]
byte
;
// BUG: should be able to allocate variable
size
for
i
:=
0
;
i
<
w
;
i
++
{
buf
[
i
]
=
' '
;
}
...
...
@@ -134,13 +137,13 @@ func (f *Fmt) pad(s string) {
// never mind.) val is known to be unsigned. we could make things maybe
// marginally faster by splitting the 32-bit case out into a separate function
// but it's not worth the duplication, so val has 64 bits.
func
putint
(
buf
*
[
64
]
byte
,
i
int
,
base
,
val
uint64
,
digits
*
string
)
int
{
func
putint
(
buf
*
[
NByte
]
byte
,
i
int
,
base
,
val
uint64
,
digits
*
string
)
int
{
for
val
>=
base
{
buf
[
i
]
=
(
*
digits
)[
val
%
base
];
// BUG: shouldn't need indirect
buf
[
i
]
=
digits
[
val
%
base
];
i
--
;
val
/=
base
;
}
buf
[
i
]
=
(
*
digits
)[
val
];
// BUG: shouldn't need indirect
buf
[
i
]
=
digits
[
val
];
return
i
-
1
;
}
...
...
@@ -157,14 +160,14 @@ func (f *Fmt) boolean(a bool) *Fmt {
// integer; interprets prec but not wid.
func
(
f
*
Fmt
)
integer
(
a
int64
,
base
uint
,
is_signed
bool
,
digits
*
string
)
string
{
var
buf
[
64
]
byte
;
var
buf
[
NByte
]
byte
;
negative
:=
is_signed
&&
a
<
0
;
if
negative
{
a
=
-
a
;
}
i
:=
putint
(
&
buf
,
63
,
uint64
(
base
),
uint64
(
a
),
digits
);
i
:=
putint
(
&
buf
,
NByte
-
1
,
uint64
(
base
),
uint64
(
a
),
digits
);
if
f
.
prec_present
{
for
i
>
0
&&
f
.
prec
>
(
63
-
i
)
{
for
i
>
0
&&
f
.
prec
>
(
NByte
-
1
-
i
)
{
buf
[
i
]
=
'0'
;
i
--
;
}
...
...
@@ -173,7 +176,7 @@ func (f *Fmt) integer(a int64, base uint, is_signed bool, digits *string) string
buf
[
i
]
=
'-'
;
i
--
;
}
return
string
(
buf
)[
i
+
1
:
64
];
return
string
(
buf
)[
i
+
1
:
NByte
];
}
// decimal
...
...
@@ -314,7 +317,6 @@ func (f *Fmt) s(s string) *Fmt {
func
pow10
(
n
int
)
double
{
var
d
double
;
npows10
:=
160
;
// nelem(pows10); BUG: why not a const?
neg
:=
false
;
if
n
<
0
{
...
...
@@ -327,17 +329,17 @@ func pow10(n int) double {
return
1.79769e+308
;
// HUGE_VAL
}
if
n
<
np
ows10
{
if
n
<
NP
ows10
{
d
=
pows10
[
n
];
}
else
{
d
=
pows10
[
np
ows10
-
1
];
d
=
pows10
[
NP
ows10
-
1
];
for
{
n
-=
np
ows10
-
1
;
if
n
<
np
ows10
{
n
-=
NP
ows10
-
1
;
if
n
<
NP
ows10
{
d
*=
pows10
[
n
];
break
;
}
d
*=
pows10
[
np
ows10
-
1
];
d
*=
pows10
[
NP
ows10
-
1
];
}
}
if
neg
{
...
...
@@ -356,9 +358,7 @@ func unpack(a double) (negative bool, exp int, num double) {
}
// find g,e such that a = g*10^e.
// guess 10-exponent using 2-exponent, then fine tune.
var
g
double
;
var
e2
int
;
e2
,
g
=
sys
.
frexp
(
a
);
// BUG: should be able to say e2, g := sys.frexp(a);
e2
,
g
:=
sys
.
frexp
(
a
);
e
:=
int
(
e2
*
.301029995663981
);
g
=
a
*
pow10
(
-
e
);
for
g
<
1
{
...
...
@@ -401,7 +401,7 @@ func (f *Fmt) E(a double) *Fmt {
// print exponent with leading 0 if appropriate.
es
:=
New
()
.
p
(
2
)
.
integer
(
int64
(
exp
),
10
,
true
,
&
ldigits
);
if
exp
>
0
{
es
=
"+"
+
es
;
//
BUG
: should do this with a fmt flag
es
=
"+"
+
es
;
//
TODO
: should do this with a fmt flag
}
s
=
s
+
"e"
+
es
;
if
negative
{
...
...
src/lib/math/main.go
View file @
655c2813
...
...
@@ -61,14 +61,15 @@ main()
ck
(
exp
[
i
],
math
.
exp
(
f
));
ck
(
floor
[
i
],
math
.
floor
(
f
));
ck
(
log
[
i
],
math
.
log
(
math
.
fabs
(
f
)));
math
.
pow
(
10
,
f
);
ck
(
pow
[
i
],
math
.
pow
(
10
,
f
));
ck
(
sin
[
i
],
math
.
sin
(
f
));
ck
(
sinh
[
i
],
math
.
sinh
(
f
));
ck
(
sqrt
[
i
],
math
.
sqrt
(
math
.
fabs
(
f
)));
ck
(
tan
[
i
],
math
.
tan
(
f
));
ck
(
tanh
[
i
],
math
.
tanh
(
f
));
ck
(
math
.
fabs
(
tanh
[
i
]
*
math
.
sqrt
(
2
)),
math
.
hypot
(
tanh
[
i
],
tanh
[
i
]));
//
ck(math.fabs(tanh[i]*math.sqrt(2)),
//
math.hypot(tanh[i], tanh[i]));
}
}
...
...
test/golden.out
View file @
655c2813
...
...
@@ -10,8 +10,8 @@
=========== ./func.go
=========== ./func1.go
func1.go:1
0
: var a redeclared in this block
previous declaration at func1.go:1
0
func1.go:1
2
: var a redeclared in this block
previous declaration at func1.go:1
2
=========== ./hashmap.go
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment