Commit 60d223a4 authored by Kai Backman's avatar Kai Backman

added missing pieces required by reflection

R=rsc
APPROVED=rsc
DELTA=61  (40 added, 18 deleted, 3 changed)
OCL=31502
CL=31580
parent 0e2cce70
...@@ -484,46 +484,67 @@ dstringptr(Sym *s, int off, char *str) ...@@ -484,46 +484,67 @@ dstringptr(Sym *s, int off, char *str)
} }
int int
duintxx(Sym *s, int off, uint64 v, int wid) dgostrlitptr(Sym *s, int off, Strlit *lit)
{ {
Prog *p; Prog *p;
off = rnd(off, wid); if(lit == nil)
return duintptr(s, off, 0);
off = rnd(off, widthptr);
p = gins(ADATA, N, N); p = gins(ADATA, N, N);
p->from.type = D_OREG; p->from.type = D_OREG;
p->from.name = D_EXTERN; p->from.name = D_EXTERN;
p->from.sym = s; p->from.sym = s;
p->from.offset = off; p->from.offset = off;
p->reg = wid; p->from.reg = widthptr;
datagostring(lit, &p->to);
p->to.type = D_CONST; p->to.type = D_CONST;
p->to.name = D_NONE; p->to.etype = TINT32;
p->to.offset = v; off += widthptr;
off += wid;
return off; return off;
} }
int int
duint32(Sym *s, int off, uint32 v) dgostringptr(Sym *s, int off, char *str)
{ {
return duintxx(s, off, v, 4); int n;
} Strlit *lit;
int if(str == nil)
duint16(Sym *s, int off, uint32 v) return duintptr(s, off, 0);
{
return duintxx(s, off, v, 2); n = strlen(str);
lit = mal(sizeof *lit + n);
strcpy(lit->s, str);
lit->len = n;
return dgostrlitptr(s, off, lit);
} }
int int
duintptr(Sym *s, int off, uint32 v) duintxx(Sym *s, int off, uint64 v, int wid)
{ {
return duintxx(s, off, v, 8); Prog *p;
off = rnd(off, wid);
p = gins(ADATA, N, N);
p->from.type = D_OREG;
p->from.name = D_EXTERN;
p->from.sym = s;
p->from.offset = off;
p->reg = wid;
p->to.type = D_CONST;
p->to.name = D_NONE;
p->to.offset = v;
off += wid;
return off;
} }
int int
dsymptr(Sym *s, int off, Sym *x) dsymptr(Sym *s, int off, Sym *x, int xoff)
{ {
Prog *p; Prog *p;
...@@ -538,7 +559,7 @@ dsymptr(Sym *s, int off, Sym *x) ...@@ -538,7 +559,7 @@ dsymptr(Sym *s, int off, Sym *x)
p->to.type = D_CONST; p->to.type = D_CONST;
p->to.name = D_EXTERN; p->to.name = D_EXTERN;
p->to.sym = x; p->to.sym = x;
p->to.offset = 0; p->to.offset = xoff;
off += widthptr; off += widthptr;
return off; return off;
...@@ -546,9 +567,10 @@ dsymptr(Sym *s, int off, Sym *x) ...@@ -546,9 +567,10 @@ dsymptr(Sym *s, int off, Sym *x)
void void
genembedtramp(Type *t, Sig *b) genembedtramp(Type *rcvr, Type *method, Sym *newnam)
{ {
fatal("genembedtramp not implemented"); fatal("genembedtramp not implemented");
// TODO(kaib): re-lift from 8g
// Sym *e; // Sym *e;
// int c, d, o, loaded; // int c, d, o, loaded;
// Prog *p; // Prog *p;
......
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