Commit 8231e945 authored by Ken Thompson's avatar Ken Thompson

now method/interface code

R=r
OCL=15627
CL=15627
parent 128f0528
...@@ -154,10 +154,6 @@ cgen(Node *n, Node *res) ...@@ -154,10 +154,6 @@ cgen(Node *n, Node *res)
regfree(&n1); regfree(&n1);
break; break;
case OS2I:
case OI2I:
case OI2S:
case OINDEXPTR: case OINDEXPTR:
case OINDEX: case OINDEX:
case ODOT: case ODOT:
...@@ -345,12 +341,6 @@ agen(Node *n, Node *res) ...@@ -345,12 +341,6 @@ agen(Node *n, Node *res)
cgen_aret(n, res); cgen_aret(n, res);
break; break;
case OS2I:
case OI2I:
case OI2S:
agen_inter(n, res);
break;
case OINDEXPTR: case OINDEXPTR:
w = n->type->width; w = n->type->width;
if(nr->addable) if(nr->addable)
...@@ -678,10 +668,10 @@ int32 ...@@ -678,10 +668,10 @@ int32
stkof(Node *n) stkof(Node *n)
{ {
switch(n->op) { switch(n->op) {
case OS2I: // case OS2I:
return 2*widthptr; // return 2*widthptr;
case OI2I: // case OI2I:
return 1*widthptr; // return 1*widthptr;
case OINDREG: case OINDREG:
return n->xoffset; return n->xoffset;
} }
......
...@@ -373,7 +373,7 @@ agen_inter(Node *n, Node *res) ...@@ -373,7 +373,7 @@ agen_inter(Node *n, Node *res)
default: default:
fatal("agen_inter %O\n", n->op); fatal("agen_inter %O\n", n->op);
case OS2I: // case OS2I:
// ifaces2i(*sigi, *sigs, i.map, i.s) // ifaces2i(*sigi, *sigs, i.map, i.s)
// i.s is input // i.s is input
// (i.map, i.s) is output // (i.map, i.s) is output
...@@ -398,7 +398,7 @@ agen_inter(Node *n, Node *res) ...@@ -398,7 +398,7 @@ agen_inter(Node *n, Node *res)
o = 2*widthptr; o = 2*widthptr;
break; break;
case OI2I: // case OI2I:
// ifacei2i(*sigi, i.map, i.s) // ifacei2i(*sigi, i.map, i.s)
// (i.map, i.s) is input // (i.map, i.s) is input
// (i.map, i.s) is output // (i.map, i.s) is output
...@@ -424,7 +424,7 @@ agen_inter(Node *n, Node *res) ...@@ -424,7 +424,7 @@ agen_inter(Node *n, Node *res)
o = 1*widthptr; o = 1*widthptr;
break; break;
case OI2S: // case OI2S:
// ifacei2s(*sigs, i.map, i.s) // ifacei2s(*sigs, i.map, i.s)
// (i.map, i.s) is input // (i.map, i.s) is input
// i.s is output // i.s is output
......
...@@ -294,45 +294,6 @@ nodconst(Node *n, Type *t, vlong v) ...@@ -294,45 +294,6 @@ nodconst(Node *n, Type *t, vlong v)
} }
} }
Sym*
signame(Type *t)
{
Sym *s;
char *e;
loop:
if(t == T)
fatal("signame: nil type");
switch(t->etype) {
default:
e = "sigs";
break;
case TPTR32:
case TPTR64:
t = t->type;
goto loop;
case TSTRUCT:
case TINTER:
e = "sigi";
break;
}
s = t->sym;
if(s == S)
fatal("signame: no sym for type");
// mark it as used so signature will be generated
if(s->local == 1)
s->local = 2;
snprint(namebuf, sizeof(namebuf), "%s_%s", e, s->name);
s = pkglookup(namebuf, s->opackage);
return s;
}
void void
nodtypesig(Node *n, Type *t) nodtypesig(Node *n, Type *t)
{ {
...@@ -1055,8 +1016,10 @@ naddr(Node *n, Addr *a) ...@@ -1055,8 +1016,10 @@ naddr(Node *n, Addr *a)
a->etype = n->etype; a->etype = n->etype;
a->offset = n->xoffset; a->offset = n->xoffset;
a->sym = n->sym; a->sym = n->sym;
if(a->sym == S) if(a->sym == S) {
a->sym = lookup(".noname"); a->sym = lookup(".noname");
fatal("noname");
}
if(n->method) { if(n->method) {
if(n->type != T) if(n->type != T)
if(n->type->sym != S) if(n->type->sym != S)
......
...@@ -161,8 +161,6 @@ dumpobj(void) ...@@ -161,8 +161,6 @@ dumpobj(void)
} }
} }
Bterm(bout); Bterm(bout);
return;
Bterm(bout);
} }
Bputdot(Biobuf *b) Bputdot(Biobuf *b)
...@@ -477,31 +475,14 @@ dumpsignatures(void) ...@@ -477,31 +475,14 @@ dumpsignatures(void)
if(t == T) if(t == T)
continue; continue;
et = t->etype; s = signame(t);
if(t->method == T && et != TINTER)
continue;
s = d->dsym;
if(s == S) if(s == S)
continue; continue;
if(s->name[0] == '_')
continue;
// if it was imported
if(s->local == 0)
continue;
// until i can figure out
// when/if it is used, do them all
// // if not used and not exported
// if(s->local == 1 && !s->export)
// continue;
x = mal(sizeof(*d)); x = mal(sizeof(*d));
x->op = OTYPE; x->op = OTYPE;
x->dsym = s; x->dsym = d->dsym;
x->dtype = t; x->dtype = d->dtype;
x->forw = signatlist; x->forw = signatlist;
signatlist = x; signatlist = x;
} }
...@@ -548,9 +529,15 @@ dumpsignatures(void) ...@@ -548,9 +529,15 @@ dumpsignatures(void)
continue; continue;
t = d->dtype; t = d->dtype;
et = t->etype; at.sym = signame(t);
if(t->method == T && et != TINTER) if(at.sym == S)
continue; continue;
if(!at.sym->local)
continue;
//print("SIGNAME = %lS\n", at.sym);
et = t->etype;
s = d->dsym; s = d->dsym;
if(s == S) if(s == S)
...@@ -562,14 +549,13 @@ dumpsignatures(void) ...@@ -562,14 +549,13 @@ dumpsignatures(void)
if(strcmp(s->opackage, package) != 0) if(strcmp(s->opackage, package) != 0)
continue; continue;
at.sym = signame(t);
a = nil; a = nil;
o = 0; o = 0;
f = t->type;
if(et != TINTER)
f = t->method; f = t->method;
if(et == TINTER)
f = t->type;
for(; f!=T; f=f->down) { for(; f!=T; f=f->down) {
if(f->type->etype != TFUNC) if(f->type->etype != TFUNC)
......
...@@ -260,7 +260,7 @@ enum ...@@ -260,7 +260,7 @@ enum
ODCLFUNC, ODCLFIELD, ODCLARG, ODCLFUNC, ODCLFIELD, ODCLARG,
OLIST, OCMP, OLIST, OCMP,
OPTR, OARRAY, OPTR, OARRAY,
ORETURN, OFOR, OIF, OSWITCH, OI2S, OS2I, OI2I, ORETURN, OFOR, OIF, OSWITCH,
OAS, OASOP, OCASE, OXCASE, OFALL, OXFALL, OAS, OASOP, OCASE, OXCASE, OFALL, OXFALL,
OGOTO, OPROC, ONEW, OEMPTY, OSELECT, OGOTO, OPROC, ONEW, OEMPTY, OSELECT,
OLEN, OCAP, OPANIC, OPRINT, OTYPEOF, OLEN, OCAP, OPANIC, OPRINT, OTYPEOF,
...@@ -564,6 +564,7 @@ int isptrarray(Type*); ...@@ -564,6 +564,7 @@ int isptrarray(Type*);
int isptrdarray(Type*); int isptrdarray(Type*);
int isinter(Type*); int isinter(Type*);
int ismethod(Type*); int ismethod(Type*);
Sym* signame(Type*);
int bytearraysz(Type*); int bytearraysz(Type*);
int eqtype(Type*, Type*, int); int eqtype(Type*, Type*, int);
void argtype(Node*, Type*); void argtype(Node*, Type*);
...@@ -692,7 +693,8 @@ Node* mapop(Node*, int); ...@@ -692,7 +693,8 @@ Node* mapop(Node*, int);
Type* fixchan(Type*); Type* fixchan(Type*);
Node* chanop(Node*, int); Node* chanop(Node*, int);
Node* arrayop(Node*, int); Node* arrayop(Node*, int);
Node* isandss(Type*, Node*); Node* ifaceop(Type*, Node*, int);
int isandss(Type*, Node*);
Node* convas(Node*); Node* convas(Node*);
void arrayconv(Type*, Node*); void arrayconv(Type*, Node*);
Node* colas(Node*, Node*); Node* colas(Node*, Node*);
......
...@@ -644,9 +644,6 @@ opnames[] = ...@@ -644,9 +644,6 @@ opnames[] =
[OPTR] = "PTR", [OPTR] = "PTR",
[ORETURN] = "RETURN", [ORETURN] = "RETURN",
[ORSH] = "RSH", [ORSH] = "RSH",
[OI2S] = "I2S",
[OS2I] = "S2I",
[OI2I] = "I2I",
[OSLICE] = "SLICE", [OSLICE] = "SLICE",
[OSUB] = "SUB", [OSUB] = "SUB",
[OSELECT] = "SELECT", [OSELECT] = "SELECT",
...@@ -1238,6 +1235,58 @@ ismethod(Type *t) ...@@ -1238,6 +1235,58 @@ ismethod(Type *t)
return 0; return 0;
} }
Sym*
signame(Type *t)
{
Sym *s, *ss;
char *e;
loop:
if(t == T) {
print("signame: nil type\n");
goto bad;
}
switch(t->etype) {
default:
e = "sigs";
break;
case TPTR32:
case TPTR64:
t = t->type;
goto loop;
case TINTER:
e = "sigi";
break;
}
s = t->sym;
if(s == S) {
print("signame: no type name\n");
goto bad;
}
if(s->name[0] == '_') {
// print("signame: temp type name %S\n", s);
goto bad;
}
snprint(namebuf, sizeof(namebuf), "%s_%s", e, s->name);
ss = pkglookup(namebuf, s->opackage);
if(ss->oname == N) {
ss->oname = newname(ss);
ss->oname->type = types[TUINT8];
ss->oname->class = PEXTERN;
ss->local = s->local;
//print("signame: %d %lS\n", ss->local, ss);
}
return ss;
bad:
return S;
}
int int
bytearraysz(Type *t) bytearraysz(Type *t)
{ {
...@@ -1620,9 +1669,6 @@ ullmancalc(Node *n) ...@@ -1620,9 +1669,6 @@ ullmancalc(Node *n)
case ONAME: case ONAME:
ul = 0; ul = 0;
goto out; goto out;
case OS2I:
case OI2S:
case OI2I:
case OCALL: case OCALL:
case OCALLMETH: case OCALLMETH:
case OCALLINTER: case OCALLINTER:
......
...@@ -23,7 +23,10 @@ func slicestring(string, int32, int32) string; ...@@ -23,7 +23,10 @@ func slicestring(string, int32, int32) string;
func indexstring(string, int32) byte; func indexstring(string, int32) byte;
func intstring(int64) string; func intstring(int64) string;
func byteastring(*byte, int32) string; func byteastring(*byte, int32) string;
func mkiface(*byte, *byte, *struct{}) interface{};
func ifaceT2I(sigi *byte, sigt *byte, elem any) (ret interface{});
func ifaceI2T(sigt *byte, iface interface{}) (ret any);
func ifaceI2I(sigi *byte, iface any) (ret any);
func argc() int32; func argc() int32;
func envc() int32; func envc() int32;
...@@ -95,7 +98,11 @@ export ...@@ -95,7 +98,11 @@ export
indexstring indexstring
intstring intstring
byteastring byteastring
mkiface
// interface
ifaceT2I
ifaceI2T
ifaceI2I
// args // args
argc argc
......
This diff is collapsed.
...@@ -10,6 +10,14 @@ static Type* sw3(Node*, Type*); ...@@ -10,6 +10,14 @@ static Type* sw3(Node*, Type*);
static Node* curfn; static Node* curfn;
static Node* addtop; static Node* addtop;
enum
{
Inone,
I2T,
I2I,
T2I
};
// can this code branch reach the end // can this code branch reach the end
// without an undcontitional RETURN // without an undcontitional RETURN
// this is hard, so it is conservative // this is hard, so it is conservative
...@@ -494,15 +502,6 @@ loop: ...@@ -494,15 +502,6 @@ loop:
case OINDREG: case OINDREG:
goto ret; goto ret;
case OS2I:
case OI2S:
case OI2I:
if(top != Erv)
goto nottop;
n->addable = 0;
walktype(n->left, Erv);
goto ret;
case OCONV: case OCONV:
if(top == Etop) if(top == Etop)
goto nottop; goto nottop;
...@@ -551,9 +550,9 @@ loop: ...@@ -551,9 +550,9 @@ loop:
goto ret; goto ret;
// interface and structure // interface and structure
r = isandss(n->type, l); et = isandss(n->type, l);
if(r != N) { if(et != Inone) {
indir(n, r); indir(n, ifaceop(n->type, l, et));
goto ret; goto ret;
} }
...@@ -2454,18 +2453,7 @@ arrayop(Node *n, int top) ...@@ -2454,18 +2453,7 @@ arrayop(Node *n, int top)
return r; return r;
} }
void int
diagnamed(Type *t)
{
if(isinter(t))
if(t->sym == S)
yyerror("interface type must be named");
if(ismethod(t))
if(t->type == T || t->type->sym == S)
yyerror("structure type must be named");
}
Node*
isandss(Type *lt, Node *r) isandss(Type *lt, Node *r)
{ {
Type *rt; Type *rt;
...@@ -2474,32 +2462,98 @@ isandss(Type *lt, Node *r) ...@@ -2474,32 +2462,98 @@ isandss(Type *lt, Node *r)
rt = r->type; rt = r->type;
if(isinter(lt)) { if(isinter(lt)) {
if(ismethod(rt)) { if(ismethod(rt))
o = OS2I; return T2I;
goto ret; if(isinter(rt) && !eqtype(rt, lt, 0))
} return I2I;
if(isinter(rt)) {
o = OI2I;
goto ret;
}
} }
if(ismethod(lt)) { if(ismethod(lt)) {
if(isinter(rt)) { if(isinter(rt))
o = OI2S; return I2T;
goto ret;
} }
return Inone;
}
Node*
ifaceop(Type *tl, Node *n, int op)
{
Type *tr;
Node *r, *a, *on;
Sym *s;
tr = n->type;
switch(op) {
default:
fatal("ifaceop: unknown op %d\n", op);
case I2T:
// ifaceI2T(sigt *byte, iface interface{}) (ret any);
a = n; // interface
r = a;
s = signame(tl); // sigi
if(s == S)
fatal("ifaceop: signame I2T");
a = s->oname;
a = nod(OADDR, a, N);
r = list(a, r);
on = syslook("ifaceI2T", 1);
argtype(on, tl);
break;
case T2I:
// ifaceT2I(sigi *byte, sigt *byte, elem any) (ret interface{});
a = n; // elem
r = a;
s = signame(tr); // sigt
if(s == S)
fatal("ifaceop: signame-1 T2I: %lT", tr);
a = s->oname;
a = nod(OADDR, a, N);
r = list(a, r);
s = signame(tl); // sigi
if(s == S) {
fatal("ifaceop: signame-2 T2I: %lT", tl);
} }
a = s->oname;
a = nod(OADDR, a, N);
r = list(a, r);
return N; on = syslook("ifaceT2I", 1);
argtype(on, tr);
ret: break;
diagnamed(lt);
diagnamed(rt);
n = nod(o, r, N); case I2I:
n->type = lt; // ifaceI2I(sigi *byte, iface any-1) (ret any-2);
return n;
a = n; // interface
r = a;
s = signame(tr); // sigi
if(s == S)
fatal("ifaceop: signame I2I");
a = s->oname;
a = nod(OADDR, a, N);
r = list(a, r);
on = syslook("ifaceI2I", 1);
argtype(on, n->type);
argtype(on, tr);
break;
}
r = nod(OCALL, on, r);
walktype(r, Erv);
return r;
} }
Node* Node*
...@@ -2507,6 +2561,7 @@ convas(Node *n) ...@@ -2507,6 +2561,7 @@ convas(Node *n)
{ {
Node *l, *r; Node *l, *r;
Type *lt, *rt; Type *lt, *rt;
int et;
if(n->op != OAS) if(n->op != OAS)
fatal("convas: not OAS %O", n->op); fatal("convas: not OAS %O", n->op);
...@@ -2542,10 +2597,9 @@ convas(Node *n) ...@@ -2542,10 +2597,9 @@ convas(Node *n)
if(eqtype(lt, rt, 0)) if(eqtype(lt, rt, 0))
goto out; goto out;
r = isandss(lt, r); et = isandss(lt, r);
if(r != N) { if(et != Inone) {
n->right = r; n->right = ifaceop(lt, r, et);
walktype(n, Etop);
goto out; goto out;
} }
...@@ -2994,11 +3048,15 @@ arraylit(Node *n) ...@@ -2994,11 +3048,15 @@ arraylit(Node *n)
fatal("arraylit: not array"); fatal("arraylit: not array");
if(t->bound < 0) { if(t->bound < 0) {
// make a shallow copy
t = typ(0);
*t = *n->type;
n->type = t;
// make it a closed array // make it a closed array
r = listfirst(&saver, &n->left); r = listfirst(&saver, &n->left);
for(idx=0; r!=N; idx++) for(idx=0; r!=N; idx++)
r = listnext(&saver); r = listnext(&saver);
t = deep(t);
t->bound = idx; t->bound = idx;
} }
......
...@@ -20,6 +20,7 @@ LIBOFILES=\ ...@@ -20,6 +20,7 @@ LIBOFILES=\
runtime.$O\ runtime.$O\
map.$O\ map.$O\
chan.$O\ chan.$O\
iface.$O\
array.$O\ array.$O\
print.$O\ print.$O\
rune.$O\ rune.$O\
......
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "runtime.h"
typedef struct Sigt Sigt;
typedef struct Sigi Sigi;
typedef struct Map Map;
struct Sigt
{
byte* name;
uint32 hash;
void (*fun)(void);
};
struct Sigi
{
byte* name;
uint32 hash;
uint32 offset;
};
struct Map
{
Sigi* sigi;
Sigt* sigt;
Map* link;
int32 bad;
int32 unused;
void (*fun[])(void);
};
static Map* hash[1009];
static int32 debug = 0;
static Map*
hashmap(Sigi *si, Sigt *ss)
{
int32 ns, ni;
uint32 ihash, h;
byte *sname, *iname;
Map *m;
h = ((uint32)(uint64)si + (uint32)(uint64)ss) % nelem(hash);
for(m=hash[h]; m!=nil; m=m->link) {
if(m->sigi == si && m->sigt == ss) {
if(m->bad) {
throw("bad hashmap");
m = nil;
}
// prints("old hashmap\n");
return m;
}
}
ni = si[0].offset; // first word has size
m = mal(sizeof(*m) + ni*sizeof(m->fun[0]));
m->sigi = si;
m->sigt = ss;
ni = 1; // skip first word
ns = 0;
loop1:
// pick up next name from
// interface signature
iname = si[ni].name;
if(iname == nil) {
m->link = hash[h];
hash[h] = m;
// prints("new hashmap\n");
return m;
}
ihash = si[ni].hash;
loop2:
// pick up and comapre next name
// from structure signature
sname = ss[ns].name;
if(sname == nil) {
prints((int8*)iname);
prints(": ");
throw("hashmap: failed to find method");
m->bad = 1;
m->link = hash[h];
hash[h] = m;
return nil;
}
if(ihash != ss[ns].hash ||
strcmp(sname, iname) != 0) {
ns++;
goto loop2;
}
m->fun[si[ni].offset] = ss[ns].fun;
ni++;
goto loop1;
}
static void
printsigi(Sigi *si)
{
sys·printpointer(si);
}
static void
printsigt(Sigt *st)
{
sys·printpointer(st);
}
static void
printiface(Map *im, void *it)
{
prints("(");
sys·printpointer(im);
prints(",");
sys·printpointer(it);
prints(")");
}
// ifaceT2I(sigi *byte, sigt *byte, elem any) (ret interface{});
void
sys·ifaceT2I(Sigi *si, Sigt *st, void *elem, Map *retim, void *retit)
{
if(debug) {
prints("T2I sigi=");
printsigi(si);
prints(" sigt=");
printsigt(st);
prints(" elem=");
sys·printpointer(elem);
prints("\n");
}
retim = hashmap(si, st);
retit = elem;
if(debug) {
prints("T2I ret=");
printiface(retim, retit);
prints("\n");
}
FLUSH(&retim);
}
// ifaceI2T(sigt *byte, iface interface{}) (ret any);
void
sys·ifaceI2T(Sigt *st, Map *im, void *it, void *ret)
{
if(debug) {
prints("I2T sigt=");
printsigt(st);
prints(" iface=");
printiface(im, it);
prints("\n");
}
if(im == nil)
throw("ifaceI2T: nil map");
if(im->sigt != st)
throw("ifaceI2T: wrong type");
ret = it;
if(debug) {
prints("I2T ret=");
sys·printpointer(ret);
prints("\n");
}
FLUSH(&ret);
}
// ifaceI2I(sigi *byte, iface interface{}) (ret interface{});
void
sys·ifaceI2I(Sigi *si, Map *im, void *it, Map *retim, void *retit)
{
if(debug) {
prints("I2I sigi=");
sys·printpointer(si);
prints(" iface=");
printiface(im, it);
prints("\n");
}
if(im == nil) {
throw("ifaceI2I: nil map");
return;
}
retit = it;
retim = im;
if(im->sigi != si)
retim = hashmap(si, im->sigt);
if(debug) {
prints("I2I ret=");
printiface(retim, retit);
prints("\n");
}
FLUSH(&retim);
}
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include "runtime.h" #include "runtime.h"
int32 debug = 0;
int32 panicking = 0; int32 panicking = 0;
void void
...@@ -146,175 +145,6 @@ sys·mal(uint32 n, uint8 *ret) ...@@ -146,175 +145,6 @@ sys·mal(uint32 n, uint8 *ret)
FLUSH(&ret); FLUSH(&ret);
} }
static Map* hash[1009];
static Map*
hashmap(Sigi *si, Sigs *ss)
{
int32 ns, ni;
uint32 ihash, h;
byte *sname, *iname;
Map *m;
h = ((uint32)(uint64)si + (uint32)(uint64)ss) % nelem(hash);
for(m=hash[h]; m!=nil; m=m->link) {
if(m->si == si && m->ss == ss) {
if(m->bad) {
throw("bad hashmap");
m = nil;
}
// prints("old hashmap\n");
return m;
}
}
ni = si[0].offset; // first word has size
m = mal(sizeof(*m) + ni*sizeof(m->fun[0]));
m->si = si;
m->ss = ss;
ni = 1; // skip first word
ns = 0;
loop1:
// pick up next name from
// interface signature
iname = si[ni].name;
if(iname == nil) {
m->link = hash[h];
hash[h] = m;
// prints("new hashmap\n");
return m;
}
ihash = si[ni].hash;
loop2:
// pick up and comapre next name
// from structure signature
sname = ss[ns].name;
if(sname == nil) {
prints((int8*)iname);
prints(": ");
throw("hashmap: failed to find method");
m->bad = 1;
m->link = hash[h];
hash[h] = m;
return nil;
}
if(ihash != ss[ns].hash ||
strcmp(sname, iname) != 0) {
ns++;
goto loop2;
}
m->fun[si[ni].offset] = ss[ns].fun;
ni++;
goto loop1;
}
void
sys·ifaces2i(Sigi *si, Sigs *ss, Map *m, void *s)
{
if(debug) {
prints("s2i sigi=");
sys·printpointer(si);
prints(" sigs=");
sys·printpointer(ss);
prints(" s=");
sys·printpointer(s);
}
if(s == nil) {
throw("ifaces2i: nil pointer");
m = nil;
FLUSH(&m);
return;
}
m = hashmap(si, ss);
if(debug) {
prints(" returning m=");
sys·printpointer(m);
prints(" s=");
sys·printpointer(s);
prints("\n");
dump((byte*)m, 64);
}
FLUSH(&m);
}
void
sys·ifacei2i(Sigi *si, Map *m, void *s)
{
if(debug) {
prints("i2i sigi=");
sys·printpointer(si);
prints(" m=");
sys·printpointer(m);
prints(" s=");
sys·printpointer(s);
}
if(m == nil) {
throw("ifacei2i: nil map");
s = nil;
FLUSH(&s);
return;
}
if(m->si == nil) {
throw("ifacei2i: nil pointer");
return;
}
if(m->si != si) {
m = hashmap(si, m->ss);
FLUSH(&m);
}
if(debug) {
prints(" returning m=");
sys·printpointer(m);
prints(" s=");
sys·printpointer(s);
prints("\n");
dump((byte*)m, 64);
}
}
void
sys·ifacei2s(Sigs *ss, Map *m, void *s)
{
if(debug) {
prints("i2s m=");
sys·printpointer(m);
prints(" s=");
sys·printpointer(s);
prints("\n");
}
if(m == nil) {
throw("ifacei2s: nil map");
s = nil;
FLUSH(&s);
return;
}
if(m->ss != ss) {
dump((byte*)m, 64);
throw("ifacei2s: wrong pointer");
s = nil;
FLUSH(&s);
return;
}
}
enum enum
{ {
NANEXP = 2047<<20, NANEXP = 2047<<20,
......
...@@ -34,9 +34,6 @@ typedef double float64; ...@@ -34,9 +34,6 @@ typedef double float64;
typedef uint8 bool; typedef uint8 bool;
typedef uint8 byte; typedef uint8 byte;
typedef struct String *string; typedef struct String *string;
typedef struct Sigs Sigs;
typedef struct Sigi Sigi;
typedef struct Map Map;
typedef struct Array Array; typedef struct Array Array;
typedef struct Gobuf Gobuf; typedef struct Gobuf Gobuf;
typedef struct G G; typedef struct G G;
...@@ -95,18 +92,6 @@ struct String ...@@ -95,18 +92,6 @@ struct String
int32 len; int32 len;
byte str[1]; byte str[1];
}; };
struct Sigs
{
byte* name;
uint32 hash;
void (*fun)(void);
};
struct Sigi
{
byte* name;
uint32 hash;
uint32 offset;
};
struct Array struct Array
{ // must not move anything { // must not move anything
...@@ -115,15 +100,6 @@ struct Array ...@@ -115,15 +100,6 @@ struct Array
uint32 cap; // allocate3d number of elements uint32 cap; // allocate3d number of elements
byte b[8]; // actual array - may not be contig byte b[8]; // actual array - may not be contig
}; };
struct Map
{
Sigi* si;
Sigs* ss;
Map* link;
int32 bad;
int32 unused;
void (*fun[])(void);
};
struct Gobuf struct Gobuf
{ {
byte* SP; byte* SP;
...@@ -305,9 +281,6 @@ void sys·cmpstring(string, string, int32); ...@@ -305,9 +281,6 @@ void sys·cmpstring(string, string, int32);
void sys·slicestring(string, int32, int32, string); void sys·slicestring(string, int32, int32, string);
void sys·indexstring(string, int32, byte); void sys·indexstring(string, int32, byte);
void sys·intstring(int64, string); void sys·intstring(int64, string);
void sys·ifaces2i(Sigi*, Sigs*, Map*, void*);
void sys·ifacei2i(Sigi*, Map*, void*);
void sys·ifacei2s(Sigs*, Map*, void*);
/* /*
* User go-called * User go-called
......
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