Commit c21d9a1e authored by Ken Thompson's avatar Ken Thompson

the end of life as we know it

int is new type

R=r
OCL=18023
CL=18023
parent 0ed4576c
...@@ -22,31 +22,6 @@ main(int argc, char *argv[]) ...@@ -22,31 +22,6 @@ main(int argc, char *argv[])
static int wptr = 8; // width of a pointer static int wptr = 8; // width of a pointer
static int wmax = 8; // max rounding static int wmax = 8; // max rounding
/*
* additionally, go declares several platform-specific type aliases:
* ushort, short, uint, int, uint32, int32, float, and double. The bit
*/
static char*
typedefs[] =
{
"short", "int16", // shorts
"ushort", "uint16",
"int", "int32", // ints
"uint", "uint32",
// "rune", "uint32",
"long", "int64", // longs
"ulong", "uint64",
// "vlong", "int64", // vlongs
// "uvlong", "uint64",
"float", "float32", // floats
"double", "float64",
};
uint32 uint32
rnd(uint32 o, uint32 r) rnd(uint32 o, uint32 r)
{ {
...@@ -114,11 +89,12 @@ dowidth(Type *t) ...@@ -114,11 +89,12 @@ dowidth(Type *t)
t->width = -2; t->width = -2;
w = 0; w = 0;
switch(t->etype) { switch(simtype[t->etype]) {
default: default:
fatal("dowidth: unknown type: %E", t->etype); fatal("dowidth: unknown type: %E", t->etype);
break; break;
/* compiler-specific stuff */
case TINT8: case TINT8:
case TUINT8: case TUINT8:
case TBOOL: // bool is int8 case TBOOL: // bool is int8
...@@ -208,11 +184,30 @@ besetptr(void) ...@@ -208,11 +184,30 @@ besetptr(void)
tptr = TPTR64; tptr = TPTR64;
} }
/*
* additionally, go declares several platform-specific type aliases:
* int, uint, float, and uptrint
*/
static struct
{
char* name;
int etype;
int sameas;
}
typedefs[] =
{
"int", TINT, TINT32,
"uint", TUINT, TUINT32,
"uptrint", TUINTPTR, TUINT64,
"float", TFLOAT, TFLOAT32,
};
void void
belexinit(int lextype) belexinit(int lextype)
{ {
int i; int i, etype, sameas;
Sym *s0, *s1; Sym *s;
Type *t;
zprog.link = P; zprog.link = P;
zprog.as = AGOK; zprog.as = AGOK;
...@@ -221,14 +216,37 @@ belexinit(int lextype) ...@@ -221,14 +216,37 @@ belexinit(int lextype)
zprog.from.scale = 0; zprog.from.scale = 0;
zprog.to = zprog.from; zprog.to = zprog.from;
for(i=0; i<nelem(typedefs); i+=2) { for(i=0; i<nelem(typedefs); i++) {
s1 = lookup(typedefs[i+1]); s = lookup(typedefs[i].name);
if(s1->lexical != lextype) s->lexical = lextype;
yyerror("need %s to define %s",
typedefs[i+1], typedefs[i+0]); etype = typedefs[i].etype;
s0 = lookup(typedefs[i+0]); if(etype < 0 || etype >= nelem(types))
s0->lexical = s1->lexical; fatal("lexinit: %s bad etype", s->name);
s0->otype = s1->otype; sameas = typedefs[i].sameas;
if(sameas < 0 || sameas >= nelem(types))
fatal("lexinit: %s bad sameas", s->name);
simtype[etype] = sameas;
t = types[etype];
if(t != T)
fatal("lexinit: %s already defined", s->name);
t = typ(etype);
t->sym = s;
dowidth(t);
types[etype] = t;
s->otype = t;
if(minfltval[sameas] != nil)
minfltval[etype] = minfltval[sameas];
if(maxfltval[sameas] != nil)
maxfltval[etype] = maxfltval[sameas];
if(minintval[sameas] != nil)
minintval[etype] = minintval[sameas];
if(maxintval[sameas] != nil)
maxintval[etype] = maxintval[sameas];
} }
symstringo = lookup(".stringo"); // strings symstringo = lookup(".stringo"); // strings
......
...@@ -839,6 +839,8 @@ cgen_as(Node *nl, Node *nr, int op) ...@@ -839,6 +839,8 @@ cgen_as(Node *nl, Node *nr, int op)
fatal("cgen_as: tl %T", tl); fatal("cgen_as: tl %T", tl);
break; break;
case TINT:
case TUINT:
case TINT8: case TINT8:
case TUINT8: case TUINT8:
case TINT16: case TINT16:
...@@ -847,11 +849,13 @@ cgen_as(Node *nl, Node *nr, int op) ...@@ -847,11 +849,13 @@ cgen_as(Node *nl, Node *nr, int op)
case TUINT32: case TUINT32:
case TINT64: case TINT64:
case TUINT64: case TUINT64:
case TUINTPTR:
nr->val.u.xval = mal(sizeof(*nr->val.u.xval)); nr->val.u.xval = mal(sizeof(*nr->val.u.xval));
mpmovecfix(nr->val.u.xval, 0); mpmovecfix(nr->val.u.xval, 0);
nr->val.ctype = CTINT; nr->val.ctype = CTINT;
break; break;
case TFLOAT:
case TFLOAT32: case TFLOAT32:
case TFLOAT64: case TFLOAT64:
case TFLOAT80: case TFLOAT80:
...@@ -1029,7 +1033,7 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res) ...@@ -1029,7 +1033,7 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
a = optoas(op, nl->type); a = optoas(op, nl->type);
if(nr->op == OLITERAL) { if(nr->op == OLITERAL) {
regalloc(&n1, nr->type, res); regalloc(&n1, nl->type, res);
cgen(nl, &n1); cgen(nl, &n1);
gins(a, nr, &n1); gins(a, nr, &n1);
gmove(&n1, res); gmove(&n1, res);
...@@ -1065,7 +1069,6 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res) ...@@ -1065,7 +1069,6 @@ cgen_shift(int op, Node *nl, Node *nr, Node *res)
cgen(nr, &n1); cgen(nr, &n1);
cgen(nl, &n2); cgen(nl, &n2);
} }
// test and fix up large shifts // test and fix up large shifts
nodconst(&n3, types[TUINT32], nl->type->width*8); nodconst(&n3, types[TUINT32], nl->type->width*8);
gins(optoas(OCMP, types[TUINT32]), &n1, &n3); gins(optoas(OCMP, types[TUINT32]), &n1, &n3);
......
...@@ -133,12 +133,13 @@ gclean(void) ...@@ -133,12 +133,13 @@ gclean(void)
void void
regalloc(Node *n, Type *t, Node *o) regalloc(Node *n, Type *t, Node *o)
{ {
int i; int i, et;
if(t == T) if(t == T)
fatal("regalloc: t nil"); fatal("regalloc: t nil");
et = simtype[t->etype];
switch(t->etype) {
switch(et) {
case TINT8: case TINT8:
case TUINT8: case TUINT8:
case TINT16: case TINT16:
...@@ -313,8 +314,8 @@ gmove(Node *f, Node *t) ...@@ -313,8 +314,8 @@ gmove(Node *f, Node *t)
Node nod, nod1, nod2, nod3, nodc; Node nod, nod1, nod2, nod3, nodc;
Prog *p1, *p2; Prog *p1, *p2;
ft = f->type->etype; ft = simtype[f->type->etype];
tt = t->type->etype; tt = simtype[t->type->etype];
t64 = 0; t64 = 0;
if(tt == TINT64 || tt == TUINT64 || tt == TPTR64) if(tt == TINT64 || tt == TUINT64 || tt == TPTR64)
...@@ -1106,7 +1107,7 @@ optoas(int op, Type *t) ...@@ -1106,7 +1107,7 @@ optoas(int op, Type *t)
fatal("optoas: t is nil"); fatal("optoas: t is nil");
a = AGOK; a = AGOK;
switch(CASE(op, t->etype)) { switch(CASE(op, simtype[t->etype])) {
default: default:
fatal("optoas: no entry %O-%T", op, t); fatal("optoas: no entry %O-%T", op, t);
break; break;
......
...@@ -444,10 +444,10 @@ defaultlit(Node *n) ...@@ -444,10 +444,10 @@ defaultlit(Node *n)
case CTINT: case CTINT:
case CTSINT: case CTSINT:
case CTUINT: case CTUINT:
n->type = types[TINT32]; n->type = types[TINT];
break; break;
case CTFLT: case CTFLT:
n->type = types[TFLOAT64]; n->type = types[TFLOAT];
break; break;
case CTBOOL: case CTBOOL:
n->type = types[TBOOL]; n->type = types[TBOOL];
......
...@@ -302,15 +302,18 @@ enum ...@@ -302,15 +302,18 @@ enum
TINT16, TUINT16, TINT16, TUINT16,
TINT32, TUINT32, TINT32, TUINT32,
TINT64, TUINT64, TINT64, TUINT64,
TINT, TUINT, TUINTPTR,
TFLOAT32, // 9 TFLOAT32, // 12
TFLOAT64, TFLOAT64,
TFLOAT80, TFLOAT80,
TFLOAT,
TBOOL, // 12 TBOOL, // 16
TPTR32, TPTR64, // 13 TPTR32, TPTR64, // 17
TDDD, // 19
TFUNC, TFUNC,
TARRAY, TARRAY,
T_old_DARRAY, T_old_DARRAY,
...@@ -325,7 +328,7 @@ enum ...@@ -325,7 +328,7 @@ enum
TFORWSTRUCT, TFORWSTRUCT,
TFORWINTER, TFORWINTER,
NTYPE, // 28 NTYPE,
}; };
enum enum
{ {
...@@ -396,6 +399,7 @@ struct Io ...@@ -396,6 +399,7 @@ struct Io
Biobuf* bin; Biobuf* bin;
int32 ilineno; int32 ilineno;
int peekc; int peekc;
int peekc1; // second peekc for ...
char* cp; // used for content when bin==nil char* cp; // used for content when bin==nil
}; };
...@@ -433,6 +437,7 @@ EXTERN char* filename; // name to uniqify names ...@@ -433,6 +437,7 @@ EXTERN char* filename; // name to uniqify names
EXTERN int exportadj; // declaration is being exported EXTERN int exportadj; // declaration is being exported
EXTERN Type* types[NTYPE]; EXTERN Type* types[NTYPE];
EXTERN uchar simtype[NTYPE];
EXTERN uchar isptr[NTYPE]; EXTERN uchar isptr[NTYPE];
EXTERN uchar isint[NTYPE]; EXTERN uchar isint[NTYPE];
EXTERN uchar isfloat[NTYPE]; EXTERN uchar isfloat[NTYPE];
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
%token <sym> LNAME LBASETYPE LATYPE LPACK LACONST %token <sym> LNAME LBASETYPE LATYPE LPACK LACONST
%token <sym> LPACKAGE LIMPORT LEXPORT %token <sym> LPACKAGE LIMPORT LEXPORT
%token <sym> LMAP LCHAN LINTERFACE LFUNC LSTRUCT %token <sym> LMAP LCHAN LINTERFACE LFUNC LSTRUCT
%token <sym> LCOLAS LFALL LRETURN %token <sym> LCOLAS LFALL LRETURN LDDD
%token <sym> LNEW LLEN LCAP LTYPEOF LPANIC LPANICN LPRINT LPRINTN %token <sym> LNEW LLEN LCAP LTYPEOF LPANIC LPANICN LPRINT LPRINTN
%token <sym> LVAR LTYPE LCONST LCONVERT LSELECT %token <sym> LVAR LTYPE LCONST LCONVERT LSELECT
%token <sym> LFOR LIF LELSE LSWITCH LCASE LDEFAULT %token <sym> LFOR LIF LELSE LSWITCH LCASE LDEFAULT
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
%type <type> nametype structtype interfacetype convtype %type <type> nametype structtype interfacetype convtype
%type <type> non_name_type Anon_fn_type Bnon_fn_type %type <type> non_name_type Anon_fn_type Bnon_fn_type
%type <type> Anon_chan_type Bnon_chan_type %type <type> Anon_chan_type Bnon_chan_type
%type <type> indcl fnlitdcl %type <type> indcl fnlitdcl dotdotdot
%type <val> hidden_constant %type <val> hidden_constant
%type <node> hidden_dcl hidden_structdcl %type <node> hidden_dcl hidden_structdcl
...@@ -1047,6 +1047,13 @@ non_name_type: ...@@ -1047,6 +1047,13 @@ non_name_type:
chantype chantype
| fntype | fntype
| othertype | othertype
| dotdotdot
dotdotdot:
LDDD
{
$$ = typ(TDDD);
}
Anon_chan_type: Anon_chan_type:
Afntype Afntype
...@@ -1447,6 +1454,10 @@ arg_chunk: ...@@ -1447,6 +1454,10 @@ arg_chunk:
{ {
$$ = nametodcl($1, $2); $$ = nametodcl($1, $2);
} }
| new_name_list_r dotdotdot
{
$$ = nametodcl($1, $2);
}
| non_name_type | non_name_type
{ {
$$ = anondcl($1); $$ = anondcl($1);
......
...@@ -69,6 +69,7 @@ mainlex(int argc, char *argv[]) ...@@ -69,6 +69,7 @@ mainlex(int argc, char *argv[])
if(curio.bin == nil) if(curio.bin == nil)
fatal("cant open: %s", infile); fatal("cant open: %s", infile);
curio.peekc = 0; curio.peekc = 0;
curio.peekc1 = 0;
externdcl = mal(sizeof(*externdcl)); externdcl = mal(sizeof(*externdcl));
externdcl->back = externdcl; externdcl->back = externdcl;
...@@ -235,6 +236,7 @@ importfile(Val *f) ...@@ -235,6 +236,7 @@ importfile(Val *f)
pushedio = curio; pushedio = curio;
curio.bin = imp; curio.bin = imp;
curio.peekc = 0; curio.peekc = 0;
curio.peekc1 = 0;
curio.infile = file; curio.infile = file;
for(;;) { for(;;) {
c = getc(); c = getc();
...@@ -280,6 +282,7 @@ cannedimports(void) ...@@ -280,6 +282,7 @@ cannedimports(void)
pushedio = curio; pushedio = curio;
curio.bin = nil; curio.bin = nil;
curio.peekc = 0; curio.peekc = 0;
curio.peekc1 = 0;
curio.infile = file; curio.infile = file;
curio.cp = sysimport; curio.cp = sysimport;
...@@ -290,7 +293,7 @@ cannedimports(void) ...@@ -290,7 +293,7 @@ cannedimports(void)
int32 int32
yylex(void) yylex(void)
{ {
int c, c1; int c, c1, clen;
vlong v; vlong v;
char *cp; char *cp;
Rune rune; Rune rune;
...@@ -334,28 +337,37 @@ l0: ...@@ -334,28 +337,37 @@ l0:
c1 = 0; c1 = 0;
goto casedot; goto casedot;
} }
if(c1 == '.') {
c1 = getc();
if(c1 == '.') {
c = LDDD;
goto lx;
}
ungetc(c1);
c1 = '.';
}
break; break;
case '"': case '"':
/* "..." */ /* "..." */
strcpy(namebuf, "\"<string>\""); strcpy(namebuf, "\"<string>\"");
cp = mal(sizeof(int32)); cp = mal(sizeof(int32));
c1 = sizeof(int32); clen = sizeof(int32);
caseq: caseq:
for(;;) { for(;;) {
if(escchar('"', &escflag, &v)) if(escchar('"', &escflag, &v))
break; break;
if(v < Runeself || escflag) { if(v < Runeself || escflag) {
cp = remal(cp, c1, 1); cp = remal(cp, clen, 1);
cp[c1++] = v; cp[clen++] = v;
} else { } else {
// botch - this limits size of runes // botch - this limits size of runes
rune = v; rune = v;
c = runelen(rune); c = runelen(rune);
cp = remal(cp, c1, c); cp = remal(cp, clen, c);
runetochar(cp+c1, &rune); runetochar(cp+clen, &rune);
c1 += c; clen += c;
} }
} }
goto catem; goto catem;
...@@ -364,36 +376,66 @@ l0: ...@@ -364,36 +376,66 @@ l0:
/* `...` */ /* `...` */
strcpy(namebuf, "`<string>`"); strcpy(namebuf, "`<string>`");
cp = mal(sizeof(int32)); cp = mal(sizeof(int32));
c1 = sizeof(int32); clen = sizeof(int32);
casebq: casebq:
for(;;) { for(;;) {
c = getc(); c = getc();
if(c == EOF || c == '`') if(c == EOF || c == '`')
break; break;
cp = remal(cp, c1, 1); cp = remal(cp, clen, 1);
cp[c1++] = c; cp[clen++] = c;
} }
goto catem;
catem: catem:
for(;;) { c = getc();
/* it takes 2 peekc's to skip comments */ if(isspace(c))
c = getc(); goto catem;
if(isspace(c))
continue; // skip comments
if(c == '"') if(c == '/') {
goto caseq; c1 = getc();
if(c == '`') if(c1 == '*') {
goto casebq; for(;;) {
ungetc(c); c = getr();
break; while(c == '*') {
c = getr();
if(c == '/')
goto catem;
}
if(c == EOF) {
yyerror("eof in comment");
errorexit();
}
}
}
if(c1 == '/') {
for(;;) {
c = getr();
if(c == '\n')
goto catem;
if(c == EOF) {
yyerror("eof in comment");
errorexit();
}
}
}
ungetc(c1);
} }
*(int32*)cp = c1-sizeof(int32); // length // cat adjacent strings
if(c == '"')
goto caseq;
if(c == '`')
goto casebq;
ungetc(c);
*(int32*)cp = clen-sizeof(int32); // length
do { do {
cp = remal(cp, c1, 1); cp = remal(cp, clen, 1);
cp[c1++] = 0; cp[clen++] = 0;
} while(c1 & MAXALIGN); } while(clen & MAXALIGN);
yylval.val.u.sval = (String*)cp; yylval.val.u.sval = (String*)cp;
yylval.val.ctype = CTSTR; yylval.val.ctype = CTSTR;
DBG("lex: string literal\n"); DBG("lex: string literal\n");
...@@ -753,7 +795,8 @@ getc(void) ...@@ -753,7 +795,8 @@ getc(void)
c = curio.peekc; c = curio.peekc;
if(c != 0) { if(c != 0) {
curio.peekc = 0; curio.peekc = curio.peekc1;
curio.peekc1 = 0;
if(c == '\n') if(c == '\n')
lineno++; lineno++;
return c; return c;
...@@ -783,6 +826,7 @@ getc(void) ...@@ -783,6 +826,7 @@ getc(void)
void void
ungetc(int c) ungetc(int c)
{ {
curio.peekc1 = curio.peekc;
curio.peekc = c; curio.peekc = c;
if(c == '\n') if(c == '\n')
lineno--; lineno--;
...@@ -968,7 +1012,6 @@ static struct ...@@ -968,7 +1012,6 @@ static struct
"bool", LBASETYPE, TBOOL, "bool", LBASETYPE, TBOOL,
"byte", LBASETYPE, TUINT8, "byte", LBASETYPE, TUINT8,
"char", LBASETYPE, TUINT8, // temp??
"string", LBASETYPE, TSTRING, "string", LBASETYPE, TSTRING,
"any", LBASETYPE, TANY, "any", LBASETYPE, TANY,
...@@ -1028,15 +1071,25 @@ lexinit(void) ...@@ -1028,15 +1071,25 @@ lexinit(void)
Type *t; Type *t;
Sym *s; Sym *s;
for(i=0; i<NTYPE; i++)
simtype[i] = i;
besetptr(); besetptr();
for(i=TINT8; i<=TUINT64; i++) for(i=TINT8; i<=TUINT64; i++)
isint[i] = 1; isint[i] = 1;
isint[TINT] = 1;
isint[TUINT] = 1;
isint[TUINTPTR] = 1;
for(i=TFLOAT32; i<=TFLOAT80; i++) for(i=TFLOAT32; i<=TFLOAT80; i++)
isfloat[i] = 1; isfloat[i] = 1;
isfloat[TFLOAT] = 1;
isptr[TPTR32] = 1; isptr[TPTR32] = 1;
isptr[TPTR64] = 1; isptr[TPTR64] = 1;
issigned[TINT] = 1;
issigned[TINT8] = 1; issigned[TINT8] = 1;
issigned[TINT16] = 1; issigned[TINT16] = 1;
issigned[TINT32] = 1; issigned[TINT32] = 1;
...@@ -1092,7 +1145,6 @@ lexinit(void) ...@@ -1092,7 +1145,6 @@ lexinit(void)
mpatoflt(maxfltval[TFLOAT64], "1.7976931348623157e+308"); mpatoflt(maxfltval[TFLOAT64], "1.7976931348623157e+308");
mpatoflt(minfltval[TFLOAT64], "-1.7976931348623157e+308"); mpatoflt(minfltval[TFLOAT64], "-1.7976931348623157e+308");
/* /*
* initialize basic types array * initialize basic types array
* initialize known symbols * initialize known symbols
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "go.h" #include "go.h"
/// uses arihmetic /// uses arithmetic
int int
mpcmpfixflt(Mpint *a, Mpflt *b) mpcmpfixflt(Mpint *a, Mpflt *b)
......
...@@ -340,7 +340,7 @@ nodintconst(int32 v) ...@@ -340,7 +340,7 @@ nodintconst(int32 v)
c->val.u.xval = mal(sizeof(*c->val.u.xval)); c->val.u.xval = mal(sizeof(*c->val.u.xval));
mpmovecfix(c->val.u.xval, v); mpmovecfix(c->val.u.xval, v);
c->val.ctype = CTINT; c->val.ctype = CTINT;
c->type = types[TINT32]; c->type = types[TINT];
ullmancalc(c); ullmancalc(c);
return c; return c;
} }
...@@ -578,15 +578,19 @@ whatis(Node *n) ...@@ -578,15 +578,19 @@ whatis(Node *n)
return Wtnil; return Wtnil;
switch(t->etype) { switch(t->etype) {
case TINT:
case TINT8: case TINT8:
case TINT16: case TINT16:
case TINT32: case TINT32:
case TINT64: case TINT64:
case TUINT:
case TUINT8: case TUINT8:
case TUINT16: case TUINT16:
case TUINT32: case TUINT32:
case TUINT64: case TUINT64:
case TUINTPTR:
return Wtint; return Wtint;
case TFLOAT:
case TFLOAT32: case TFLOAT32:
case TFLOAT64: case TFLOAT64:
case TFLOAT80: case TFLOAT80:
...@@ -796,6 +800,8 @@ s%~ %%g ...@@ -796,6 +800,8 @@ s%~ %%g
static char* static char*
etnames[] = etnames[] =
{ {
[TINT] = "INT",
[TUINT] = "UINT",
[TINT8] = "INT8", [TINT8] = "INT8",
[TUINT8] = "UINT8", [TUINT8] = "UINT8",
[TINT16] = "INT16", [TINT16] = "INT16",
...@@ -804,6 +810,8 @@ etnames[] = ...@@ -804,6 +810,8 @@ etnames[] =
[TUINT32] = "UINT32", [TUINT32] = "UINT32",
[TINT64] = "INT64", [TINT64] = "INT64",
[TUINT64] = "UINT64", [TUINT64] = "UINT64",
[TUINTPTR] = "UINTPTR",
[TFLOAT] = "FLOAT",
[TFLOAT32] = "FLOAT32", [TFLOAT32] = "FLOAT32",
[TFLOAT64] = "FLOAT64", [TFLOAT64] = "FLOAT64",
[TFLOAT80] = "FLOAT80", [TFLOAT80] = "FLOAT80",
...@@ -939,20 +947,26 @@ out: ...@@ -939,20 +947,26 @@ out:
return fmtstrcpy(fp, buf); return fmtstrcpy(fp, buf);
} }
static char *basicnames[] = { static char*
[TINT8] "int8", basicnames[] =
[TUINT8] "uint8", {
[TINT16] "int16", [TINT] = "int",
[TUINT16] "uint16", [TUINT] = "uint",
[TINT32] "int32", [TINT8] = "int8",
[TUINT32] "uint32", [TUINT8] = "uint8",
[TINT64] "int64", [TINT16] = "int16",
[TUINT64] "uint64", [TUINT16] = "uint16",
[TFLOAT32] "float32", [TINT32] = "int32",
[TFLOAT64] "float64", [TUINT32] = "uint32",
[TFLOAT80] "float80", [TINT64] = "int64",
[TBOOL] "bool", [TUINT64] = "uint64",
[TANY] "any", [TUINTPTR] = "uintptr",
[TFLOAT] = "float",
[TFLOAT32] = "float32",
[TFLOAT64] = "float64",
[TFLOAT80] = "float80",
[TBOOL] = "bool",
[TANY] = "any",
}; };
int int
...@@ -1609,16 +1623,20 @@ globalsig(Type *t) ...@@ -1609,16 +1623,20 @@ globalsig(Type *t)
} }
return S; return S;
case TINT:
case TINT8: case TINT8:
case TINT16: case TINT16:
case TINT32: case TINT32:
case TINT64: case TINT64:
case TUINT:
case TUINT8: case TUINT8:
case TUINT16: case TUINT16:
case TUINT32: case TUINT32:
case TUINT64: case TUINT64:
case TUINTPTR:
case TFLOAT:
case TFLOAT32: case TFLOAT32:
case TFLOAT64: case TFLOAT64:
case TFLOAT80: case TFLOAT80:
......
...@@ -5,14 +5,14 @@ ...@@ -5,14 +5,14 @@
package SYS // rename to avoid redeclaration package SYS // rename to avoid redeclaration
export func mal(uint32) *any; export func mal(int32) *any;
export func breakpoint(); export func breakpoint();
export func throwindex(); export func throwindex();
export func throwreturn(); export func throwreturn();
export func panicl(int32); export func panicl(int32);
export func printbool(bool); export func printbool(bool);
export func printfloat(double); export func printfloat(float64);
export func printint(int64); export func printint(int64);
export func printstring(string); export func printstring(string);
export func printpointer(*any); export func printpointer(*any);
...@@ -21,11 +21,11 @@ export func printnl(); ...@@ -21,11 +21,11 @@ export func printnl();
export func printsp(); export func printsp();
export func catstring(string, string) string; export func catstring(string, string) string;
export func cmpstring(string, string) int32; export func cmpstring(string, string) int;
export func slicestring(string, int32, int32) string; export func slicestring(string, int, int) string;
export func indexstring(string, int32) byte; export func indexstring(string, int) byte;
export func intstring(int64) string; export func intstring(int64) string;
export func byteastring(*byte, int32) string; export func byteastring(*byte, int) string;
export func arraystring(*[]byte) string; export func arraystring(*[]byte) string;
export func ifaceT2I(sigi *byte, sigt *byte, elem any) (ret any); export func ifaceT2I(sigi *byte, sigt *byte, elem any) (ret any);
...@@ -34,50 +34,50 @@ export func ifaceI2I(sigi *byte, iface any) (ret any); ...@@ -34,50 +34,50 @@ export func ifaceI2I(sigi *byte, iface any) (ret any);
export func ifaceeq(i1 any, i2 any) (ret bool); export func ifaceeq(i1 any, i2 any) (ret bool);
export func reflect(i interface { }) (uint64, string); export func reflect(i interface { }) (uint64, string);
export func argc() int32; export func argc() int;
export func envc() int32; export func envc() int;
export func argv(int32) string; export func argv(int) string;
export func envv(int32) string; export func envv(int) string;
export func frexp(float64) (float64, int32); // break fp into exp,fract export func frexp(float64) (float64, int); // break fp into exp,fract
export func ldexp(float64, int32) float64; // make fp from exp,fract export func ldexp(float64, int) float64; // make fp from exp,fract
export func modf(float64) (float64, float64); // break fp into double.double export func modf(float64) (float64, float64); // break fp into double.double
export func isInf(float64, int32) bool; // test for infinity export func isInf(float64, int) bool; // test for infinity
export func isNaN(float64) bool; // test for not-a-number export func isNaN(float64) bool; // test for not-a-number
export func Inf(int32) float64; // return signed Inf export func Inf(int) float64; // return signed Inf
export func NaN() float64; // return a NaN export func NaN() float64; // return a NaN
export func newmap(keysize uint32, valsize uint32, export func newmap(keysize int, valsize int,
keyalg uint32, valalg uint32, keyalg int, valalg int,
hint uint32) (hmap *map[any]any); hint int) (hmap *map[any]any);
export func mapaccess1(hmap *map[any]any, key any) (val any); export func mapaccess1(hmap *map[any]any, key any) (val any);
export func mapaccess2(hmap *map[any]any, key any) (val any, pres bool); export func mapaccess2(hmap *map[any]any, key any) (val any, pres bool);
export func mapassign1(hmap *map[any]any, key any, val any); export func mapassign1(hmap *map[any]any, key any, val any);
export func mapassign2(hmap *map[any]any, key any, val any, pres bool); export func mapassign2(hmap *map[any]any, key any, val any, pres bool);
export func newchan(elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any); export func newchan(elemsize int, elemalg int, hint int) (hchan *chan any);
export func chanrecv1(hchan *chan any) (elem any); export func chanrecv1(hchan *chan any) (elem any);
export func chanrecv2(hchan *chan any) (elem any, pres bool); export func chanrecv2(hchan *chan any) (elem any, pres bool);
export func chanrecv3(hchan *chan any, elem *any) (pres bool); export func chanrecv3(hchan *chan any, elem *any) (pres bool);
export func chansend1(hchan *chan any, elem any); export func chansend1(hchan *chan any, elem any);
export func chansend2(hchan *chan any, elem any) (pres bool); export func chansend2(hchan *chan any, elem any) (pres bool);
export func newselect(size uint32) (sel *byte); export func newselect(size int) (sel *byte);
export func selectsend(sel *byte, hchan *chan any, elem any) (selected bool); export func selectsend(sel *byte, hchan *chan any, elem any) (selected bool);
export func selectrecv(sel *byte, hchan *chan any, elem *any) (selected bool); export func selectrecv(sel *byte, hchan *chan any, elem *any) (selected bool);
export func selectgo(sel *byte); export func selectgo(sel *byte);
export func newarray(nel uint32, cap uint32, width uint32) (ary *[]any); export func newarray(nel int, cap int, width int) (ary *[]any);
export func arraysliced(old *[]any, lb uint32, hb uint32, width uint32) (ary *[]any); export func arraysliced(old *[]any, lb int, hb int, width int) (ary *[]any);
export func arrayslices(old *any, nel uint32, lb uint32, hb uint32, width uint32) (ary *[]any); export func arrayslices(old *any, nel int, lb int, hb int, width int) (ary *[]any);
export func arrays2d(old *any, nel uint32) (ary *[]any); export func arrays2d(old *any, nel int) (ary *[]any);
export func gosched(); export func gosched();
export func goexit(); export func goexit();
export func readfile(string) (string, bool); // read file into string; boolean status export func readfile(string) (string, bool); // read file into string; boolean status
export func writefile(string, string) (bool); // write string into file; boolean status export func writefile(string, string) (bool); // write string into file; boolean status
export func bytestorune(*byte, int32, int32) (int32, int32); // convert bytes to runes export func bytestorune(*byte, int, int) (int, int); // convert bytes to runes
export func stringtorune(string, int32) (int32, int32); // convert bytes to runes export func stringtorune(string, int) (int, int); // convert bytes to runes
export func exit(int32); export func exit(int);
char *sysimport = char *sysimport =
"package sys\n" "package sys\n"
"export func sys.mal (? uint32) (? *any)\n" "export func sys.mal (? int32) (? *any)\n"
"export func sys.breakpoint ()\n" "export func sys.breakpoint ()\n"
"export func sys.throwindex ()\n" "export func sys.throwindex ()\n"
"export func sys.throwreturn ()\n" "export func sys.throwreturn ()\n"
...@@ -14,53 +14,53 @@ char *sysimport = ...@@ -14,53 +14,53 @@ char *sysimport =
"export func sys.printnl ()\n" "export func sys.printnl ()\n"
"export func sys.printsp ()\n" "export func sys.printsp ()\n"
"export func sys.catstring (? string, ? string) (? string)\n" "export func sys.catstring (? string, ? string) (? string)\n"
"export func sys.cmpstring (? string, ? string) (? int32)\n" "export func sys.cmpstring (? string, ? string) (? int)\n"
"export func sys.slicestring (? string, ? int32, ? int32) (? string)\n" "export func sys.slicestring (? string, ? int, ? int) (? string)\n"
"export func sys.indexstring (? string, ? int32) (? uint8)\n" "export func sys.indexstring (? string, ? int) (? uint8)\n"
"export func sys.intstring (? int64) (? string)\n" "export func sys.intstring (? int64) (? string)\n"
"export func sys.byteastring (? *uint8, ? int32) (? string)\n" "export func sys.byteastring (? *uint8, ? int) (? string)\n"
"export func sys.arraystring (? *[]uint8) (? string)\n" "export func sys.arraystring (? *[]uint8) (? string)\n"
"export func sys.ifaceT2I (sigi *uint8, sigt *uint8, elem any) (ret any)\n" "export func sys.ifaceT2I (sigi *uint8, sigt *uint8, elem any) (ret any)\n"
"export func sys.ifaceI2T (sigt *uint8, iface any) (ret any)\n" "export func sys.ifaceI2T (sigt *uint8, iface any) (ret any)\n"
"export func sys.ifaceI2I (sigi *uint8, iface any) (ret any)\n" "export func sys.ifaceI2I (sigi *uint8, iface any) (ret any)\n"
"export func sys.ifaceeq (i1 any, i2 any) (ret bool)\n" "export func sys.ifaceeq (i1 any, i2 any) (ret bool)\n"
"export func sys.reflect (i interface { }) (? uint64, ? string)\n" "export func sys.reflect (i interface { }) (? uint64, ? string)\n"
"export func sys.argc () (? int32)\n" "export func sys.argc () (? int)\n"
"export func sys.envc () (? int32)\n" "export func sys.envc () (? int)\n"
"export func sys.argv (? int32) (? string)\n" "export func sys.argv (? int) (? string)\n"
"export func sys.envv (? int32) (? string)\n" "export func sys.envv (? int) (? string)\n"
"export func sys.frexp (? float64) (? float64, ? int32)\n" "export func sys.frexp (? float64) (? float64, ? int)\n"
"export func sys.ldexp (? float64, ? int32) (? float64)\n" "export func sys.ldexp (? float64, ? int) (? float64)\n"
"export func sys.modf (? float64) (? float64, ? float64)\n" "export func sys.modf (? float64) (? float64, ? float64)\n"
"export func sys.isInf (? float64, ? int32) (? bool)\n" "export func sys.isInf (? float64, ? int) (? bool)\n"
"export func sys.isNaN (? float64) (? bool)\n" "export func sys.isNaN (? float64) (? bool)\n"
"export func sys.Inf (? int32) (? float64)\n" "export func sys.Inf (? int) (? float64)\n"
"export func sys.NaN () (? float64)\n" "export func sys.NaN () (? float64)\n"
"export func sys.newmap (keysize uint32, valsize uint32, keyalg uint32, valalg uint32, hint uint32) (hmap *map[any] any)\n" "export func sys.newmap (keysize int, valsize int, keyalg int, valalg int, hint int) (hmap *map[any] any)\n"
"export func sys.mapaccess1 (hmap *map[any] any, key any) (val any)\n" "export func sys.mapaccess1 (hmap *map[any] any, key any) (val any)\n"
"export func sys.mapaccess2 (hmap *map[any] any, key any) (val any, pres bool)\n" "export func sys.mapaccess2 (hmap *map[any] any, key any) (val any, pres bool)\n"
"export func sys.mapassign1 (hmap *map[any] any, key any, val any)\n" "export func sys.mapassign1 (hmap *map[any] any, key any, val any)\n"
"export func sys.mapassign2 (hmap *map[any] any, key any, val any, pres bool)\n" "export func sys.mapassign2 (hmap *map[any] any, key any, val any, pres bool)\n"
"export func sys.newchan (elemsize uint32, elemalg uint32, hint uint32) (hchan *chan any)\n" "export func sys.newchan (elemsize int, elemalg int, hint int) (hchan *chan any)\n"
"export func sys.chanrecv1 (hchan *chan any) (elem any)\n" "export func sys.chanrecv1 (hchan *chan any) (elem any)\n"
"export func sys.chanrecv2 (hchan *chan any) (elem any, pres bool)\n" "export func sys.chanrecv2 (hchan *chan any) (elem any, pres bool)\n"
"export func sys.chanrecv3 (hchan *chan any, elem *any) (pres bool)\n" "export func sys.chanrecv3 (hchan *chan any, elem *any) (pres bool)\n"
"export func sys.chansend1 (hchan *chan any, elem any)\n" "export func sys.chansend1 (hchan *chan any, elem any)\n"
"export func sys.chansend2 (hchan *chan any, elem any) (pres bool)\n" "export func sys.chansend2 (hchan *chan any, elem any) (pres bool)\n"
"export func sys.newselect (size uint32) (sel *uint8)\n" "export func sys.newselect (size int) (sel *uint8)\n"
"export func sys.selectsend (sel *uint8, hchan *chan any, elem any) (selected bool)\n" "export func sys.selectsend (sel *uint8, hchan *chan any, elem any) (selected bool)\n"
"export func sys.selectrecv (sel *uint8, hchan *chan any, elem *any) (selected bool)\n" "export func sys.selectrecv (sel *uint8, hchan *chan any, elem *any) (selected bool)\n"
"export func sys.selectgo (sel *uint8)\n" "export func sys.selectgo (sel *uint8)\n"
"export func sys.newarray (nel uint32, cap uint32, width uint32) (ary *[]any)\n" "export func sys.newarray (nel int, cap int, width int) (ary *[]any)\n"
"export func sys.arraysliced (old *[]any, lb uint32, hb uint32, width uint32) (ary *[]any)\n" "export func sys.arraysliced (old *[]any, lb int, hb int, width int) (ary *[]any)\n"
"export func sys.arrayslices (old *any, nel uint32, lb uint32, hb uint32, width uint32) (ary *[]any)\n" "export func sys.arrayslices (old *any, nel int, lb int, hb int, width int) (ary *[]any)\n"
"export func sys.arrays2d (old *any, nel uint32) (ary *[]any)\n" "export func sys.arrays2d (old *any, nel int) (ary *[]any)\n"
"export func sys.gosched ()\n" "export func sys.gosched ()\n"
"export func sys.goexit ()\n" "export func sys.goexit ()\n"
"export func sys.readfile (? string) (? string, ? bool)\n" "export func sys.readfile (? string) (? string, ? bool)\n"
"export func sys.writefile (? string, ? string) (? bool)\n" "export func sys.writefile (? string, ? string) (? bool)\n"
"export func sys.bytestorune (? *uint8, ? int32, ? int32) (? int32, ? int32)\n" "export func sys.bytestorune (? *uint8, ? int, ? int) (? int, ? int)\n"
"export func sys.stringtorune (? string, ? int32) (? int32, ? int32)\n" "export func sys.stringtorune (? string, ? int) (? int, ? int)\n"
"export func sys.exit (? int32)\n" "export func sys.exit (? int)\n"
"\n" "\n"
"$$\n"; "$$\n";
...@@ -353,7 +353,7 @@ loop: ...@@ -353,7 +353,7 @@ loop:
case 0: case 0:
if(top == Erv) { if(top == Erv) {
yyerror("function requires a return type"); yyerror("function requires a return type");
n->type = types[TINT32]; n->type = types[TINT];
} }
break; break;
...@@ -645,8 +645,8 @@ loop: ...@@ -645,8 +645,8 @@ loop:
evconst(n); evconst(n);
if(n->op == OLITERAL) if(n->op == OLITERAL)
goto ret; goto ret;
convlit(n->right, types[TUINT32]); convlit(n->right, types[TUINT]);
convlit(n->left, types[TINT32]); convlit(n->left, types[TINT]);
if(n->left->type == T || n->right->type == T) if(n->left->type == T || n->right->type == T)
goto ret; goto ret;
if(issigned[n->right->type->etype]) if(issigned[n->right->type->etype])
...@@ -734,10 +734,10 @@ loop: ...@@ -734,10 +734,10 @@ loop:
break; break;
case TARRAY: case TARRAY:
if(t->bound >= 0) if(t->bound >= 0)
nodconst(n, types[TINT32], t->bound); nodconst(n, types[TINT], t->bound);
break; break;
} }
n->type = types[TINT32]; n->type = types[TINT];
goto ret; goto ret;
case OCAP: case OCAP:
...@@ -755,10 +755,10 @@ loop: ...@@ -755,10 +755,10 @@ loop:
goto badt; goto badt;
case TARRAY: case TARRAY:
if(t->bound >= 0) if(t->bound >= 0)
nodconst(n, types[TINT32], t->bound); nodconst(n, types[TINT], t->bound);
break; break;
} }
n->type = types[TINT32]; n->type = types[TINT];
goto ret; goto ret;
case OINDEX: case OINDEX:
...@@ -785,7 +785,7 @@ loop: ...@@ -785,7 +785,7 @@ loop:
if(top != Erv) if(top != Erv)
goto nottop; goto nottop;
if(n->right->type == T) { if(n->right->type == T) {
convlit(n->right, types[TINT32]); convlit(n->right, types[TINT]);
if(n->right->type == T) if(n->right->type == T)
goto ret; goto ret;
} }
...@@ -825,7 +825,7 @@ loop: ...@@ -825,7 +825,7 @@ loop:
case TARRAY: case TARRAY:
// right side must be an int // right side must be an int
if(n->right->type == T) { if(n->right->type == T) {
convlit(n->right, types[TINT32]); convlit(n->right, types[TINT]);
if(n->right->type == T) if(n->right->type == T)
break; break;
} }
...@@ -1110,7 +1110,7 @@ sw1(Node *c, Type *place) ...@@ -1110,7 +1110,7 @@ sw1(Node *c, Type *place)
Type* Type*
sw2(Node *c, Type *place) sw2(Node *c, Type *place)
{ {
return types[TINT32]; // botch return types[TINT]; // botch
} }
/* /*
...@@ -1406,7 +1406,7 @@ walkselect(Node *sel) ...@@ -1406,7 +1406,7 @@ walkselect(Node *sel)
on = syslook("newselect", 0); on = syslook("newselect", 0);
r = nod(OXXX, N, N); r = nod(OXXX, N, N);
nodconst(r, types[TINT32], count); // count nodconst(r, types[TINT], count); // count
r = nod(OCALL, on, r); r = nod(OCALL, on, r);
r = nod(OAS, var, r); r = nod(OAS, var, r);
...@@ -1870,10 +1870,10 @@ stringop(Node *n, int top) ...@@ -1870,10 +1870,10 @@ stringop(Node *n, int top)
case OSLICE: case OSLICE:
// sys_slicestring(s, lb, hb) // sys_slicestring(s, lb, hb)
r = nod(OCONV, n->right->left, N); r = nod(OCONV, n->right->left, N);
r->type = types[TINT32]; r->type = types[TINT];
c = nod(OCONV, n->right->right, N); c = nod(OCONV, n->right->right, N);
c->type = types[TINT32]; c->type = types[TINT];
r = list(r, c); r = list(r, c);
r = list(n->left, r); r = list(n->left, r);
...@@ -1890,7 +1890,7 @@ stringop(Node *n, int top) ...@@ -1890,7 +1890,7 @@ stringop(Node *n, int top)
c->type = c->left->type->type; c->type = c->left->type->type;
} }
r = nod(OCONV, n->right, N); r = nod(OCONV, n->right, N);
r->type = types[TINT32]; r->type = types[TINT];
r = list(c, r); r = list(c, r);
on = syslook("indexstring", 0); on = syslook("indexstring", 0);
r = nod(OCALL, on, r); r = nod(OCALL, on, r);
...@@ -1984,9 +1984,9 @@ mapop(Node *n, int top) ...@@ -1984,9 +1984,9 @@ mapop(Node *n, int top)
if(top != Erv) if(top != Erv)
goto nottop; goto nottop;
// newmap(keysize uint32, valsize uint32, // newmap(keysize int, valsize int,
// keyalg uint32, valalg uint32, // keyalg int, valalg int,
// hint uint32) (hmap *map[any-1]any-2); // hint int) (hmap *map[any-1]any-2);
t = fixmap(n->type); t = fixmap(n->type);
if(t == T) if(t == T)
...@@ -2194,8 +2194,8 @@ chanop(Node *n, int top) ...@@ -2194,8 +2194,8 @@ chanop(Node *n, int top)
fatal("chanop: unknown op %O", n->op); fatal("chanop: unknown op %O", n->op);
case ONEW: case ONEW:
// newchan(elemsize uint32, elemalg uint32, // newchan(elemsize int, elemalg int,
// hint uint32) (hmap *chan[any-1]); // hint int) (hmap *chan[any-1]);
t = fixchan(n->type); t = fixchan(n->type);
if(t == T) if(t == T)
...@@ -2380,12 +2380,12 @@ arrayop(Node *n, int top) ...@@ -2380,12 +2380,12 @@ arrayop(Node *n, int top)
fatal("darrayop: unknown op %O", n->op); fatal("darrayop: unknown op %O", n->op);
case ONEW: case ONEW:
// newarray(nel uint32, max uint32, width uint32) (ary *[]any) // newarray(nel int, max int, width int) (ary *[]any)
t = fixarray(n->type); t = fixarray(n->type);
a = nodintconst(t->type->width); // width a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N); a = nod(OCONV, a, N);
a->type = types[TUINT32]; a->type = types[TINT];
r = a; r = a;
a = listfirst(&save, &n->left); // max a = listfirst(&save, &n->left); // max
...@@ -2393,7 +2393,7 @@ arrayop(Node *n, int top) ...@@ -2393,7 +2393,7 @@ arrayop(Node *n, int top)
if(a == N) if(a == N)
a = nodintconst(0); a = nodintconst(0);
a = nod(OCONV, a, N); a = nod(OCONV, a, N);
a->type = types[TUINT32]; a->type = types[TINT];
r = list(a, r); r = list(a, r);
a = listfirst(&save, &n->left); // nel a = listfirst(&save, &n->left); // nel
...@@ -2403,7 +2403,7 @@ arrayop(Node *n, int top) ...@@ -2403,7 +2403,7 @@ arrayop(Node *n, int top)
a = nodintconst(t->bound); a = nodintconst(t->bound);
} }
a = nod(OCONV, a, N); a = nod(OCONV, a, N);
a->type = types[TUINT32]; a->type = types[TINT];
r = list(a, r); r = list(a, r);
on = syslook("newarray", 1); on = syslook("newarray", 1);
...@@ -2421,12 +2421,12 @@ arrayop(Node *n, int top) ...@@ -2421,12 +2421,12 @@ arrayop(Node *n, int top)
break; break;
case OAS: case OAS:
// arrays2d(old *any, nel uint32) (ary *[]any) // arrays2d(old *any, nel int) (ary *[]any)
t = fixarray(n->right->type); t = fixarray(n->right->type);
a = nodintconst(t->bound); // nel a = nodintconst(t->bound); // nel
a = nod(OCONV, a, N); a = nod(OCONV, a, N);
a->type = types[TUINT32]; a->type = types[TINT];
r = a; r = a;
a = n->right; // old a = n->right; // old
...@@ -2445,20 +2445,20 @@ arrayop(Node *n, int top) ...@@ -2445,20 +2445,20 @@ arrayop(Node *n, int top)
if(isptrarray(n->left->type)) if(isptrarray(n->left->type))
goto slicestatic; goto slicestatic;
// arrayslices(old *[]any, lb uint32, hb uint32, width uint32) (ary *[]any) // arrayslices(old *[]any, lb int, hb int, width int) (ary *[]any)
t = fixarray(n->left->type); t = fixarray(n->left->type);
a = nodintconst(t->type->width); // width a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N); a = nod(OCONV, a, N);
a->type = types[TUINT32]; a->type = types[TINT];
r = a; r = a;
a = nod(OCONV, n->right->right, N); // hb a = nod(OCONV, n->right->right, N); // hb
a->type = types[TUINT32]; a->type = types[TINT];
r = list(a, r); r = list(a, r);
a = nod(OCONV, n->right->left, N); // lb a = nod(OCONV, n->right->left, N); // lb
a->type = types[TUINT32]; a->type = types[TINT];
r = list(a, r); r = list(a, r);
a = n->left; // old a = n->left; // old
...@@ -2472,25 +2472,25 @@ arrayop(Node *n, int top) ...@@ -2472,25 +2472,25 @@ arrayop(Node *n, int top)
break; break;
slicestatic: slicestatic:
// arrayslices(old *any, nel uint32, lb uint32, hb uint32, width uint32) (ary *[]any) // arrayslices(old *any, nel int, lb int, hb int, width int) (ary *[]any)
t = fixarray(n->left->type); t = fixarray(n->left->type);
a = nodintconst(t->type->width); // width a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N); a = nod(OCONV, a, N);
a->type = types[TUINT32]; a->type = types[TINT];
r = a; r = a;
a = nod(OCONV, n->right->right, N); // hb a = nod(OCONV, n->right->right, N); // hb
a->type = types[TUINT32]; a->type = types[TINT];
r = list(a, r); r = list(a, r);
a = nod(OCONV, n->right->left, N); // lb a = nod(OCONV, n->right->left, N); // lb
a->type = types[TUINT32]; a->type = types[TINT];
r = list(a, r); r = list(a, r);
a = nodintconst(t->bound); // nel a = nodintconst(t->bound); // nel
a = nod(OCONV, a, N); a = nod(OCONV, a, N);
a->type = types[TUINT32]; a->type = types[TINT];
r = list(a, r); r = list(a, r);
a = n->left; // old a = n->left; // old
......
...@@ -164,7 +164,7 @@ export func atol(s string) (i int64, ok bool) { ...@@ -164,7 +164,7 @@ export func atol(s string) (i int64, ok bool) {
export func atoi(s string) (i int, ok bool) { export func atoi(s string) (i int, ok bool) {
ii, okok := atol(s); ii, okok := atol(s);
i = int32(ii); i = int(ii);
return i, okok return i, okok
} }
......
...@@ -44,7 +44,7 @@ export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) { ...@@ -44,7 +44,7 @@ export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
} }
export func pipe(fds *[2]int64) (ret int64, errno int64) { export func pipe(fds *[2]int64) (ret int64, errno int64) {
var t [2] int32; var t [2] int;
r1, r2, err := Syscall(SYS_PIPE, Int32Ptr(&t[0]), 0, 0); r1, r2, err := Syscall(SYS_PIPE, Int32Ptr(&t[0]), 0, 0);
if r1 < 0 { if r1 < 0 {
return r1, err; return r1, err;
......
...@@ -49,7 +49,7 @@ export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err i ...@@ -49,7 +49,7 @@ export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err i
} }
export func setsockopt_int(fd, level, opt int64, value int) int64 { export func setsockopt_int(fd, level, opt int64, value int) int64 {
n := int32(opt); n := int(opt);
r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4); r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4);
return e return e
} }
...@@ -58,7 +58,7 @@ export func setsockopt_tv(fd, level, opt, nsec int64) int64 { ...@@ -58,7 +58,7 @@ export func setsockopt_tv(fd, level, opt, nsec int64) int64 {
var tv Timeval; var tv Timeval;
nsec += 999; nsec += 999;
tv.sec = int64(nsec/1000000000); tv.sec = int64(nsec/1000000000);
tv.usec = uint32(nsec%1000000000); tv.usec = uint(nsec%1000000000);
r1, e := setsockopt(fd, level, opt, TimevalPtr(&tv), 4); r1, e := setsockopt(fd, level, opt, TimevalPtr(&tv), 4);
return e return e
} }
......
...@@ -61,7 +61,7 @@ export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err i ...@@ -61,7 +61,7 @@ export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err i
} }
export func setsockopt_int(fd, level, opt int64, value int) int64 { export func setsockopt_int(fd, level, opt int64, value int) int64 {
n := int32(opt); n := int(opt);
r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4); r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4);
return e return e
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment