Beispiel #1
0
static void 
assertE2Tret ( Type *t , Eface e , byte *ret ) 
{ 
Eface err; 
#line 288 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"
if ( e.type == nil ) { 
runtime·newTypeAssertionError ( 
nil , nil , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
if ( e.type != t ) { 
runtime·newTypeAssertionError ( 
nil , e.type->string , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
copyout ( t , &e.data , ret ) ; 
} 
Beispiel #2
0
static void 
assertE2Tret ( Type *t , Eface e , byte *ret ) 
{ 
Eface err; 
#line 259 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
if ( e.type == nil ) { 
runtime·newTypeAssertionError ( 
nil , nil , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
if ( e.type != t ) { 
runtime·newTypeAssertionError ( 
nil , e.type->string , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
copyout ( t , &e.data , ret ) ; 
} 
Beispiel #3
0
static void
assertE2Tret(Type *t, Eface e, byte *ret)
{
	Eface err;

	if(e.type == nil) {
		runtime·newTypeAssertionError(
			nil, nil, t->string,
			nil, &err);
		runtime·panic(err);
	}
	if(e.type != t) {
		runtime·newTypeAssertionError(
			nil, e.type->string, t->string,
			nil, &err);
		runtime·panic(err);
	}
	copyout(t, &e.data, ret);
}
Beispiel #4
0
static void 
assertI2Tret ( Type *t , Iface i , byte *ret ) 
{ 
Itab *tab; 
Eface err; 
#line 209 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
tab = i.tab; 
if ( tab == nil ) { 
runtime·newTypeAssertionError ( 
nil , nil , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
if ( tab->type != t ) { 
runtime·newTypeAssertionError ( 
tab->inter->string , tab->type->string , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
copyout ( t , &i.data , ret ) ; 
} 
Beispiel #5
0
static void
assertI2Tret(Type *t, Iface i, byte *ret)
{
	Itab *tab;
	Eface err;

	tab = i.tab;
	if(tab == nil) {
		runtime·newTypeAssertionError(
			nil, nil, t->string,
			nil, &err);
		runtime·panic(err);
	}
	if(tab->type != t) {
		runtime·newTypeAssertionError(
			tab->inter->string, tab->type->string, t->string,
			nil, &err);
		runtime·panic(err);
	}
	copyout(t, &i.data, ret);
}
Beispiel #6
0
static void 
assertI2Tret ( Type *t , Iface i , byte *ret ) 
{ 
Itab *tab; 
Eface err; 
#line 233 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"
tab = i.tab; 
if ( tab == nil ) { 
runtime·newTypeAssertionError ( 
nil , nil , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
if ( tab->type != t ) { 
runtime·newTypeAssertionError ( 
tab->inter->string , tab->type->string , t->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
copyout ( t , &i.data , ret ) ; 
} 
Beispiel #7
0
void
runtime·ifaceE2I(InterfaceType *inter, Eface e, Iface *ret)
{
	Type *t;
	Eface err;

	t = e.type;
	if(t == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret->data = e.data;
	ret->tab = itab(inter, t, 0);
}
Beispiel #8
0
void
runtime·ifaceI2I(InterfaceType *inter, Iface i, Iface *ret)
{
	Itab *tab;
	Eface err;

	tab = i.tab;
	if(tab == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret->data = i.data;
	ret->tab = itab(inter, tab->type, 0);
}
Beispiel #9
0
void 
runtime·ifaceE2I ( InterfaceType *inter , Eface e , Iface *ret ) 
{ 
Type *t; 
Eface err; 
#line 406 "/home/14/ren/source/golang/go/src/pkg/runtime/iface.goc"
t = e.type; 
if ( t == nil ) { 
#line 409 "/home/14/ren/source/golang/go/src/pkg/runtime/iface.goc"
runtime·newTypeAssertionError ( 
nil , nil , inter->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
ret->data = e.data; 
ret->tab = itab ( inter , t , 0 ) ; 
} 
Beispiel #10
0
void 
runtime·ifaceI2I ( InterfaceType *inter , Iface i , Iface *ret ) 
{ 
Itab *tab; 
Eface err; 
#line 355 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
tab = i.tab; 
if ( tab == nil ) { 
#line 358 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
runtime·newTypeAssertionError ( 
nil , nil , inter->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
ret->data = i.data; 
ret->tab = itab ( inter , tab->type , 0 ) ; 
} 
Beispiel #11
0
void 
runtime·ifaceE2I ( InterfaceType *inter , Eface e , Iface *ret ) 
{ 
Type *t; 
Eface err; 
#line 421 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"
t = e.type; 
if ( t == nil ) { 
#line 424 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"
runtime·newTypeAssertionError ( 
nil , nil , inter->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
ret->data = e.data; 
ret->tab = itab ( inter , t , 0 ) ; 
} 
Beispiel #12
0
void 
runtime·ifaceI2I ( InterfaceType *inter , Iface i , Iface *ret ) 
{ 
Itab *tab; 
Eface err; 
#line 384 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"
tab = i.tab; 
if ( tab == nil ) { 
#line 387 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"
runtime·newTypeAssertionError ( 
nil , nil , inter->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
ret->data = i.data; 
ret->tab = itab ( inter , tab->type , 0 ) ; 
} 
Beispiel #13
0
void 
runtime·ifaceE2I ( InterfaceType *inter , Eface e , Iface *ret ) 
{ 
Type *t; 
Eface err; 
#line 392 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
t = e.type; 
if ( t == nil ) { 
#line 395 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
runtime·newTypeAssertionError ( 
nil , nil , inter->string , 
nil , &err ) ; 
runtime·panic ( err ) ; 
} 
ret->data = e.data; 
ret->tab = itab ( inter , t , 0 ) ; 
} 
Beispiel #14
0
// func ifaceE2E(typ *byte, iface any) (ret any)
void
runtime·assertE2E(InterfaceType* inter, Eface e, Eface ret)
{
	Type *t;
	Eface err;

	t = e.type;
	if(t == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret = e;
	FLUSH(&ret);
}
Beispiel #15
0
// func ifaceI2E(typ *byte, iface any) (ret any)
void
runtime·assertI2E(InterfaceType* inter, Iface i, Eface ret)
{
	Itab *tab;
	Eface err;

	tab = i.tab;
	if(tab == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret.data = i.data;
	ret.type = tab->type;
	FLUSH(&ret);
}
Beispiel #16
0
void
runtime·assertE2E(InterfaceType* inter, Eface e, Eface ret)
{
#line 436 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"

	Type *t;
	Eface err;

	t = e.type;
	if(t == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret = e;
	FLUSH(&ret);
}
Beispiel #17
0
void
runtime·assertI2E(InterfaceType* inter, Iface i, Eface ret)
{
#line 306 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"

	Itab *tab;
	Eface err;

	tab = i.tab;
	if(tab == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret.data = i.data;
	ret.type = tab->type;
	FLUSH(&ret);
}
Beispiel #18
0
void
runtime·assertE2E(InterfaceType* inter, Eface e, Eface ret)
{
	ret.type = 0;
	ret.data = 0;
	FLUSH(&ret);
#line 465 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"

	Type *t;
	Eface err;

	t = e.type;
	if(t == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret = e;
	FLUSH(&ret);
}
Beispiel #19
0
void
runtime·assertE2E(InterfaceType* inter, Eface e, Eface ret)
{
	ret.type = 0;
	ret.data = 0;
	FLUSH(&ret);
#line 450 "/home/14/ren/source/golang/go/src/pkg/runtime/iface.goc"

	Type *t;
	Eface err;

	t = e.type;
	if(t == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret = e;
	FLUSH(&ret);
}
Beispiel #20
0
void
runtime·assertI2E(InterfaceType* inter, Iface i, Eface ret)
{
	ret.type = 0;
	ret.data = 0;
	FLUSH(&ret);
#line 335 "/tmp/makerelease197226928/go/src/pkg/runtime/iface.goc"

	Itab *tab;
	Eface err;

	tab = i.tab;
	if(tab == nil) {
		// explicit conversions require non-nil interface value.
		runtime·newTypeAssertionError(
			nil, nil, inter->string,
			nil, &err);
		runtime·panic(err);
	}
	ret.data = i.data;
	ret.type = tab->type;
	FLUSH(&ret);
}
Beispiel #21
0
static Itab* 
itab ( InterfaceType *inter , Type *type , int32 canfail ) 
{ 
int32 locked; 
int32 ni; 
Method *t , *et; 
IMethod *i , *ei; 
uint32 h; 
String *iname , *ipkgPath; 
Itab *m; 
UncommonType *x; 
Type *itype; 
Eface err; 
#line 38 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
if ( inter->mhdr.len == 0 ) 
runtime·throw ( "internal error - misuse of itab" ) ; 
#line 41 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
locked = 0; 
#line 44 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
x = type->x; 
if ( x == nil ) { 
if ( canfail ) 
return nil; 
iname = inter->m[0].name; 
goto throw; 
} 
#line 53 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
h = inter->hash; 
h += 17 * type->hash; 
#line 56 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
h %= nelem ( hash ) ; 
#line 60 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
for ( locked=0; locked<2; locked++ ) { 
if ( locked ) 
runtime·lock ( &ifacelock ) ; 
for ( m=runtime·atomicloadp ( &hash[h] ) ; m!=nil; m=m->link ) { 
if ( m->inter == inter && m->type == type ) { 
if ( m->bad ) { 
m = nil; 
if ( !canfail ) { 
#line 75 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
goto search; 
} 
} 
if ( locked ) 
runtime·unlock ( &ifacelock ) ; 
return m; 
} 
} 
} 
#line 85 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
ni = inter->mhdr.len; 
m = runtime·persistentalloc ( sizeof ( *m ) + ni*sizeof m->fun[0] , 0 , &mstats.other_sys ) ; 
m->inter = inter; 
m->type = type; 
#line 90 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
search: 
#line 95 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
i = inter->m; 
ei = i + inter->mhdr.len; 
t = x->m; 
et = t + x->mhdr.len; 
for ( ; i < ei; i++ ) { 
itype = i->type; 
iname = i->name; 
ipkgPath = i->pkgPath; 
for ( ;; t++ ) { 
if ( t >= et ) { 
if ( !canfail ) { 
throw: 
#line 108 "/home/pi/go_build/hg/go/src/pkg/runtime/iface.goc"
runtime·newTypeAssertionError ( 
nil , type->string , inter->string , 
iname , &err ) ; 
if ( locked ) 
runtime·unlock ( &ifacelock ) ; 
runtime·panic ( err ) ; 
return nil; 
} 
m->bad = 1; 
goto out; 
} 
if ( t->mtyp == itype && t->name == iname && t->pkgPath == ipkgPath ) 
break; 
} 
if ( m ) 
m->fun[i - inter->m] = t->ifn; 
} 
Beispiel #22
0
static Itab*
itab(InterfaceType *inter, Type *type, int32 canfail)
{
	int32 locked;
	int32 ni;
	Method *t, *et;
	IMethod *i, *ei;
	uint32 h;
	String *iname, *ipkgPath;
	Itab *m;
	UncommonType *x;
	Type *itype;
	Eface err;

	if(inter->mhdr.len == 0)
		runtime·throw("internal error - misuse of itab");

	locked = 0;

	// easy case
	x = type->x;
	if(x == nil) {
		if(canfail)
			return nil;
		iname = inter->m[0].name;
		goto throw;
	}

	// compiler has provided some good hash codes for us.
	h = inter->hash;
	h += 17 * type->hash;
	// TODO(rsc): h += 23 * x->mhash ?
	h %= nelem(hash);

	// look twice - once without lock, once with.
	// common case will be no lock contention.
	for(locked=0; locked<2; locked++) {
		if(locked)
			runtime·lock(&ifacelock);
		for(m=runtime·atomicloadp(&hash[h]); m!=nil; m=m->link) {
			if(m->inter == inter && m->type == type) {
				if(m->bad) {
					m = nil;
					if(!canfail) {
						// this can only happen if the conversion
						// was already done once using the , ok form
						// and we have a cached negative result.
						// the cached result doesn't record which
						// interface function was missing, so jump
						// down to the interface check, which will
						// do more work but give a better error.
						goto search;
					}
				}
				if(locked)
					runtime·unlock(&ifacelock);
				return m;
			}
		}
	}

	ni = inter->mhdr.len;
	m = runtime·persistentalloc(sizeof(*m) + ni*sizeof m->fun[0], 0, &mstats.other_sys);
	m->inter = inter;
	m->type = type;

search:
	// both inter and type have method sorted by name,
	// and interface names are unique,
	// so can iterate over both in lock step;
	// the loop is O(ni+nt) not O(ni*nt).
	i = inter->m;
	ei = i + inter->mhdr.len;
	t = x->m;
	et = t + x->mhdr.len;
	for(; i < ei; i++) {
		itype = i->type;
		iname = i->name;
		ipkgPath = i->pkgPath;
		for(;; t++) {
			if(t >= et) {
				if(!canfail) {
				throw:
					// didn't find method
					runtime·newTypeAssertionError(
						nil, type->string, inter->string,
						iname, &err);
					if(locked)
						runtime·unlock(&ifacelock);
					runtime·panic(err);
					return nil;	// not reached
				}
				m->bad = 1;
				goto out;
			}
			if(t->mtyp == itype && t->name == iname && t->pkgPath == ipkgPath)
				break;
		}
		if(m)
			m->fun[i - inter->m] = t->ifn;
	}