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
ed13d399
Commit
ed13d399
authored
Feb 21, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: minor const simplifications
R=ken2 CC=golang-dev
https://golang.org/cl/217069
parent
f59cb49a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
32 deletions
+15
-32
const.c
src/cmd/gc/const.c
+15
-32
No files found.
src/cmd/gc/const.c
View file @
ed13d399
...
...
@@ -173,6 +173,7 @@ convlit1(Node **np, Type *t, int explicit)
if
(
isint
[
et
])
{
switch
(
ct
)
{
default:
goto
bad
;
case
CTCPLX
:
case
CTFLT
:
n
->
val
=
toint
(
n
->
val
);
...
...
@@ -185,6 +186,7 @@ convlit1(Node **np, Type *t, int explicit)
if
(
isfloat
[
et
])
{
switch
(
ct
)
{
default:
goto
bad
;
case
CTCPLX
:
case
CTINT
:
n
->
val
=
toflt
(
n
->
val
);
...
...
@@ -966,43 +968,28 @@ defaultlit(Node **np, Type *t)
break
;
case
CTINT
:
n
->
type
=
types
[
TINT
];
if
(
t
!=
T
)
{
if
(
isint
[
t
->
etype
])
n
->
type
=
t
;
else
if
(
isfloat
[
t
->
etype
])
{
n
->
type
=
t
;
n
->
val
=
toflt
(
n
->
val
);
}
}
overflow
(
n
->
val
,
n
->
type
);
break
;
goto
num
;
case
CTFLT
:
n
->
type
=
types
[
TFLOAT
];
goto
num
;
case
CTCPLX
:
n
->
type
=
types
[
TCOMPLEX
];
goto
num
;
num:
if
(
t
!=
T
)
{
if
(
isfloat
[
t
->
etype
])
n
->
type
=
t
;
else
if
(
isint
[
t
->
etype
])
{
n
->
type
=
t
;
n
->
val
=
toint
(
n
->
val
);
}
}
overflow
(
n
->
val
,
n
->
type
);
break
;
case
CTCPLX
:
n
->
type
=
types
[
TCOMPLEX
];
if
(
t
!=
T
)
{
if
(
iscomplex
[
t
->
etype
])
n
->
type
=
t
;
else
if
(
isfloat
[
t
->
etype
])
{
n
->
type
=
t
;
n
->
val
=
toflt
(
n
->
val
);
}
else
if
(
isint
[
t
->
etype
])
{
}
else
if
(
iscomplex
[
t
->
etype
])
{
n
->
type
=
t
;
n
->
val
=
to
int
(
n
->
val
);
n
->
val
=
to
cplx
(
n
->
val
);
}
}
overflow
(
n
->
val
,
n
->
type
);
...
...
@@ -1015,6 +1002,7 @@ defaultlit(Node **np, Type *t)
* defaultlit on both nodes simultaneously;
* if they're both ideal going in they better
* get the same type going out.
* force means must assign concrete (non-ideal) type.
*/
void
defaultlit2
(
Node
**
lp
,
Node
**
rp
,
int
force
)
...
...
@@ -1192,13 +1180,8 @@ convconst(Node *con, Type *t, Val *val)
if
(
isfloat
[
tt
])
{
con
->
val
=
toflt
(
con
->
val
);
// if(con->val.ctype == CTINT) {
// con->val.ctype = CTFLT;
// con->val.u.fval = mal(sizeof *con->val.u.fval);
// mpmovefixflt(con->val.u.fval, val->u.xval);
// }
// if(con->val.ctype != CTFLT)
// fatal("convconst ctype=%d %T", con->val.ctype, t);
if
(
con
->
val
.
ctype
!=
CTFLT
)
fatal
(
"convconst ctype=%d %T"
,
con
->
val
.
ctype
,
t
);
if
(
tt
==
TFLOAT32
)
con
->
val
.
u
.
fval
=
truncfltlit
(
con
->
val
.
u
.
fval
,
t
);
return
;
...
...
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