if i < 0 || i >= j.a.Len() {
return Null
}
- return j.a.At(i)
+ return j.a.At(i).(Json)
}
func (j *_Array) String() string {
s := "[";
case b.ptr != nil:
return *b.ptr;
case b.a != nil:
- return b.a.At(b.i);
+ return b.a.At(b.i).(Json);
case b.m != nil:
return b.m[b.k];
}
pv := v.(reflect.PtrValue);
psubtype := pv.Type().(reflect.PtrType).Sub();
if pv.Get() == nil && psubtype.Kind() == reflect.ArrayKind {
- av := reflect.NewSliceValue(psubtype, 0, 8);
+ av := reflect.NewSliceValue(psubtype.(reflect.ArrayType), 0, 8);
pv.SetSub(av);
}
}
for n <= i {
n *= 2
}
- av1 := reflect.NewSliceValue(av.Type(), av.Len(), n);
+ av1 := reflect.NewSliceValue(av.Type().(reflect.ArrayType), av.Len(), n);
av1.CopyFrom(av, av.Len());
pv.SetSub(av1);
av = av1;
assert(typ.String(), "[]uint32");
t = reflect.ParseTypeString("", "[]int32");
- v := reflect.NewSliceValue(t, 5, 10);
+ v := reflect.NewSliceValue(t.(ArrayType), 5, 10);
t1 := reflect.ParseTypeString("", "*[]int32");
v1 := reflect.NewInitValue(t1);
if v1 == nil { panic("V1 is nil"); }
}
}
for tocopy := 1; tocopy <= 7; tocopy++ {
- vb.(PtrValue).Sub().(ArrayValue).CopyFrom(va.(PtrValue).Sub(), tocopy);
+ vb.(PtrValue).Sub().(ArrayValue).CopyFrom(va.(PtrValue).Sub().(ArrayValue), tocopy);
for i := 0; i < tocopy; i++ {
if a[i] != b[i] {
t.Errorf("1 tocopy=%d a[%d]=%d, b[%d]=%d",
}
return str + TypeToString(c.Elem(), false);
case StructKind:
- return "struct{" + typeFieldsToString(typ, ";") + "}";
+ return "struct{" + typeFieldsToString(typ.(StructType), ";") + "}";
case InterfaceKind:
- return "interface{" + typeFieldsToString(typ, ";") + "}";
+ return "interface{" + typeFieldsToString(typ.(InterfaceType), ";") + "}";
case FuncKind:
f := typ.(FuncType);
str = "(" + typeFieldsToString(f.In(), ",") + ")";
// -- Pointer
type PtrType interface {
+ // TODO: Type;
+ Kind() int;
+ Name() string;
+ String() string;
+ Size() int;
+
Sub() Type
}
// -- Array
type ArrayType interface {
+ // TODO: Type;
+ Kind() int;
+ Name() string;
+ String() string;
+ Size() int;
+
IsSlice() bool;
Len() int;
Elem() Type;
// -- Map
type MapType interface {
+ // TODO: Type;
+ Kind() int;
+ Name() string;
+ String() string;
+ Size() int;
+
Key() Type;
Elem() Type;
}
// -- Chan
type ChanType interface {
+ // TODO: Type;
+ Kind() int;
+ Name() string;
+ String() string;
+ Size() int;
+
Dir() int;
Elem() Type;
}
// -- Struct
type StructType interface {
+ // TODO: Type;
+ Kind() int;
+ Name() string;
+ String() string;
+ Size() int;
+
Field(int) (name string, typ Type, tag string, offset int);
Len() int;
}
// -- Interface
type InterfaceType interface {
+ // TODO: Type;
+ Kind() int;
+ Name() string;
+ String() string;
+ Size() int;
+
Field(int) (name string, typ Type, tag string, offset int);
Len() int;
}
// -- Func
type FuncType interface {
+ // TODO: Type;
+ Kind() int;
+ Name() string;
+ String() string;
+ Size() int;
+
In() StructType;
Out() StructType;
}
// -- Missing
type MissingValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
Addr() Addr;
+ Interface() interface {};
}
type missingValueStruct struct {
// -- Int
type IntValue interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() int;
Set(int);
- Type() Type;
}
type intValueStruct struct {
// -- Int8
type Int8Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() int8;
Set(int8);
- Type() Type;
}
type int8ValueStruct struct {
// -- Int16
type Int16Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() int16;
Set(int16);
- Type() Type;
}
type int16ValueStruct struct {
// -- Int32
type Int32Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() int32;
Set(int32);
- Type() Type;
}
type int32ValueStruct struct {
// -- Int64
type Int64Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() int64;
Set(int64);
- Type() Type;
}
type int64ValueStruct struct {
// -- Uint
type UintValue interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() uint;
Set(uint);
- Type() Type;
}
type uintValueStruct struct {
// -- Uint8
type Uint8Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() uint8;
Set(uint8);
- Type() Type;
}
type uint8ValueStruct struct {
// -- Uint16
type Uint16Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() uint16;
Set(uint16);
- Type() Type;
}
type uint16ValueStruct struct {
// -- Uint32
type Uint32Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() uint32;
Set(uint32);
- Type() Type;
}
type uint32ValueStruct struct {
// -- Uint64
type Uint64Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() uint64;
Set(uint64);
- Type() Type;
}
type uint64ValueStruct struct {
// -- Uintptr
type UintptrValue interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() uintptr;
Set(uintptr);
- Type() Type;
}
type uintptrValueStruct struct {
// -- Float
type FloatValue interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() float;
Set(float);
- Type() Type;
}
type floatValueStruct struct {
// -- Float32
type Float32Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() float32;
Set(float32);
- Type() Type;
}
type float32ValueStruct struct {
// -- Float64
type Float64Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() float64;
Set(float64);
- Type() Type;
}
type float64ValueStruct struct {
// -- Float80
type Float80Value interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() float80;
Set(float80);
- Type() Type;
}
type float80ValueStruct struct {
// -- String
type StringValue interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() string;
Set(string);
- Type() Type;
}
type stringValueStruct struct {
// -- Bool
type BoolValue interface {
+ // TODO: Value;
Kind() int;
+ Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() bool;
Set(bool);
- Type() Type;
}
type boolValueStruct struct {
// -- Pointer
type PtrValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Sub() Value;
Get() Addr;
SetSub(Value);
// Slices and arrays are represented by the same interface.
type ArrayValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
IsSlice() bool;
Len() int;
Cap() int;
// -- Map TODO: finish and test
type MapValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Len() int;
Elem(key Value) Value;
}
// -- Chan
type ChanValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
+ Addr() Addr;
+ Interface() interface {};
}
type chanValueStruct struct {
// -- Struct
type StructValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Len() int;
Field(i int) Value;
}
// -- Interface
type InterfaceValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
+ Addr() Addr;
+ Interface() interface {};
+
Get() interface {};
}
// -- Func
type FuncValue interface {
+ // TODO: Value;
Kind() int;
Type() Type;
+ Addr() Addr;
+ Interface() interface {};
}
type funcValueStruct struct {
array.len = uint32(len);
array.cap = uint32(cap);
- return newValueAddr(typ, Addr(array));
+ return newValueAddr(typ, Addr(array)).(ArrayValue);
}
// Works on both slices and arrays
func get(in *dch) *rat {
seqno++;
in.req <- seqno;
- return <-in.dat;
+ return (<-in.dat).(*rat);
}
// Get one item from each of n demand channels
for {
<-Z.req;
uv = get2(U,V);
- switch end(uv[0])+2*end(uv[1]) {
+ switch end(uv[0].(*rat))+2*end(uv[1].(*rat)) {
case 0:
- Z.dat <- add(uv[0], uv[1]);
+ Z.dat <- add(uv[0].(*rat), uv[1].(*rat));
case 1:
Z.dat <- uv[1];
copy(V,Z);
go func(U, V, Z PS){
<-Z.req;
uv := get2(U,V);
- if end(uv[0])!=0 || end(uv[1]) != 0 {
+ if end(uv[0].(*rat))!=0 || end(uv[1].(*rat)) != 0 {
Z.dat <- finis;
} else {
- Z.dat <- mul(uv[0],uv[1]);
+ Z.dat <- mul(uv[0].(*rat),uv[1].(*rat));
UU := Split(U);
VV := Split(V);
- W := Add(Cmul(uv[0],VV[0]),Cmul(uv[1],UU[0]));
+ W := Add(Cmul(uv[0].(*rat),VV[0]),Cmul(uv[1].(*rat),UU[0]));
<-Z.req;
Z.dat <- get(W);
copy(Add(W,Mul(UU[1],VV[1])),Z);
v.Insert(i0);
for i := 0; i < v.nelem; i++ {
var x *I;
- x = v.At(i);
+ x = v.At(i).(*I);
print(i, " ", x.val, "\n"); // prints correct list
}
for i := 0; i < v.nelem; i++ {
}
func (s *TStruct) field(i int) *TStruct {
- // works if we say
- // t := s.fields.At(i);
- // return t;
- return s.fields.At(i);
+ return s.fields.At(i).(*TStruct);
}
func main() {
func
main()
{
- i2 = e(); // bug089.go:16: fatal error: agen_inter i2i
+ i2 = e().(I2); // bug089.go:16: fatal error: agen_inter i2i
}
func main() {
var i I;
i = 1;
- var v1 int = i;
+ var v1 = i.(int);
if foo1(v1) != 1 { panicln(1) }
- var v2 int32 = int32(i.(int));
+ var v2 = int32(i.(int));
if foo2(v2) != 1 { panicln(2) }
- var v3 int32 = i; // This implicit type conversion should fail at runtime.
+ var v3 = i.(int32); // This type conversion should fail at runtime.
if foo2(v3) != 1 { panicln(3) }
}
var i I;
var e interface {};
e = s;
- i = e;
+ i = e.(I);
}
// hide S down here to avoid static warning
type I interface { M() }
var i I
+type I2 interface { M(); N(); }
+var i2 I2;
+
+var e interface { };
+
func main() {
+ e = t; // ok
+ t = e; // ERROR "need explicit"
+
// neither of these can work,
// because i has an extra method
// that t does not, so i cannot contain a t.
- i = t; // ERROR "missing|incompatible"
- t = i; // ERROR "missing|incompatible"
+ i = t; // ERROR "missing|incompatible|is not"
+ t = i; // ERROR "missing|incompatible|is not"
+
+ i = i2; // ok
+ i2 = i; // ERROR "need explicit"
}
// run it thru an interface
i = s;
- s = i;
+ s = i.(*S);
// same as t3
if s.test1() != s.a1 { panicln("t4", 1) }
u32 = 4455; ia[11] = u32;
u64 = 765432; ia[12] = u64;
- s = ia[0]; if s != "xxx" { panicln(0,s); }
+ s = ia[0].(string); if s != "xxx" { panicln(0,s); }
i32 = int32(ia[1].(int));
if i32 != 12345 { panicln(1,i32); }
- b = ia[2]; if b != true { panicln(2,b); }
+ b = ia[2].(bool); if b != true { panicln(2,b); }
- s = ia[3]; if s != "now is" { panicln(3,s); }
- b = ia[4]; if b != false { panicln(4,b); }
+ s = ia[3].(string); if s != "now is" { panicln(3,s); }
+ b = ia[4].(bool); if b != false { panicln(4,b); }
- i8 = ia[5]; if i8 != 29 { panicln(5,i8); }
- i16 = ia[6]; if i16 != 994 { panicln(6,i16); }
- i32 = ia[7]; if i32 != 3434 { panicln(7,i32); }
- i64 = ia[8]; if i64 != 1234567 { panicln(8,i64); }
+ i8 = ia[5].(int8); if i8 != 29 { panicln(5,i8); }
+ i16 = ia[6].(int16); if i16 != 994 { panicln(6,i16); }
+ i32 = ia[7].(int32); if i32 != 3434 { panicln(7,i32); }
+ i64 = ia[8].(int64); if i64 != 1234567 { panicln(8,i64); }
- u8 = ia[9]; if u8 != 12 { panicln(5,u8); }
- u16 = ia[10]; if u16 != 799 { panicln(6,u16); }
- u32 = ia[11]; if u32 != 4455 { panicln(7,u32); }
- u64 = ia[12]; if u64 != 765432 { panicln(8,u64); }
+ u8 = ia[9].(uint8); if u8 != 12 { panicln(5,u8); }
+ u16 = ia[10].(uint16); if u16 != 799 { panicln(6,u16); }
+ u32 = ia[11].(uint32); if u32 != 4455 { panicln(7,u32); }
+ u64 = ia[12].(uint64); if u64 != 765432 { panicln(8,u64); }
}
if s.g() != 6 { panic(12); }
i1 = s; // convert S to I1
- i2 = i1; // convert I1 to I2
+ i2 = i1.(I2); // convert I1 to I2
// call interface
if i1.f() != 5 { panic(21); }
if i2.f() != 5 { panic(22); }
if i2.g() != 6 { panic(23); }
- g = i1; // convert I1 to S
+ g = i1.(*S); // convert I1 to S
if g != s { panic(31); }
- g = i2; // convert I2 to S
+ g = i2.(*S); // convert I2 to S
if g != s { panic(32); }
}
x = last;
} else {
last.Y = P.newBinaryExpr(pos, Scanner.COMMA, last.Y, y);
- last = last.Y;
+ last = last.Y.(*AST.BinaryExpr);
}
}
x = last;
} else {
last.Y = P.newBinaryExpr(pos, Scanner.COMMA, last.Y, y);
- last = last.Y;
+ last = last.Y.(*AST.BinaryExpr);
}
if P.tok == Scanner.COMMA {