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
713e3e15
Commit
713e3e15
authored
Feb 18, 2010
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more complex - constants
import and export R=rsc CC=golang-dev
https://golang.org/cl/214050
parent
1734cb02
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
3 deletions
+41
-3
const.c
src/cmd/gc/const.c
+20
-0
export.c
src/cmd/gc/export.c
+3
-0
go.h
src/cmd/gc/go.h
+1
-0
go.y
src/cmd/gc/go.y
+10
-2
walk.c
src/cmd/gc/walk.c
+6
-0
type.go
src/pkg/runtime/type.go
+1
-1
No files found.
src/cmd/gc/const.c
View file @
713e3e15
...
...
@@ -851,6 +851,26 @@ nodlit(Val v)
return
n
;
}
Node
*
nodcplxlit
(
Val
r
,
Val
i
)
{
Node
*
n
;
Mpcplx
*
c
;
c
=
mal
(
sizeof
(
*
c
));
n
=
nod
(
OLITERAL
,
N
,
N
);
n
->
type
=
types
[
TIDEAL
];
n
->
val
.
u
.
cval
=
c
;
n
->
val
.
ctype
=
CTCPLX
;
if
(
r
.
ctype
!=
CTFLT
||
i
.
ctype
!=
CTFLT
)
fatal
(
"nodcplxlit ctype %d/%d"
,
r
.
ctype
,
i
.
ctype
);
mpmovefltflt
(
&
c
->
real
,
r
.
u
.
fval
);
mpmovefltflt
(
&
c
->
imag
,
i
.
u
.
fval
);
return
n
;
}
// TODO(rsc): combine with convlit
void
defaultlit
(
Node
**
np
,
Type
*
t
)
...
...
src/cmd/gc/export.c
View file @
713e3e15
...
...
@@ -133,6 +133,9 @@ dumpexportconst(Sym *s)
case
CTFLT
:
Bprint
(
bout
,
"%F
\n
"
,
n
->
val
.
u
.
fval
);
break
;
case
CTCPLX
:
Bprint
(
bout
,
"(%F+%F)
\n
"
,
&
n
->
val
.
u
.
cval
->
real
,
&
n
->
val
.
u
.
cval
->
imag
);
break
;
case
CTSTR
:
Bprint
(
bout
,
"
\"
%Z
\"\n
"
,
n
->
val
.
u
.
sval
);
break
;
...
...
src/cmd/gc/go.h
View file @
713e3e15
...
...
@@ -851,6 +851,7 @@ void linehist(char*, int32, int);
int32
setlineno
(
Node
*
);
Node
*
nod
(
int
,
Node
*
,
Node
*
);
Node
*
nodlit
(
Val
);
Node
*
nodcplxlit
(
Val
,
Val
);
Type
*
typ
(
int
);
int
algtype
(
Type
*
);
void
dodump
(
Node
*
,
int
);
...
...
src/cmd/gc/go.y
View file @
713e3e15
...
...
@@ -76,7 +76,8 @@
%type <sym> hidden_importsym hidden_pkg_importsym
%type <node> hidden_constant hidden_dcl hidden_interfacedcl hidden_structdcl hidden_opt_sym
%type <node> hidden_constant hidden_literal hidden_dcl
%type <node> hidden_interfacedcl hidden_structdcl hidden_opt_sym
%type <list> hidden_funres
%type <list> ohidden_funres
...
...
@@ -1743,7 +1744,7 @@ hidden_funres:
$$ = list1(nod(ODCLFIELD, N, typenod($1)));
}
hidden_
constant
:
hidden_
literal
:
LLITERAL
{
$$ = nodlit($1);
...
...
@@ -1769,6 +1770,13 @@ hidden_constant:
yyerror("bad constant %S", $$->sym);
}
hidden_constant:
hidden_literal
| '
(
' hidden_literal '
+
' hidden_literal '
)
'
{
$$ = nodcplxlit($2->val, $4->val);
}
hidden_importsym:
LLITERAL '
.
' sym
{
...
...
src/cmd/gc/walk.c
View file @
713e3e15
...
...
@@ -1724,6 +1724,12 @@ walkprint(Node *nn, NodeList **init, int defer)
t
=
types
[
TFLOAT64
];
}
else
on
=
syslook
(
"printfloat"
,
0
);
}
else
if
(
iscomplex
[
et
])
{
if
(
defer
)
{
fmtprint
(
&
fmt
,
"%%f"
);
t
=
types
[
TFLOAT64
];
}
else
on
=
syslook
(
"printcomplex"
,
0
);
}
else
if
(
et
==
TBOOL
)
{
if
(
defer
)
fmtprint
(
&
fmt
,
"%%t"
);
...
...
src/pkg/runtime/type.go
View file @
713e3e15
...
...
@@ -102,7 +102,7 @@ type FloatType commonType
// Complex64Type represents a complex64 type.
type
Complex64Type
commonType
// Complex128Type represents a complex
32
type.
// Complex128Type represents a complex
128
type.
type
Complex128Type
commonType
// ComplexType represents a complex type.
...
...
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