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
47975235
Commit
47975235
authored
Aug 12, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bugs in const/case
R=r DELTA=138 (75 added, 12 deleted, 51 changed) OCL=14129 CL=14131
parent
9b1e6fdd
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
121 additions
and
58 deletions
+121
-58
gen.c
src/cmd/6g/gen.c
+2
-3
const.c
src/cmd/gc/const.c
+14
-6
go.h
src/cmd/gc/go.h
+2
-0
go.y
src/cmd/gc/go.y
+43
-9
lex.c
src/cmd/gc/lex.c
+1
-1
mparith1.c
src/cmd/gc/mparith1.c
+22
-0
subr.c
src/cmd/gc/subr.c
+1
-1
walk.c
src/cmd/gc/walk.c
+1
-1
rob2.go
test/ken/rob2.go
+35
-37
No files found.
src/cmd/6g/gen.c
View file @
47975235
...
...
@@ -455,10 +455,9 @@ swgen(Node *n)
}
// put in the break between cases
if
(
any
)
{
if
(
any
)
patch
(
gbranch
(
AJMP
,
T
),
breakpc
);
any
=
0
;
}
any
=
1
;
// over case expressions
c2
=
listfirst
(
&
save2
,
&
c1
->
left
);
...
...
src/cmd/gc/const.c
View file @
47975235
...
...
@@ -63,12 +63,16 @@ convlit(Node *n, Type *t)
break
;
}
if
(
isfloat
[
et
])
{
Mpint
*
xv
;
// int to float
if
(
mpcmpfltflt
(
n
->
val
.
u
.
fval
,
minfltval
[
et
])
<
0
)
xv
=
n
->
val
.
u
.
xval
;
if
(
mpcmpfixflt
(
xv
,
minfltval
[
et
])
<
0
)
goto
bad2
;
if
(
mpcmpf
ltflt
(
n
->
val
.
u
.
fval
,
maxfltval
[
et
])
>
0
)
if
(
mpcmpf
ixflt
(
xv
,
maxfltval
[
et
])
>
0
)
goto
bad2
;
mpmovefixflt
(
n
->
val
.
u
.
fval
,
n
->
val
.
u
.
xval
);
n
->
val
.
u
.
fval
=
mal
(
sizeof
(
*
n
->
val
.
u
.
fval
));
mpmovefixflt
(
n
->
val
.
u
.
fval
,
xv
);
n
->
val
.
ctype
=
CTFLT
;
break
;
}
...
...
@@ -76,12 +80,16 @@ convlit(Node *n, Type *t)
case
Wlitfloat
:
if
(
isint
[
et
])
{
Mpflt
*
fv
;
// float to int
if
(
mpcmpfixfix
(
n
->
val
.
u
.
xval
,
minintval
[
et
])
<
0
)
fv
=
n
->
val
.
u
.
fval
;
if
(
mpcmpfltfix
(
fv
,
minintval
[
et
])
<
0
)
goto
bad2
;
if
(
mpcmpf
ixfix
(
n
->
val
.
u
.
xval
,
maxintval
[
et
])
>
0
)
if
(
mpcmpf
ltfix
(
fv
,
maxintval
[
et
])
>
0
)
goto
bad2
;
mpmovefltfix
(
n
->
val
.
u
.
xval
,
n
->
val
.
u
.
fval
);
n
->
val
.
u
.
xval
=
mal
(
sizeof
(
*
n
->
val
.
u
.
xval
));
mpmovefltfix
(
n
->
val
.
u
.
xval
,
fv
);
n
->
val
.
ctype
=
CTINT
;
break
;
}
...
...
src/cmd/gc/go.h
View file @
47975235
...
...
@@ -471,6 +471,8 @@ void mkpackage(char*);
/*
* mparith1.c
*/
int
mpcmpfixflt
(
Mpint
*
a
,
Mpflt
*
b
);
int
mpcmpfltfix
(
Mpflt
*
a
,
Mpint
*
b
);
int
mpcmpfixfix
(
Mpint
*
a
,
Mpint
*
b
);
int
mpcmpfixc
(
Mpint
*
b
,
vlong
c
);
int
mpcmpfltflt
(
Mpflt
*
a
,
Mpflt
*
b
);
...
...
src/cmd/gc/go.y
View file @
47975235
...
...
@@ -708,7 +708,7 @@ pexpr:
{
$$
=
$
2
;
}
|
pexpr
'.'
sym
1
|
pexpr
'.'
sym
2
{
$$
=
nod
(
ODOT
,
$
1
,
newname
($
3
));
}
...
...
@@ -812,13 +812,13 @@ name_name:
}
new_name
:
sym
2
sym
1
{
$$
=
newname
($
1
);
}
new_type
:
sym
2
sym
1
{
$$
=
newtype
($
1
);
}
...
...
@@ -832,17 +832,36 @@ sym:
sym1
:
sym
|
key1
|
key2
sym2
:
sym
|
key1
|
key2
/*
*
keywords
that
we
can
>>>>
ORIGINAL
go
/
src
/
cmd
/
gc
/
go
.
y
#
8
====
THEIRS
go
/
src
/
cmd
/
gc
/
go
.
y
#
9
*
use
as
field
names
====
YOURS
go
/
src
/
cmd
/
gc
/
go
.
y
*
use
a
variable
/
type
names
<<<<
*/
key1
:
LNIL
|
LTRUE
|
LFALSE
|
LIOTA
|
LLEN
|
LPANIC
|
LPRINT
|
LNEW
|
LBASETYPE
/*
*
keywords
that
we
can
*/
key2
:
LPACKAGE
|
LIMPORT
|
LEXPORT
...
...
@@ -871,8 +890,21 @@ key1:
|
LRANGE
|
LIGNORE
/*
*
keywords
that
we
can
>>>>
ORIGINAL
go
/
src
/
cmd
/
gc
/
go
.
y
#
8
*
use
a
variable
/
type
names
*/
key2
:
LNIL
|
LTRUE
|
LFALSE
|
LIOTA
|
LLEN
|
LPANIC
|
LPRINT
|
LNEW
|
LBASETYPE
====
THEIRS
go
/
src
/
cmd
/
gc
/
go
.
y
#
9
*
use
as
variable
/
type
names
*/
key2
:
...
...
@@ -886,6 +918,8 @@ key2:
|
LNEW
|
LBASETYPE
====
YOURS
src
/
cmd
/
gc
/
go
.
y
<<<<
name
:
lname
{
...
...
@@ -1394,7 +1428,7 @@ export:
{
exportsym
($
1
);
}
|
sym
'.'
sym
1
|
sym
'.'
sym
2
{
exportsym
(
pkglookup
($
3
->
name
,
$
1
->
name
));
}
...
...
@@ -1578,7 +1612,7 @@ hidden_import:
}
isym
:
sym
'.'
sym
1
sym
'.'
sym
2
{
$$
=
nod
(
OIMPORT
,
N
,
N
);
$$->
osym
=
$
1
;
...
...
@@ -1586,7 +1620,7 @@ isym:
$$->
sym
=
$
3
;
renamepkg
($$);
}
|
'('
sym
')'
sym
'.'
sym
1
|
'('
sym
')'
sym
'.'
sym
2
{
$$
=
nod
(
OIMPORT
,
N
,
N
);
$$->
osym
=
$
2
;
...
...
src/cmd/gc/lex.c
View file @
47975235
...
...
@@ -1022,8 +1022,8 @@ void
lexinit
(
void
)
{
int
i
,
etype
,
lex
;
Sym
*
s
;
Type
*
t
;
Sym
*
s
;
besetptr
();
...
...
src/cmd/gc/mparith1.c
View file @
47975235
...
...
@@ -6,6 +6,28 @@
/// uses arihmetic
int
mpcmpfixflt
(
Mpint
*
a
,
Mpflt
*
b
)
{
char
buf
[
500
];
Mpflt
c
;
sprint
(
buf
,
"%B"
,
a
);
mpatoflt
(
&
c
,
buf
);
return
mpcmpfltflt
(
&
c
,
b
);
}
int
mpcmpfltfix
(
Mpflt
*
a
,
Mpint
*
b
)
{
char
buf
[
500
];
Mpflt
c
;
sprint
(
buf
,
"%B"
,
b
);
mpatoflt
(
&
c
,
buf
);
return
mpcmpfltflt
(
a
,
&
c
);
}
int
mpcmpfixfix
(
Mpint
*
a
,
Mpint
*
b
)
{
...
...
src/cmd/gc/subr.c
View file @
47975235
...
...
@@ -1064,7 +1064,7 @@ Nconv(Fmt *fp)
snprint
(
buf1
,
sizeof
(
buf1
),
"S
\"
%Z
\"
"
,
n
->
val
.
u
.
sval
);
break
;
case
CTBOOL
:
snprint
(
buf1
,
sizeof
(
buf1
),
"B%
ll
d"
,
n
->
val
.
u
.
bval
);
snprint
(
buf1
,
sizeof
(
buf1
),
"B%d"
,
n
->
val
.
u
.
bval
);
break
;
case
CTNIL
:
snprint
(
buf1
,
sizeof
(
buf1
),
"N"
);
...
...
src/cmd/gc/walk.c
View file @
47975235
...
...
@@ -1399,11 +1399,11 @@ Node*
prcompat
(
Node
*
n
)
{
Node
*
l
,
*
r
;
Node
*
on
;
Type
*
t
;
Iter
save
;
int
w
;
char
*
name
;
Node
*
on
;
r
=
N
;
l
=
listfirst
(
&
save
,
&
n
);
...
...
test/ken/rob2.go
View file @
47975235
...
...
@@ -162,35 +162,34 @@ func NextToken()
c
=
Get
();
}
switch
c
{
case
EOF
:
token
=
EOF
;
case
'('
:
case
')'
:
token
=
c
;
break
;
default
:
for
i
=
0
;
i
<
100
-
1
;
{
// sizeof tokenbuf - 1
tokenbuf
[
i
]
=
convert
(
byte
,
c
);
i
=
i
+
1
;
c
=
Get
();
if
c
==
EOF
{
break
;
}
if
WhiteSpace
(
c
)
||
c
==
')'
{
peekc
=
c
;
break
;
}
}
if
i
>=
100
-
1
{
// sizeof tokenbuf - 1
panic
(
"atom too long
\n
"
);
case
EOF
:
token
=
EOF
;
case
'('
,
')'
:
token
=
c
;
break
;
default
:
for
i
=
0
;
i
<
100
-
1
;
{
// sizeof tokenbuf - 1
tokenbuf
[
i
]
=
convert
(
byte
,
c
);
i
=
i
+
1
;
c
=
Get
();
if
c
==
EOF
{
break
;
}
tokenlen
=
i
;
tokenbuf
[
i
]
=
nilchar
;
if
'0'
<=
tokenbuf
[
0
]
&&
tokenbuf
[
0
]
<=
'9'
{
token
=
'0'
;
}
else
{
token
=
'A'
;
if
WhiteSpace
(
c
)
||
c
==
')'
{
peekc
=
c
;
break
;
}
}
if
i
>=
100
-
1
{
// sizeof tokenbuf - 1
panic
(
"atom too long
\n
"
);
}
tokenlen
=
i
;
tokenbuf
[
i
]
=
nilchar
;
if
'0'
<=
tokenbuf
[
0
]
&&
tokenbuf
[
0
]
<=
'9'
{
token
=
'0'
;
}
else
{
token
=
'A'
;
}
}
}
...
...
@@ -267,16 +266,15 @@ func Parse() *Slist
}
else
{
// Atom
switch
token
{
case
EOF
:
return
nil
;
case
'0'
:
slist
=
atom
(
atoi
());
case
'"'
:
case
'A'
:
slist
=
atom
(
0
);
default
:
slist
=
nil
;
print
(
"unknown token"
);
// token, tokenbuf);
case
EOF
:
return
nil
;
case
'0'
:
slist
=
atom
(
atoi
());
case
'"'
,
'A'
:
slist
=
atom
(
0
);
default
:
slist
=
nil
;
print
(
"unknown token: "
,
token
,
"
\n
"
);
}
NextToken
();
return
slist
;
...
...
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