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)
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;
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);
%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
$$ = list1(nod(ODCLFIELD, N, typenod($1)));
}
-hidden_constant:
+hidden_literal:
LLITERAL
{
$$ = nodlit($1);
yyerror("bad constant %S", $$->sym);
}
+hidden_constant:
+ hidden_literal
+| '(' hidden_literal '+' hidden_literal ')'
+ {
+ $$ = nodcplxlit($2->val, $4->val);
+ }
+
hidden_importsym:
LLITERAL '.' sym
{
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");
// Complex64Type represents a complex64 type.
type Complex64Type commonType
-// Complex128Type represents a complex32 type.
+// Complex128Type represents a complex128 type.
type Complex128Type commonType
// ComplexType represents a complex type.