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
52861558
Commit
52861558
authored
Aug 13, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put i2s, s2i and i2i in convert
R=r OCL=14143 CL=14143
parent
0f1d439e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
40 deletions
+68
-40
go.h
src/cmd/gc/go.h
+1
-0
walk.c
src/cmd/gc/walk.c
+67
-40
No files found.
src/cmd/gc/go.h
View file @
52861558
...
...
@@ -669,6 +669,7 @@ Type* fixmap(Type*);
Node
*
mapop
(
Node
*
,
int
);
Type
*
fixchan
(
Type
*
);
Node
*
chanop
(
Node
*
,
int
);
Node
*
isandss
(
Type
*
,
Node
*
);
Node
*
convas
(
Node
*
);
void
arrayconv
(
Type
*
,
Node
*
);
Node
*
colas
(
Node
*
,
Node
*
);
...
...
src/cmd/gc/walk.c
View file @
52861558
...
...
@@ -391,45 +391,56 @@ loop:
if
(
top
!=
Erv
)
goto
nottop
;
walktype
(
n
->
left
,
Erv
);
if
(
n
->
left
==
N
)
l
=
n
->
left
;
if
(
l
==
N
)
goto
ret
;
t
=
n
->
type
;
if
(
t
==
T
)
goto
ret
;
convlit
(
n
->
left
,
n
->
type
);
convlit
(
l
,
t
);
// nil conversion
if
(
eqtype
(
n
->
type
,
n
->
left
->
type
,
0
))
{
if
(
n
->
left
->
op
!=
ONAME
)
*
n
=
*
n
->
left
;
if
(
eqtype
(
t
,
l
->
type
,
0
))
{
if
(
l
->
op
!=
ONAME
)
*
n
=
*
l
;
goto
ret
;
}
// simple fix-float
if
(
n
->
left
->
type
!=
T
)
if
(
isint
[
n
->
left
->
type
->
etype
]
||
isfloat
[
n
->
left
->
type
->
etype
])
if
(
isint
[
n
->
type
->
etype
]
||
isfloat
[
n
->
type
->
etype
])
{
if
(
l
->
type
!=
T
)
if
(
isint
[
l
->
type
->
etype
]
||
isfloat
[
l
->
type
->
etype
])
if
(
isint
[
t
->
etype
]
||
isfloat
[
t
->
etype
])
{
evconst
(
n
);
goto
ret
;
}
// to string
if
(
isptrto
(
n
->
type
,
TSTRING
))
{
if
(
isint
[
n
->
left
->
type
->
etype
])
{
if
(
isptrto
(
t
,
TSTRING
))
{
if
(
isint
[
l
->
type
->
etype
])
{
*
n
=
*
stringop
(
n
,
top
);
goto
ret
;
}
if
(
isbytearray
(
n
->
left
->
type
)
!=
0
)
{
if
(
isbytearray
(
l
->
type
)
!=
0
)
{
n
->
op
=
OARRAY
;
*
n
=
*
stringop
(
n
,
top
);
goto
ret
;
}
}
if
(
n
->
type
->
etype
==
TARRAY
)
{
arrayconv
(
n
->
type
,
n
->
left
);
if
(
t
->
etype
==
TARRAY
)
{
arrayconv
(
t
,
l
);
goto
ret
;
}
r
=
isandss
(
n
->
type
,
l
);
if
(
r
!=
N
)
{
*
n
=
*
r
;
goto
ret
;
}
badtype
(
n
->
op
,
n
->
left
->
type
,
n
->
type
);
badtype
(
n
->
op
,
l
->
type
,
t
);
goto
ret
;
case
ORETURN
:
...
...
@@ -2083,9 +2094,45 @@ diagnamed(Type *t)
}
Node
*
convas
(
Node
*
n
)
isandss
(
Type
*
lt
,
Node
*
r
)
{
Type
*
rt
;
Node
*
n
;
int
o
;
rt
=
r
->
type
;
if
(
isinter
(
lt
))
{
if
(
isptrto
(
rt
,
TSTRUCT
))
{
o
=
OS2I
;
goto
ret
;
}
if
(
isinter
(
rt
))
{
o
=
OI2I
;
goto
ret
;
}
}
if
(
isptrto
(
lt
,
TSTRUCT
))
{
if
(
isinter
(
rt
))
{
o
=
OI2S
;
goto
ret
;
}
}
return
N
;
ret:
diagnamed
(
lt
);
diagnamed
(
rt
);
n
=
nod
(
o
,
r
,
N
);
n
->
type
=
lt
;
return
n
;
}
Node
*
convas
(
Node
*
n
)
{
Node
*
l
,
*
r
;
Type
*
lt
,
*
rt
;
...
...
@@ -2124,35 +2171,15 @@ convas(Node *n)
if
(
eqtype
(
lt
,
rt
,
0
))
return
n
;
if
(
isinter
(
lt
))
{
if
(
isptrto
(
rt
,
TSTRUCT
))
{
o
=
OS2I
;
goto
ret
;
}
if
(
isinter
(
rt
))
{
o
=
OI2I
;
goto
ret
;
}
}
if
(
isptrto
(
lt
,
TSTRUCT
))
{
if
(
isinter
(
rt
))
{
o
=
OI2S
;
goto
ret
;
}
r
=
isandss
(
lt
,
r
);
if
(
r
!=
N
)
{
n
->
right
=
r
;
walktype
(
n
,
Etop
);
return
n
;
}
badtype
(
n
->
op
,
lt
,
rt
);
return
n
;
ret:
diagnamed
(
lt
);
diagnamed
(
rt
);
n
->
right
=
nod
(
o
,
r
,
N
);
n
->
right
->
type
=
l
->
type
;
walktype
(
n
,
Etop
);
return
n
;
}
void
...
...
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