static int wptr = 8; // width of a pointer
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
rnd(uint32 o, uint32 r)
{
t->width = -2;
w = 0;
- switch(t->etype) {
+ switch(simtype[t->etype]) {
default:
fatal("dowidth: unknown type: %E", t->etype);
break;
+ /* compiler-specific stuff */
case TINT8:
case TUINT8:
case TBOOL: // bool is int8
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
belexinit(int lextype)
{
- int i;
- Sym *s0, *s1;
+ int i, etype, sameas;
+ Sym *s;
+ Type *t;
zprog.link = P;
zprog.as = AGOK;
zprog.from.scale = 0;
zprog.to = zprog.from;
- for(i=0; i<nelem(typedefs); i+=2) {
- s1 = lookup(typedefs[i+1]);
- if(s1->lexical != lextype)
- yyerror("need %s to define %s",
- typedefs[i+1], typedefs[i+0]);
- s0 = lookup(typedefs[i+0]);
- s0->lexical = s1->lexical;
- s0->otype = s1->otype;
+ for(i=0; i<nelem(typedefs); i++) {
+ s = lookup(typedefs[i].name);
+ s->lexical = lextype;
+
+ etype = typedefs[i].etype;
+ if(etype < 0 || etype >= nelem(types))
+ fatal("lexinit: %s bad etype", s->name);
+ 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
fatal("cgen_as: tl %T", tl);
break;
+ case TINT:
+ case TUINT:
case TINT8:
case TUINT8:
case TINT16:
case TUINT32:
case TINT64:
case TUINT64:
+ case TUINTPTR:
nr->val.u.xval = mal(sizeof(*nr->val.u.xval));
mpmovecfix(nr->val.u.xval, 0);
nr->val.ctype = CTINT;
break;
+ case TFLOAT:
case TFLOAT32:
case TFLOAT64:
case TFLOAT80:
a = optoas(op, nl->type);
if(nr->op == OLITERAL) {
- regalloc(&n1, nr->type, res);
+ regalloc(&n1, nl->type, res);
cgen(nl, &n1);
gins(a, nr, &n1);
gmove(&n1, res);
cgen(nr, &n1);
cgen(nl, &n2);
}
-
// test and fix up large shifts
nodconst(&n3, types[TUINT32], nl->type->width*8);
gins(optoas(OCMP, types[TUINT32]), &n1, &n3);
void
regalloc(Node *n, Type *t, Node *o)
{
- int i;
+ int i, et;
if(t == T)
fatal("regalloc: t nil");
-
- switch(t->etype) {
+ et = simtype[t->etype];
+
+ switch(et) {
case TINT8:
case TUINT8:
case TINT16:
Node nod, nod1, nod2, nod3, nodc;
Prog *p1, *p2;
- ft = f->type->etype;
- tt = t->type->etype;
+ ft = simtype[f->type->etype];
+ tt = simtype[t->type->etype];
t64 = 0;
if(tt == TINT64 || tt == TUINT64 || tt == TPTR64)
fatal("optoas: t is nil");
a = AGOK;
- switch(CASE(op, t->etype)) {
+ switch(CASE(op, simtype[t->etype])) {
default:
fatal("optoas: no entry %O-%T", op, t);
break;
case CTINT:
case CTSINT:
case CTUINT:
- n->type = types[TINT32];
+ n->type = types[TINT];
break;
case CTFLT:
- n->type = types[TFLOAT64];
+ n->type = types[TFLOAT];
break;
case CTBOOL:
n->type = types[TBOOL];
TINT16, TUINT16,
TINT32, TUINT32,
TINT64, TUINT64,
+ TINT, TUINT, TUINTPTR,
- TFLOAT32, // 9
+ TFLOAT32, // 12
TFLOAT64,
TFLOAT80,
+ TFLOAT,
- TBOOL, // 12
+ TBOOL, // 16
- TPTR32, TPTR64, // 13
+ TPTR32, TPTR64, // 17
+ TDDD, // 19
TFUNC,
TARRAY,
T_old_DARRAY,
TFORWSTRUCT,
TFORWINTER,
- NTYPE, // 28
+ NTYPE,
};
enum
{
Biobuf* bin;
int32 ilineno;
int peekc;
+ int peekc1; // second peekc for ...
char* cp; // used for content when bin==nil
};
EXTERN int exportadj; // declaration is being exported
EXTERN Type* types[NTYPE];
+EXTERN uchar simtype[NTYPE];
EXTERN uchar isptr[NTYPE];
EXTERN uchar isint[NTYPE];
EXTERN uchar isfloat[NTYPE];
%token <sym> LNAME LBASETYPE LATYPE LPACK LACONST
%token <sym> LPACKAGE LIMPORT LEXPORT
%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> LVAR LTYPE LCONST LCONVERT LSELECT
%token <sym> LFOR LIF LELSE LSWITCH LCASE LDEFAULT
%type <type> nametype structtype interfacetype convtype
%type <type> non_name_type Anon_fn_type Bnon_fn_type
%type <type> Anon_chan_type Bnon_chan_type
-%type <type> indcl fnlitdcl
+%type <type> indcl fnlitdcl dotdotdot
%type <val> hidden_constant
%type <node> hidden_dcl hidden_structdcl
chantype
| fntype
| othertype
+| dotdotdot
+
+dotdotdot:
+ LDDD
+ {
+ $$ = typ(TDDD);
+ }
Anon_chan_type:
Afntype
{
$$ = nametodcl($1, $2);
}
+| new_name_list_r dotdotdot
+ {
+ $$ = nametodcl($1, $2);
+ }
| non_name_type
{
$$ = anondcl($1);
if(curio.bin == nil)
fatal("cant open: %s", infile);
curio.peekc = 0;
+ curio.peekc1 = 0;
externdcl = mal(sizeof(*externdcl));
externdcl->back = externdcl;
pushedio = curio;
curio.bin = imp;
curio.peekc = 0;
+ curio.peekc1 = 0;
curio.infile = file;
for(;;) {
c = getc();
pushedio = curio;
curio.bin = nil;
curio.peekc = 0;
+ curio.peekc1 = 0;
curio.infile = file;
curio.cp = sysimport;
int32
yylex(void)
{
- int c, c1;
+ int c, c1, clen;
vlong v;
char *cp;
Rune rune;
c1 = 0;
goto casedot;
}
+ if(c1 == '.') {
+ c1 = getc();
+ if(c1 == '.') {
+ c = LDDD;
+ goto lx;
+ }
+ ungetc(c1);
+ c1 = '.';
+ }
break;
case '"':
/* "..." */
strcpy(namebuf, "\"<string>\"");
cp = mal(sizeof(int32));
- c1 = sizeof(int32);
+ clen = sizeof(int32);
caseq:
for(;;) {
if(escchar('"', &escflag, &v))
break;
if(v < Runeself || escflag) {
- cp = remal(cp, c1, 1);
- cp[c1++] = v;
+ cp = remal(cp, clen, 1);
+ cp[clen++] = v;
} else {
// botch - this limits size of runes
rune = v;
c = runelen(rune);
- cp = remal(cp, c1, c);
- runetochar(cp+c1, &rune);
- c1 += c;
+ cp = remal(cp, clen, c);
+ runetochar(cp+clen, &rune);
+ clen += c;
}
}
goto catem;
/* `...` */
strcpy(namebuf, "`<string>`");
cp = mal(sizeof(int32));
- c1 = sizeof(int32);
+ clen = sizeof(int32);
casebq:
for(;;) {
c = getc();
if(c == EOF || c == '`')
break;
- cp = remal(cp, c1, 1);
- cp[c1++] = c;
+ cp = remal(cp, clen, 1);
+ cp[clen++] = c;
}
+ goto catem;
catem:
- for(;;) {
- /* it takes 2 peekc's to skip comments */
- c = getc();
- if(isspace(c))
- continue;
- if(c == '"')
- goto caseq;
- if(c == '`')
- goto casebq;
- ungetc(c);
- break;
+ c = getc();
+ if(isspace(c))
+ goto catem;
+
+ // skip comments
+ if(c == '/') {
+ c1 = getc();
+ if(c1 == '*') {
+ for(;;) {
+ c = getr();
+ 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 {
- cp = remal(cp, c1, 1);
- cp[c1++] = 0;
- } while(c1 & MAXALIGN);
+ cp = remal(cp, clen, 1);
+ cp[clen++] = 0;
+ } while(clen & MAXALIGN);
yylval.val.u.sval = (String*)cp;
yylval.val.ctype = CTSTR;
DBG("lex: string literal\n");
c = curio.peekc;
if(c != 0) {
- curio.peekc = 0;
+ curio.peekc = curio.peekc1;
+ curio.peekc1 = 0;
if(c == '\n')
lineno++;
return c;
void
ungetc(int c)
{
+ curio.peekc1 = curio.peekc;
curio.peekc = c;
if(c == '\n')
lineno--;
"bool", LBASETYPE, TBOOL,
"byte", LBASETYPE, TUINT8,
- "char", LBASETYPE, TUINT8, // temp??
"string", LBASETYPE, TSTRING,
"any", LBASETYPE, TANY,
Type *t;
Sym *s;
+ for(i=0; i<NTYPE; i++)
+ simtype[i] = i;
+
besetptr();
for(i=TINT8; i<=TUINT64; i++)
isint[i] = 1;
+ isint[TINT] = 1;
+ isint[TUINT] = 1;
+ isint[TUINTPTR] = 1;
+
for(i=TFLOAT32; i<=TFLOAT80; i++)
isfloat[i] = 1;
+ isfloat[TFLOAT] = 1;
+
isptr[TPTR32] = 1;
isptr[TPTR64] = 1;
+ issigned[TINT] = 1;
issigned[TINT8] = 1;
issigned[TINT16] = 1;
issigned[TINT32] = 1;
mpatoflt(maxfltval[TFLOAT64], "1.7976931348623157e+308");
mpatoflt(minfltval[TFLOAT64], "-1.7976931348623157e+308");
-
/*
* initialize basic types array
* initialize known symbols
#include "go.h"
-/// uses arihmetic
+/// uses arithmetic
int
mpcmpfixflt(Mpint *a, Mpflt *b)
c->val.u.xval = mal(sizeof(*c->val.u.xval));
mpmovecfix(c->val.u.xval, v);
c->val.ctype = CTINT;
- c->type = types[TINT32];
+ c->type = types[TINT];
ullmancalc(c);
return c;
}
return Wtnil;
switch(t->etype) {
+ case TINT:
case TINT8:
case TINT16:
case TINT32:
case TINT64:
+ case TUINT:
case TUINT8:
case TUINT16:
case TUINT32:
case TUINT64:
+ case TUINTPTR:
return Wtint;
+ case TFLOAT:
case TFLOAT32:
case TFLOAT64:
case TFLOAT80:
static char*
etnames[] =
{
+ [TINT] = "INT",
+ [TUINT] = "UINT",
[TINT8] = "INT8",
[TUINT8] = "UINT8",
[TINT16] = "INT16",
[TUINT32] = "UINT32",
[TINT64] = "INT64",
[TUINT64] = "UINT64",
+ [TUINTPTR] = "UINTPTR",
+ [TFLOAT] = "FLOAT",
[TFLOAT32] = "FLOAT32",
[TFLOAT64] = "FLOAT64",
[TFLOAT80] = "FLOAT80",
return fmtstrcpy(fp, buf);
}
-static char *basicnames[] = {
-[TINT8] "int8",
-[TUINT8] "uint8",
-[TINT16] "int16",
-[TUINT16] "uint16",
-[TINT32] "int32",
-[TUINT32] "uint32",
-[TINT64] "int64",
-[TUINT64] "uint64",
-[TFLOAT32] "float32",
-[TFLOAT64] "float64",
-[TFLOAT80] "float80",
-[TBOOL] "bool",
-[TANY] "any",
+static char*
+basicnames[] =
+{
+ [TINT] = "int",
+ [TUINT] = "uint",
+ [TINT8] = "int8",
+ [TUINT8] = "uint8",
+ [TINT16] = "int16",
+ [TUINT16] = "uint16",
+ [TINT32] = "int32",
+ [TUINT32] = "uint32",
+ [TINT64] = "int64",
+ [TUINT64] = "uint64",
+ [TUINTPTR] = "uintptr",
+ [TFLOAT] = "float",
+ [TFLOAT32] = "float32",
+ [TFLOAT64] = "float64",
+ [TFLOAT80] = "float80",
+ [TBOOL] = "bool",
+ [TANY] = "any",
};
int
}
return S;
+ case TINT:
case TINT8:
case TINT16:
case TINT32:
case TINT64:
+ case TUINT:
case TUINT8:
case TUINT16:
case TUINT32:
case TUINT64:
+ case TUINTPTR:
+ case TFLOAT:
case TFLOAT32:
case TFLOAT64:
case TFLOAT80:
package SYS // rename to avoid redeclaration
-export func mal(uint32) *any;
+export func mal(int32) *any;
export func breakpoint();
export func throwindex();
export func throwreturn();
export func panicl(int32);
export func printbool(bool);
-export func printfloat(double);
+export func printfloat(float64);
export func printint(int64);
export func printstring(string);
export func printpointer(*any);
export func printsp();
export func catstring(string, string) string;
-export func cmpstring(string, string) int32;
-export func slicestring(string, int32, int32) string;
-export func indexstring(string, int32) byte;
+export func cmpstring(string, string) int;
+export func slicestring(string, int, int) string;
+export func indexstring(string, int) byte;
export func intstring(int64) string;
-export func byteastring(*byte, int32) string;
+export func byteastring(*byte, int) string;
export func arraystring(*[]byte) string;
export func ifaceT2I(sigi *byte, sigt *byte, elem any) (ret any);
export func ifaceeq(i1 any, i2 any) (ret bool);
export func reflect(i interface { }) (uint64, string);
-export func argc() int32;
-export func envc() int32;
-export func argv(int32) string;
-export func envv(int32) string;
+export func argc() int;
+export func envc() int;
+export func argv(int) string;
+export func envv(int) string;
-export func frexp(float64) (float64, int32); // break fp into exp,fract
-export func ldexp(float64, int32) float64; // make fp from exp,fract
+export func frexp(float64) (float64, int); // break fp into 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 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 Inf(int32) float64; // return signed Inf
+export func Inf(int) float64; // return signed Inf
export func NaN() float64; // return a NaN
-export func newmap(keysize uint32, valsize uint32,
- keyalg uint32, valalg uint32,
- hint uint32) (hmap *map[any]any);
+export func newmap(keysize int, valsize int,
+ keyalg int, valalg int,
+ hint int) (hmap *map[any]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 mapassign1(hmap *map[any]any, key any, val any);
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 chanrecv2(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 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 selectrecv(sel *byte, hchan *chan any, elem *any) (selected bool);
export func selectgo(sel *byte);
-export func newarray(nel uint32, cap uint32, width uint32) (ary *[]any);
-export func arraysliced(old *[]any, lb uint32, hb uint32, width uint32) (ary *[]any);
-export func arrayslices(old *any, nel uint32, lb uint32, hb uint32, width uint32) (ary *[]any);
-export func arrays2d(old *any, nel uint32) (ary *[]any);
+export func newarray(nel int, cap int, width int) (ary *[]any);
+export func arraysliced(old *[]any, lb int, hb int, width int) (ary *[]any);
+export func arrayslices(old *any, nel int, lb int, hb int, width int) (ary *[]any);
+export func arrays2d(old *any, nel int) (ary *[]any);
export func gosched();
export func goexit();
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 bytestorune(*byte, int32, int32) (int32, int32); // convert bytes to runes
-export func stringtorune(string, int32) (int32, int32); // convert bytes to runes
+export func bytestorune(*byte, int, int) (int, int); // 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 =
"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.throwindex ()\n"
"export func sys.throwreturn ()\n"
"export func sys.printnl ()\n"
"export func sys.printsp ()\n"
"export func sys.catstring (? string, ? string) (? string)\n"
- "export func sys.cmpstring (? string, ? string) (? int32)\n"
- "export func sys.slicestring (? string, ? int32, ? int32) (? string)\n"
- "export func sys.indexstring (? string, ? int32) (? uint8)\n"
+ "export func sys.cmpstring (? string, ? string) (? int)\n"
+ "export func sys.slicestring (? string, ? int, ? int) (? string)\n"
+ "export func sys.indexstring (? string, ? int) (? uint8)\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.ifaceT2I (sigi *uint8, sigt *uint8, elem 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.ifaceeq (i1 any, i2 any) (ret bool)\n"
"export func sys.reflect (i interface { }) (? uint64, ? string)\n"
- "export func sys.argc () (? int32)\n"
- "export func sys.envc () (? int32)\n"
- "export func sys.argv (? int32) (? string)\n"
- "export func sys.envv (? int32) (? string)\n"
- "export func sys.frexp (? float64) (? float64, ? int32)\n"
- "export func sys.ldexp (? float64, ? int32) (? float64)\n"
+ "export func sys.argc () (? int)\n"
+ "export func sys.envc () (? int)\n"
+ "export func sys.argv (? int) (? string)\n"
+ "export func sys.envv (? int) (? string)\n"
+ "export func sys.frexp (? float64) (? float64, ? int)\n"
+ "export func sys.ldexp (? float64, ? int) (? 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.Inf (? int32) (? float64)\n"
+ "export func sys.Inf (? int) (? 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.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.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.chanrecv2 (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.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.selectrecv (sel *uint8, hchan *chan any, elem *any) (selected bool)\n"
"export func sys.selectgo (sel *uint8)\n"
- "export func sys.newarray (nel uint32, cap uint32, width uint32) (ary *[]any)\n"
- "export func sys.arraysliced (old *[]any, lb uint32, hb uint32, width uint32) (ary *[]any)\n"
- "export func sys.arrayslices (old *any, nel uint32, lb uint32, hb uint32, width uint32) (ary *[]any)\n"
- "export func sys.arrays2d (old *any, nel uint32) (ary *[]any)\n"
+ "export func sys.newarray (nel int, cap int, width int) (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 int, lb int, hb int, width int) (ary *[]any)\n"
+ "export func sys.arrays2d (old *any, nel int) (ary *[]any)\n"
"export func sys.gosched ()\n"
"export func sys.goexit ()\n"
"export func sys.readfile (? 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.stringtorune (? string, ? int32) (? int32, ? int32)\n"
- "export func sys.exit (? int32)\n"
+ "export func sys.bytestorune (? *uint8, ? int, ? int) (? int, ? int)\n"
+ "export func sys.stringtorune (? string, ? int) (? int, ? int)\n"
+ "export func sys.exit (? int)\n"
"\n"
"$$\n";
case 0:
if(top == Erv) {
yyerror("function requires a return type");
- n->type = types[TINT32];
+ n->type = types[TINT];
}
break;
evconst(n);
if(n->op == OLITERAL)
goto ret;
- convlit(n->right, types[TUINT32]);
- convlit(n->left, types[TINT32]);
+ convlit(n->right, types[TUINT]);
+ convlit(n->left, types[TINT]);
if(n->left->type == T || n->right->type == T)
goto ret;
if(issigned[n->right->type->etype])
break;
case TARRAY:
if(t->bound >= 0)
- nodconst(n, types[TINT32], t->bound);
+ nodconst(n, types[TINT], t->bound);
break;
}
- n->type = types[TINT32];
+ n->type = types[TINT];
goto ret;
case OCAP:
goto badt;
case TARRAY:
if(t->bound >= 0)
- nodconst(n, types[TINT32], t->bound);
+ nodconst(n, types[TINT], t->bound);
break;
}
- n->type = types[TINT32];
+ n->type = types[TINT];
goto ret;
case OINDEX:
if(top != Erv)
goto nottop;
if(n->right->type == T) {
- convlit(n->right, types[TINT32]);
+ convlit(n->right, types[TINT]);
if(n->right->type == T)
goto ret;
}
case TARRAY:
// right side must be an int
if(n->right->type == T) {
- convlit(n->right, types[TINT32]);
+ convlit(n->right, types[TINT]);
if(n->right->type == T)
break;
}
Type*
sw2(Node *c, Type *place)
{
- return types[TINT32]; // botch
+ return types[TINT]; // botch
}
/*
on = syslook("newselect", 0);
r = nod(OXXX, N, N);
- nodconst(r, types[TINT32], count); // count
+ nodconst(r, types[TINT], count); // count
r = nod(OCALL, on, r);
r = nod(OAS, var, r);
case OSLICE:
// sys_slicestring(s, lb, hb)
r = nod(OCONV, n->right->left, N);
- r->type = types[TINT32];
+ r->type = types[TINT];
c = nod(OCONV, n->right->right, N);
- c->type = types[TINT32];
+ c->type = types[TINT];
r = list(r, c);
r = list(n->left, r);
c->type = c->left->type->type;
}
r = nod(OCONV, n->right, N);
- r->type = types[TINT32];
+ r->type = types[TINT];
r = list(c, r);
on = syslook("indexstring", 0);
r = nod(OCALL, on, r);
if(top != Erv)
goto nottop;
- // newmap(keysize uint32, valsize uint32,
- // keyalg uint32, valalg uint32,
- // hint uint32) (hmap *map[any-1]any-2);
+ // newmap(keysize int, valsize int,
+ // keyalg int, valalg int,
+ // hint int) (hmap *map[any-1]any-2);
t = fixmap(n->type);
if(t == T)
fatal("chanop: unknown op %O", n->op);
case ONEW:
- // newchan(elemsize uint32, elemalg uint32,
- // hint uint32) (hmap *chan[any-1]);
+ // newchan(elemsize int, elemalg int,
+ // hint int) (hmap *chan[any-1]);
t = fixchan(n->type);
if(t == T)
fatal("darrayop: unknown op %O", n->op);
case ONEW:
- // newarray(nel uint32, max uint32, width uint32) (ary *[]any)
+ // newarray(nel int, max int, width int) (ary *[]any)
t = fixarray(n->type);
a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N);
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = a;
a = listfirst(&save, &n->left); // max
if(a == N)
a = nodintconst(0);
a = nod(OCONV, a, N);
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = list(a, r);
a = listfirst(&save, &n->left); // nel
a = nodintconst(t->bound);
}
a = nod(OCONV, a, N);
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = list(a, r);
on = syslook("newarray", 1);
break;
case OAS:
- // arrays2d(old *any, nel uint32) (ary *[]any)
+ // arrays2d(old *any, nel int) (ary *[]any)
t = fixarray(n->right->type);
a = nodintconst(t->bound); // nel
a = nod(OCONV, a, N);
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = a;
a = n->right; // old
if(isptrarray(n->left->type))
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);
a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N);
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = a;
a = nod(OCONV, n->right->right, N); // hb
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = list(a, r);
a = nod(OCONV, n->right->left, N); // lb
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = list(a, r);
a = n->left; // old
break;
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);
a = nodintconst(t->type->width); // width
a = nod(OCONV, a, N);
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = a;
a = nod(OCONV, n->right->right, N); // hb
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = list(a, r);
a = nod(OCONV, n->right->left, N); // lb
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = list(a, r);
a = nodintconst(t->bound); // nel
a = nod(OCONV, a, N);
- a->type = types[TUINT32];
+ a->type = types[TINT];
r = list(a, r);
a = n->left; // old
export func atoi(s string) (i int, ok bool) {
ii, okok := atol(s);
- i = int32(ii);
+ i = int(ii);
return i, okok
}
}
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);
if r1 < 0 {
return r1, err;
}
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);
return e
}
var tv Timeval;
nsec += 999;
tv.sec = int64(nsec/1000000000);
- tv.usec = uint32(nsec%1000000000);
+ tv.usec = uint(nsec%1000000000);
r1, e := setsockopt(fd, level, opt, TimevalPtr(&tv), 4);
return e
}
}
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);
return e
}