diff --git a/contracts/assign_unnamed_type/assign_unnamedtype0_filetest.gno b/contracts/assign_unnamed_type/assign_unnamedtype0_filetest.gno new file mode 100644 index 00000000000..c722fa50c9c --- /dev/null +++ b/contracts/assign_unnamed_type/assign_unnamedtype0_filetest.gno @@ -0,0 +1,15 @@ +package main + +type nat []word +type word int + +func main() { + var a nat + b := []word{0} + a = b + + println(a) +} + +// Output: +// (slice[(0 main.word)] main.nat) diff --git a/contracts/assign_unnamed_type/assign_unnamedtype0b_filetest.gno b/contracts/assign_unnamed_type/assign_unnamedtype0b_filetest.gno new file mode 100644 index 00000000000..b9db1871254 --- /dev/null +++ b/contracts/assign_unnamed_type/assign_unnamedtype0b_filetest.gno @@ -0,0 +1,15 @@ +package main + +type nat []int +type word int + +func main() { + var a nat + b := []word{0} + a = b + + println(a) +} + +// Error: +// main/contracts/assign_unnamed_type/assign_unnamedtype0b_filetest.gno:9: cannot use main.word as int without explicit conversion diff --git a/contracts/assign_unnamed_type/assign_unnamedtype7_filetest.gno b/contracts/assign_unnamed_type/assign_unnamedtype7_filetest.gno new file mode 100644 index 00000000000..939428bd192 --- /dev/null +++ b/contracts/assign_unnamed_type/assign_unnamedtype7_filetest.gno @@ -0,0 +1,15 @@ +package main + +type mychan chan int + +// chan int is unmamed +func main() { + var n mychan = nil + var u chan int = nil + n = u + + println(n) +} + +// Output: +// (nil main.mychan) diff --git a/contracts/declaredtype/declaredType0b_filetest.gno b/contracts/declaredtype/declaredType0b_filetest.gno new file mode 100644 index 00000000000..b053442c2d4 --- /dev/null +++ b/contracts/declaredtype/declaredType0b_filetest.gno @@ -0,0 +1,20 @@ +package main + +type word int +type nat []word + +func (n nat) add() bool { + return true +} + +func main() { + var abs nat + var b []word + b = []word{0} + abs = b + + println(abs) +} + +// Output: +// (slice[(0 main.word)] main.nat) diff --git a/contracts/decompose/decompose2_filetest.gno b/contracts/decompose/decompose2_filetest.gno deleted file mode 100644 index fc3f4161079..00000000000 --- a/contracts/decompose/decompose2_filetest.gno +++ /dev/null @@ -1,20 +0,0 @@ -package main - -func x() (int, int) { - - return 1, 2 -} - -func main() { - var a, b int - a, _ = x() - //t1, t2 := x() - //a, b = t1, t2 - println(a) - println(b) - -} - -// Output: -// 1 -// 0 diff --git a/contracts/decompose/decompose_filetest.gno b/contracts/decompose/decompose_filetest.gno deleted file mode 100644 index 8c315258eb9..00000000000 --- a/contracts/decompose/decompose_filetest.gno +++ /dev/null @@ -1,20 +0,0 @@ -package main - -func x() (int, int) { - - return 1, 2 -} - -func main() { - var a, b int - a, b = x() - //t1, t2 := x() - //a, b = t1, t2 - println(a) - println(b) - -} - -// Output: -// 1 -// 2 diff --git a/contracts/decompose/decompose_unnamed1a_filetest.gno b/contracts/decompose/decompose_unnamed1a_filetest.gno new file mode 100644 index 00000000000..aff909afcd5 --- /dev/null +++ b/contracts/decompose/decompose_unnamed1a_filetest.gno @@ -0,0 +1,26 @@ +package main + +type nat []int + +func x() (nat, []int) { + a := nat{1} + b := []int{2} + return a, b +} + +func main() { + var u1 []int + var n2 nat + + _, n2 = x() + // _tmp1, _tmp_2 := x() + // _, u2 = _tmp1, _tmp_2 + + println(u1) + println(n2) + +} + +// Output: +// (nil []int) +// (slice[(2 int)] main.nat) diff --git a/contracts/decompose/decompose_unnamed1b_filetest.gno b/contracts/decompose/decompose_unnamed1b_filetest.gno new file mode 100644 index 00000000000..3248d9ca700 --- /dev/null +++ b/contracts/decompose/decompose_unnamed1b_filetest.gno @@ -0,0 +1,26 @@ +package main + +type nat []int + +func x() (nat, []int) { + a := nat{1} + b := []int{2} + return a, b +} + +func main() { + var u1 []int + var n2 nat + + u1, _ = x() + // _tmp1, _tmp_2 := x() + // u1, _ = _tmp1, _tmp_2 + + println(u1) + println(n2) + +} + +// Output: +// slice[(1 int)] +// (nil main.nat) diff --git a/contracts/decompose/decompose_unnamed2_filetest.gno b/contracts/decompose/decompose_unnamed2_filetest.gno new file mode 100644 index 00000000000..e28b231b63e --- /dev/null +++ b/contracts/decompose/decompose_unnamed2_filetest.gno @@ -0,0 +1,30 @@ +package main + +type nat []int + +func x() (nat, []int) { + a := nat{1} + b := []int{2} + return a, b +} + +func main() { + var u1 []int + var n2 nat + // BlockStmt + { u1, n2 = x() + // _tmp_1, _tmp_2 := x() + // u1, n2 = _tmp_1, _tmp_2 + + println(u1) + println(n2) + println(u1) + println(n2) + } +} + +// Output: +// slice[(1 int)] +// (slice[(2 int)] main.nat) +// slice[(1 int)] +// (slice[(2 int)] main.nat) diff --git a/contracts/decompose/return_two2c_filetest.gno b/contracts/decompose/decompose_unnamed_filetest.gno similarity index 100% rename from contracts/decompose/return_two2c_filetest.gno rename to contracts/decompose/decompose_unnamed_filetest.gno diff --git a/contracts/filetest/default_value_filetest.gno b/contracts/filetest/default_value_filetest.gno new file mode 100644 index 00000000000..5612f9a84d4 --- /dev/null +++ b/contracts/filetest/default_value_filetest.gno @@ -0,0 +1,30 @@ +package main +type nat []int +type nmap map[int]int +type nfunc func() + +func main() { + var u1 []int + var n2 nat + var m map[int]int + var m2 nmap + var f func() + var f2 nfunc + + + println(u1) + println(n2) + println(m) + println(m2) + println(f) + println(f2) + +} + +// Output: +// (nil []int) +// (nil main.nat) +// (nil map[int]int) +// (nil main.nmap) +// nil func()() +// (nil main.nfunc) diff --git a/contracts/filetest/realm_compositelit_filetest.gno b/contracts/filetest/realm_compositelit_filetest.gno new file mode 100644 index 00000000000..1efa2348052 --- /dev/null +++ b/contracts/filetest/realm_compositelit_filetest.gno @@ -0,0 +1,225 @@ +// PKGPATH: gno.land/r/test +package test + +import ( + "fmt" +) + +type word uint +type nat []word + +var zero *Int + +// structLit +type Int struct { + abs nat +} + +func main() { + + zero = &Int{ + abs: []word{0}, + } + a := zero.abs + println(a) +} + +// Output: +// (slice[(0 gno.land/r/test.word)] gno.land/r/test.nat) + +// Realm: +// switchrealm["gno.land/r/test"] +// c[a8ada09dee16d791fd406d629fe29bb0ed084a30:5]={ +// "Data": null, +// "List": [ +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/test.word" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5", +// "ModTime": "0", +// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4", +// "RefCount": "1" +// } +// } +// c[a8ada09dee16d791fd406d629fe29bb0ed084a30:4]={ +// "Fields": [ +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/test.nat" +// }, +// "V": { +// "@type": "/gno.SliceValue", +// "Base": { +// "@type": "/gno.RefValue", +// "Hash": "9263ebf7e55e2d929e9c190bc4490ee58db148ec", +// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:5" +// }, +// "Length": "1", +// "Maxcap": "1", +// "Offset": "0" +// } +// } +// ], +// "ObjectInfo": { +// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4", +// "ModTime": "0", +// "OwnerID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", +// "RefCount": "1" +// } +// } +// u[a8ada09dee16d791fd406d629fe29bb0ed084a30:2]={ +// "Blank": {}, +// "ObjectInfo": { +// "ID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:2", +// "IsEscaped": true, +// "ModTime": "3", +// "RefCount": "2" +// }, +// "Parent": null, +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "File": "", +// "Line": "0", +// "Nonce": "0", +// "PkgPath": "gno.land/r/test" +// } +// }, +// "Values": [ +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.PrimitiveType", +// "value": "2048" +// }, +// "Methods": [], +// "Name": "word", +// "PkgPath": "gno.land/r/test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/test.word" +// }, +// "Vrd": false +// }, +// "Methods": [], +// "Name": "nat", +// "PkgPath": "gno.land/r/test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "abs", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/test.nat" +// } +// } +// ], +// "PkgPath": "gno.land/r/test" +// }, +// "Methods": [], +// "Name": "Int", +// "PkgPath": "gno.land/r/test" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:3" +// }, +// "FileName": "main.gno", +// "IsMethod": false, +// "Name": "main", +// "PkgPath": "gno.land/r/test", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "File": "main.gno", +// "Line": "18", +// "Nonce": "0", +// "PkgPath": "gno.land/r/test" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/test.Int" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": null, +// "Index": "0", +// "TV": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/test.Int" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "91ebdb8ff6b68e0b93179fae022213185a450649", +// "ObjectID": "a8ada09dee16d791fd406d629fe29bb0ed084a30:4" +// } +// } +// } +// } +// ] +// } diff --git a/examples/gno.land/r/demo/tests/realm_compositelit.gno b/examples/gno.land/r/demo/tests/realm_compositelit.gno new file mode 100644 index 00000000000..b7363362314 --- /dev/null +++ b/examples/gno.land/r/demo/tests/realm_compositelit.gno @@ -0,0 +1,21 @@ +package tests + +type Word uint +type nat []Word + +var zero = &Int{ + neg: true, + abs: []Word{0}, +} + +// structLit +type Int struct { + neg bool + abs nat +} + +func GetZeroType() nat { + + a := zero.abs + return a +} diff --git a/examples/gno.land/r/demo/tests/realm_method38d.gno b/examples/gno.land/r/demo/tests/realm_method38d.gno new file mode 100644 index 00000000000..7355efd157c --- /dev/null +++ b/examples/gno.land/r/demo/tests/realm_method38d.gno @@ -0,0 +1,22 @@ +package tests + +var abs nat + +func (n nat) Add() nat { + + return []Word{0} +} + +func GetAbs() nat { + + abs = []Word{0} + + return abs +} + +func AbsAdd() nat { + + rt := GetAbs().Add() + + return rt +} diff --git a/gnovm/pkg/gnolang/nodes.go b/gnovm/pkg/gnolang/nodes.go index 57141028bb3..786b6a15004 100644 --- a/gnovm/pkg/gnolang/nodes.go +++ b/gnovm/pkg/gnolang/nodes.go @@ -668,6 +668,12 @@ func (ss Body) GetBody() Body { return ss } +func (ss *Body) SetBody( nb Body){ + + *ss = nb + +} + func (ss Body) GetLabeledStmt(label Name) (stmt Stmt, idx int) { for idx, stmt = range ss { if label == stmt.GetLabel() { @@ -1331,7 +1337,7 @@ func (x *PackageNode) PrepareNewValues(pv *PackageValue) []TypedValue { panic("PackageNode.PrepareNewValues() package mismatch") } } - // the FuncDecl Body maybe be altered during the preprocessing. + // the FuncValue Body maybe be altered during the preprocessing. // We need to update body field from the source in the FuncValue accordingly. for _, tv := range x.Values { @@ -1443,6 +1449,7 @@ type BlockNode interface { Define(Name, TypedValue) Define2(bool, Name, Type, TypedValue) GetBody() Body + SetBody(Body) } // ---------------------------------------- @@ -1804,18 +1811,39 @@ func (x *IfStmt) GetBody() Body { panic("IfStmt has no body (but .Then and .Else do)") } +func (x *IfStmt) SetBody(b Body) { + + panic("IfStmt has no body (but .Then and .Else do)") +} + func (x *SwitchStmt) GetBody() Body { panic("SwitchStmt has no body (but its cases do)") } +func (x *SwitchStmt) SetBody(b Body) { + + panic("SwitchStmt has no body (but .Then and .Else do)") +} + + func (x *FileNode) GetBody() Body { panic("FileNode has no body (but it does have .Decls)") } +func (x *FileNode) SetBody(b Body) { + + panic("FileNode has no body (but .Then and .Else do)") +} + func (x *PackageNode) GetBody() Body { panic("PackageNode has no body") } +func (x *PackageNode) SetBody(b Body) { + + panic("PackageNode has no body") +} + // ---------------------------------------- // Value Path diff --git a/gnovm/pkg/gnolang/preprocess.go b/gnovm/pkg/gnolang/preprocess.go index 2a57a70e641..4e7994c40a4 100644 --- a/gnovm/pkg/gnolang/preprocess.go +++ b/gnovm/pkg/gnolang/preprocess.go @@ -1585,9 +1585,7 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node { "%d variables but %s returns %d values", len(n.Lhs), cx.Func.String(), len(cft.Results))) } - - /* ----- START of discussion ---- */ - + // check if we we need to decompose for named typed conversion in the function return results decompose := false for i, rhsType := range cft.Results { @@ -1598,112 +1596,72 @@ func Preprocess(store Store, ctx BlockNode, n Node) Node { } } - if decompose == true { - - // only enter this section if cft.Results to be converted to Lhs type and >1? worth to check this? - // a,b = x() decopose to: - // tmp1, tmp2 := x() convert current statement to (Op=DEFINE) - // a,b = tmp1, tmp2 add a newStmt ( Op=ASSIGN ) - // add statement to the FuncDecl.Body - // - // copy the a,b = x() and create a new statement a,b = _tmp_1, _tmp_2 - // add or insert a new assignment statements a,b = tmp1,tmp2 AFTER the current statement in the last.Body. - fbody := last.GetBody() - curBodyLen := len(fbody) - origBodyLen := last.GetStaticBlock().GetBlock().GetBodyStmt().BodyLen - - newStmt := n.Copy().(*AssignStmt) - newStmt.SetAttribute(ATTR_PREPROCESSED, false) - newStmt.Line = n.Line - // No need to change astmt.Lhs - var rhsExprs Exprs - for i, _ := range cft.Results { - // create a hidden var with leading dot. the curBodyLen increase every time when there is an decompostion - // we use curBodyLen to differentiate the .tmp variables created in each assignment decompostion - rn := fmt.Sprintf("_tmp_%d_%d", curBodyLen, i) - rhsExprs = append(rhsExprs, X(rn)) - } - newStmt.Rhs = rhsExprs - // add or insert a new assignment statements a,b = tmp1,tmp2 AFTER the current statement in the last.Body. - if len(fbody) == 0 { + if decompose ==true{ - last.(*FuncDecl).Body = append(fbody, Body{newStmt}...) - } else { - last.(*FuncDecl).Body = append(fbody[:index+1], append(Body{newStmt}, fbody[index+1:]...)...) - } - // DISCUSSION: need to insert the statement astmt to FuncValue.body of PackageNopde.Values[i].V - // Option1: make FuncValue.body as a poninter to FuncValue.Source.Body - // Option2: Add transcribe type FuncValue - // Option3: updating FuncValue.body=FuncValue.Source.Body in updates := pn.PrepareNewValues(pv) - // Current Option3. Need to Update FuncValue from source - // Option4: in Op_Call: FuncValue.GetBodyFromSource synce FuncValue.body with Source body - // - // update current assignment node and run define tmp1,tmp2 := x() - for i, lx := range n.Lhs { - if lx.(*NameExpr).Name == "_" { - continue - } - // create a hidden var with leading dot. - ln := fmt.Sprintf("_tmp_%d_%d", curBodyLen, i) - n.Lhs[i] = X(ln) + // only enter this section if cft.Results to be converted to Lhs type for named type conversion. + // decompose a,b = x() + // tmp1, tmp2 := x() assignment statemet expression (Op=DEFINE) + // a,b = tmp1, tmp2 assignment statemet expression ( Op=ASSIGN ) + // add the new statement to last.Body + + // step1: + // create a hidden var with leading _ the curBodyLen increase every time when there is an decompostion + // because there could be multiple decomposition happens + // we use both stmt index and resturn result number to differentiate the _tmp variables created in each assignment decompostion + // ex. _tmp_3_2: this variabl is created as the 3rd statement in the block, the 2nd parameter returned from x(), + // create _tmp_1_1, tmp_1_2 .... based on number of result from x() + var tmpExprs Exprs + for i, _ := range cft.Results { + rn := fmt.Sprintf("_tmp_%d_%d", index, i) + tmpExprs = append(tmpExprs, Nx(rn)) } - n.Op = DEFINE - - for i, lx := range n.Lhs { - ln := lx.(*NameExpr).Name - rf := cft.Results[i] - // re-definition - last.Define(ln, anyValue(rf.Type)) - fillNameExprPath(last, lx.(*NameExpr), true) + // step2: + // tmp1, tmp2 := x() + dsx := &AssignStmt{ + Lhs: tmpExprs, + Op: DEFINE, + Rhs: n.Rhs, } + dsx.SetLine(n.Line) + dsx = Preprocess(store, last,dsx).(*AssignStmt) - // # ISSUE1: - // After preprocess the last lastment in FuncDecl.Body will not be transcribed - // in the exampe println(u2) will not be preprocessed and u2 will have empty PathValue. - // VM will throw non pointer panic when execute this. - // - // ### Cause: transcribe flow - // in transcribe.go - // case *FuncDecl: // func main() - // : - // for idx := range cnn.Body { - // : - // cnn.Body[idx] = transcribe(t, nns, TRANS_FUNC_BODY, idx, cnn.Body[idx], &c).(Stmt) - // } - // : - // Can not extend the length of cnn.Body ([]stmt) therefore it does not range through the extra statements - - // ### Solution: - // Alway peprocess the +1 index of orignal body length in the newBody - // since the new last.Body could keep growing when multiple assign stmt decomposition happens - // We need to use the original body len as preprocess index in the newBody - newBody := last.(*FuncDecl).Body - Preprocess(store, last, newBody[origBodyLen]) - // DISCUSSION: - // What will be the side effect to preprocess the last statement before other statements in the Body? - - return n, TRANS_CONTINUE + // step3: + + // a,b = tmp1, tmp2 + // assign stmt expression + // the right hand side will be converted to call expr for nameed/unnamed covnerstion + // we make a copy of tmpExrs to prevent dsx.Lhs in the preview statement changing by the side effect + // when asx.Rhs is converted to const call expr during the preprocess of the next statement + + asx := &AssignStmt{ + Lhs: n.Lhs, + Op: ASSIGN, + Rhs: copyExprs(tmpExprs), - } - // # ISSUE2: we have solution - // The FuncValue.body is not updated after we changed the body in preproces. - // VM run time will not evaluate the extra statemetns in the FuncValue.Source.Body - // - // ### Solution: need to insert the statement astmt to FuncValue.body of PackageNode.Values[i].V - // Option1: make FuncValue.body as a poninter to FuncValue.Source.Body - // Option2: Add transcribe type FuncValue - // Option3: updating FuncValue.body=FuncValue.Source.Body when run updates := pn.PrepareNewValues(pv) before run time - // Current we implemented the Option3. - // Option4: in Op_Call: same as option3 but in run time .call FuncValue.GetBodyFromSource() to synce FuncValue.body with FuncValue.Source.Body - - /* ----- END of discussion ---- */ - for i, lx := range n.Lhs { - lt := evalStaticTypeOf(store, last, lx) - if lt != nil { - checkType(cft.Results[i].Type, lt, false) } - } + asx.SetLine(n.Line) + asx = Preprocess(store, last,asx).(*AssignStmt) + + // step4: + // replace the orignal stmt with two new stmts + body := last.GetBody() + // we need to do an in-place replacement while leaving the current node + n.Attributes = dsx.Attributes + n.Lhs = dsx.Lhs + n.Op =dsx.Op + n.Rhs=dsx.Rhs + + // insert a assignment statement a,b = tmp1,tmp2 AFTER the current statement in the last.Body. + body = append(body[:index+1], append(Body{asx}, body[index+1:]...)...) + last.SetBody(body) + } // end of the decomposition + + // DISCUSSION: we need to insert the statements to FuncValue.body of PackageNopde.Values[i].V + // Option1: make FuncValue.body as a poninter to FuncValue.Source.Body + // Option2: updating FuncValue.body=FuncValue.Source.Body in updates := pn.PrepareNewValues(pv) during preprocess. + // current is Option2. we need to Update FuncValue from source + // Option3: in Op_Call: FuncValue.GetBodyFromSource synce FuncValue.body with Source body case *TypeAssertExpr: // Type-assert case: a, ok := x.(type) if len(n.Lhs) != 2 { @@ -2064,28 +2022,6 @@ func pushInitBlock(bn BlockNode, last *BlockNode, stack *[]BlockNode) { if bn.GetStaticBlock().Source != bn { panic("expected the source of a block node to be itself") } - hasBody := true - - switch bn.(type) { - case *IfStmt: - hasBody = false - case *SwitchStmt: - hasBody = false - case *FileNode: - hasBody = false - case *PackageNode: - hasBody = false - default: - - } - - if hasBody { - bn.GetStaticBlock().bodyStmt = bodyStmt{ - Body: bn.GetBody(), - BodyLen: len(bn.GetBody()), - } - } - *last = bn *stack = append(*stack, bn) } @@ -2292,12 +2228,12 @@ func getResultTypedValues(cx *CallExpr) []TypedValue { func evalConst(store Store, last BlockNode, x Expr) *ConstExpr { // TODO: some check or verification for ensuring x // is constant? From the machine? - cv := NewMachine(".dontcare", store) - tv := cv.EvalStatic(last, x) - cv.Release() + m := NewMachine(".dontcare", store) + cv := m.EvalStatic(last, x) + m.Release() cx := &ConstExpr{ Source: x, - TypedValue: tv, + TypedValue: cv, } cx.SetAttribute(ATTR_PREPROCESSED, true) setConstAttrs(cx) @@ -2454,11 +2390,13 @@ func checkOrConvertType(store Store, last BlockNode, x *Expr, t Type, autoNative // "push" expected type into shift binary's left operand. checkOrConvertType(store, last, &bx.Left, t, autoNative) } else if *x != nil { // XXX if x != nil && t != nil { + // check type xt := evalStaticTypeOf(store, last, *x) if t != nil { checkType(xt, t, autoNative) } - if isUntyped(xt) { + // convert type + if isUntyped(xt) { // convert if x is untyped literal if t == nil { t = defaultTypeOf(xt) } @@ -2479,11 +2417,14 @@ func checkOrConvertType(store Store, last BlockNode, x *Expr, t Type, autoNative // default: } } + // convert x to destination type t cx := Expr(Call(constType(nil, t), *x)) cx = Preprocess(store, last, cx).(Expr) *x = cx - } else { // covert if one side is declared type and the other side is + } else { + //if one side is declared name type and the other side is unnamed type if isNamedConversion(xt, t) { + // covert right (xt) to the type of the left (t) cx := Expr(Call(constType(nil, t), *x)) cx = Preprocess(store, last, cx).(Expr) *x = cx diff --git a/gnovm/pkg/gnolang/transcribe.go b/gnovm/pkg/gnolang/transcribe.go index c5b72336c83..94f933c05d1 100644 --- a/gnovm/pkg/gnolang/transcribe.go +++ b/gnovm/pkg/gnolang/transcribe.go @@ -271,7 +271,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc } else { cnn = cnn2.(*FuncLitExpr) } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_FUNCLIT_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break @@ -383,7 +383,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc } else { cnn = cnn2.(*BlockStmt) } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_BLOCK_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break @@ -393,7 +393,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc } case *BranchStmt: case *DeclStmt: - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_DECL_BODY, idx, cnn.Body[idx], &c).(SimpleDeclStmt) if isBreak(c) { break @@ -438,7 +438,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc return } } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_FOR_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break @@ -488,7 +488,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc } else { cnn = cnn2.(*IfCaseStmt) } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_IF_CASE_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break @@ -525,7 +525,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc return } } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_RANGE_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break @@ -565,7 +565,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc if isStopOrSkip(nc, c) { return } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_SELECTCASE_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break @@ -640,7 +640,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc return } } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_SWITCHCASE_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break @@ -666,7 +666,7 @@ func transcribe(t Transform, ns []Node, ftype TransField, index int, n Node, nc } else { cnn = cnn2.(*FuncDecl) } - for idx := range cnn.Body { + for idx := 0; idx < len(cnn.Body); idx++ { // the len of Body could change when we decompose a statemet to mulitiple statments. cnn.Body[idx] = transcribe(t, nns, TRANS_FUNC_BODY, idx, cnn.Body[idx], &c).(Stmt) if isBreak(c) { break diff --git a/gnovm/pkg/gnolang/values_string.go b/gnovm/pkg/gnolang/values_string.go index dda648924ba..855d8f04b37 100644 --- a/gnovm/pkg/gnolang/values_string.go +++ b/gnovm/pkg/gnolang/values_string.go @@ -226,11 +226,29 @@ func (tv *TypedValue) Sprint(m *Machine) string { case *ArrayType: return tv.V.(*ArrayValue).String() case *SliceType: - return tv.V.(*SliceValue).String() + switch sv := tv.V.(type) { + case nil: + return tv.String() + case *SliceValue: + return sv.String() + default: + panic(fmt.Sprintf( + "unexpected slice type %v", + reflect.TypeOf(tv.V))) + } case *StructType: return tv.V.(*StructValue).String() case *MapType: - return tv.V.(*MapValue).String() + switch mv := tv.V.(type) { + case nil: + return tv.String() + case *MapValue: + return mv.String() + default: + panic(fmt.Sprintf( + "unexpected slice type %v", + reflect.TypeOf(tv.V))) + } case *FuncType: switch fv := tv.V.(type) { case nil: diff --git a/gnovm/tests/files/addr0b_stdlibs.gno b/gnovm/tests/files/addr0b_stdlibs.gno index e2848c2321b..2ec6782c7f0 100644 --- a/gnovm/tests/files/addr0b_stdlibs.gno +++ b/gnovm/tests/files/addr0b_stdlibs.gno @@ -20,4 +20,4 @@ func main() { } // Output: -// struct{(struct{( string),( string),(0 int),(0 int),(nil github.com/gnolang/gno/_test/net/http.Header),(undefined),(0 int64),(nil []string),(false bool),( string),(nil github.com/gnolang/gno/_test/net/http.Values),(nil github.com/gnolang/gno/_test/net/http.Values),(nil github.com/gnolang/gno/_test/net/http.Header),( string),( string),(nil *github.com/gnolang/gno/_test/net/http.Response)} github.com/gnolang/gno/_test/net/http.Request),( string)} +// (struct{(struct{( string),( string),(0 int),(0 int),(nil github.com/gnolang/gno/_test/net/http.Header),(undefined),(0 int64),(nil []string),(false bool),( string),(nil github.com/gnolang/gno/_test/net/http.Values),(nil github.com/gnolang/gno/_test/net/http.Values),(nil github.com/gnolang/gno/_test/net/http.Header),( string),( string),(nil *github.com/gnolang/gno/_test/net/http.Response)} github.com/gnolang/gno/_test/net/http.Request),( string)} main.extendedRequest) diff --git a/gnovm/tests/files/assign21.gno b/gnovm/tests/files/assign21.gno index 9d3595e95bd..c24d902c0c0 100644 --- a/gnovm/tests/files/assign21.gno +++ b/gnovm/tests/files/assign21.gno @@ -14,4 +14,4 @@ func main() { } // Output: -// 1 true +// (1 main.thing) true diff --git a/gnovm/tests/files/composite2.gno b/gnovm/tests/files/composite2.gno index 5e8dc6afc1b..e6882e03b8b 100644 --- a/gnovm/tests/files/composite2.gno +++ b/gnovm/tests/files/composite2.gno @@ -9,4 +9,4 @@ func main() { } // Output: -// struct{("hello" string)} +// (struct{("hello" string)} main.T) diff --git a/gnovm/tests/files/composite5.gno b/gnovm/tests/files/composite5.gno index 15c4aa530e7..906f9d4f930 100644 --- a/gnovm/tests/files/composite5.gno +++ b/gnovm/tests/files/composite5.gno @@ -11,4 +11,4 @@ func main() { } // Output: -// struct{(12 uint16)} +// (struct{(12 uint16)} main.T) diff --git a/gnovm/tests/files/composite6.gno b/gnovm/tests/files/composite6.gno index 122665aa9d7..25817cde400 100644 --- a/gnovm/tests/files/composite6.gno +++ b/gnovm/tests/files/composite6.gno @@ -15,4 +15,4 @@ func main() { } // Output: -// struct{(2 uint16)} +// (struct{(2 uint16)} main.T) diff --git a/gnovm/tests/files/const12.gno b/gnovm/tests/files/const12.gno index 84510bf16b5..86dde62eb3d 100644 --- a/gnovm/tests/files/const12.gno +++ b/gnovm/tests/files/const12.gno @@ -14,4 +14,4 @@ func main() { } // Output: -// 0 2 4 6 +// (0 main.Kind) (2 main.Kind) (4 main.Kind) (6 main.Kind) diff --git a/gnovm/tests/files/const15.gno b/gnovm/tests/files/const15.gno index ed55754726c..a2af6c6a849 100644 --- a/gnovm/tests/files/const15.gno +++ b/gnovm/tests/files/const15.gno @@ -14,4 +14,4 @@ func main() { } // Output: -// 3 +// (3 main.T1) diff --git a/gnovm/tests/files/fun6b.gno b/gnovm/tests/files/fun6b.gno index 9ff57036333..17b0473b33b 100644 --- a/gnovm/tests/files/fun6b.gno +++ b/gnovm/tests/files/fun6b.gno @@ -17,4 +17,4 @@ func main() { } // Output: -// struct{(gonative{} gonative{*sync.Pool})} +// (struct{(gonative{} gonative{*sync.Pool})} main.Pool) diff --git a/gnovm/tests/files/fun9.gno b/gnovm/tests/files/fun9.gno index 5b5ec1bfe36..18c49a3a226 100644 --- a/gnovm/tests/files/fun9.gno +++ b/gnovm/tests/files/fun9.gno @@ -9,4 +9,4 @@ func main() { } // Output: -// 1 +// (1 main.myint) diff --git a/gnovm/tests/files/interface39b.gno b/gnovm/tests/files/interface39b.gno index 9a49c0abdef..a87b9ff1d30 100644 --- a/gnovm/tests/files/interface39b.gno +++ b/gnovm/tests/files/interface39b.gno @@ -18,4 +18,4 @@ func main() { } // Output: -// struct{("bar" string)} +// (struct{("bar" string)} main.foo) diff --git a/gnovm/tests/files/map19b.gno b/gnovm/tests/files/map19b.gno index dbbb6876cc6..77361016591 100644 --- a/gnovm/tests/files/map19b.gno +++ b/gnovm/tests/files/map19b.gno @@ -14,4 +14,4 @@ func main() { } // Output: -// struct{(nil map[int64]*main.server)} +// (struct{(nil map[int64]*main.server)} main.cmap) diff --git a/gnovm/tests/files/ptr0.gno b/gnovm/tests/files/ptr0.gno index 2c61280b2ee..dd459e2d29f 100644 --- a/gnovm/tests/files/ptr0.gno +++ b/gnovm/tests/files/ptr0.gno @@ -9,4 +9,4 @@ func main() { } // Output: -// 2 +// (2 main.myint) diff --git a/gnovm/tests/files/ptr7.gno b/gnovm/tests/files/ptr7.gno index 1c6d7ae4040..b8f7fc9cf88 100644 --- a/gnovm/tests/files/ptr7.gno +++ b/gnovm/tests/files/ptr7.gno @@ -23,4 +23,4 @@ func main() { } // Output: -// struct{(nil github.com/gnolang/gno/_test/net.IP),(nil github.com/gnolang/gno/_test/net.IPMask)} +// (struct{(nil github.com/gnolang/gno/_test/net.IP),(nil github.com/gnolang/gno/_test/net.IPMask)} main.ipNetValue) diff --git a/gnovm/tests/files/recurse0.gno b/gnovm/tests/files/recurse0.gno index 2bf8f539f5a..fe5a997b19f 100644 --- a/gnovm/tests/files/recurse0.gno +++ b/gnovm/tests/files/recurse0.gno @@ -33,5 +33,5 @@ func main() { } // Output: -// struct{(nil []main.T),(nil []*main.T),(nil map[string]main.T),(nil map[string]*main.T),(nil chan main.T),(nil chan *main.T),(nil *main.T),(nil func(.arg_0 main.T)( main.T)),(nil func(.arg_0 *main.T)( *main.T)),(struct{(nil []main.T),(nil []*main.T),(nil map[string]main.T),(nil map[string]*main.T),(nil chan main.T),(nil chan *main.T),(nil *main.T),(nil func(.arg_0 main.T)( main.T)),(nil func(.arg_0 *main.T)( *main.T))} main.U)} -// struct{(nil []main.T),(nil []*main.T),(nil map[string]main.T),(nil map[string]*main.T),(nil chan main.T),(nil chan *main.T),(nil *main.T),(nil func(.arg_0 main.T)( main.T)),(nil func(.arg_0 *main.T)( *main.T))} +// (struct{(nil []main.T),(nil []*main.T),(nil map[string]main.T),(nil map[string]*main.T),(nil chan main.T),(nil chan *main.T),(nil *main.T),(nil func(.arg_0 main.T)( main.T)),(nil func(.arg_0 *main.T)( *main.T)),(struct{(nil []main.T),(nil []*main.T),(nil map[string]main.T),(nil map[string]*main.T),(nil chan main.T),(nil chan *main.T),(nil *main.T),(nil func(.arg_0 main.T)( main.T)),(nil func(.arg_0 *main.T)( *main.T))} main.U)} main.T) +// (struct{(nil []main.T),(nil []*main.T),(nil map[string]main.T),(nil map[string]*main.T),(nil chan main.T),(nil chan *main.T),(nil *main.T),(nil func(.arg_0 main.T)( main.T)),(nil func(.arg_0 *main.T)( *main.T))} main.U) diff --git a/gnovm/tests/files/struct28b.gno b/gnovm/tests/files/struct28b.gno index dc61b00bb6f..e426fe490e2 100644 --- a/gnovm/tests/files/struct28b.gno +++ b/gnovm/tests/files/struct28b.gno @@ -14,4 +14,4 @@ func main() { } // Output: -// struct{(struct{(nil *main.T1)} main.T2)} +// (struct{(struct{(nil *main.T1)} main.T2)} main.T1) diff --git a/gnovm/tests/files/struct50b.gno b/gnovm/tests/files/struct50b.gno index 62558c5b69f..212238c5cd7 100644 --- a/gnovm/tests/files/struct50b.gno +++ b/gnovm/tests/files/struct50b.gno @@ -14,5 +14,5 @@ func main() { } // Output: -// struct{("hello" string),(slice[(struct{("world" string),(nil []main.Node)} main.Node)] []main.Node)} -// struct{("hello" string),(slice[(struct{("world" string),(slice[(struct{("sunshine" string),(nil []main.Node)} main.Node)] []main.Node)} main.Node)] []main.Node)} +// (struct{("hello" string),(slice[(struct{("world" string),(nil []main.Node)} main.Node)] []main.Node)} main.Node) +// (struct{("hello" string),(slice[(struct{("world" string),(slice[(struct{("sunshine" string),(nil []main.Node)} main.Node)] []main.Node)} main.Node)] []main.Node)} main.Node) diff --git a/gnovm/tests/files/struct52b.gno b/gnovm/tests/files/struct52b.gno index 167e45d10a6..f1b26641149 100644 --- a/gnovm/tests/files/struct52b.gno +++ b/gnovm/tests/files/struct52b.gno @@ -14,5 +14,5 @@ func main() { } // Output: -// struct{("hello" string),(map{("1" string):(struct{("world" string),(map{} map[string]main.Node)} main.Node)} map[string]main.Node)} -// struct{("hello" string),(map{("1" string):(struct{("world" string),(map{("1" string):(struct{("sunshine" string),(map{} map[string]main.Node)} main.Node)} map[string]main.Node)} main.Node)} map[string]main.Node)} +// (struct{("hello" string),(map{("1" string):(struct{("world" string),(map{} map[string]main.Node)} main.Node)} map[string]main.Node)} main.Node) +// (struct{("hello" string),(map{("1" string):(struct{("world" string),(map{("1" string):(struct{("sunshine" string),(map{} map[string]main.Node)} main.Node)} map[string]main.Node)} main.Node)} map[string]main.Node)} main.Node) diff --git a/gnovm/tests/files/struct53b.gno b/gnovm/tests/files/struct53b.gno index b0f9be2659d..a367b109d30 100644 --- a/gnovm/tests/files/struct53b.gno +++ b/gnovm/tests/files/struct53b.gno @@ -18,4 +18,4 @@ func main() { } // Output: -// struct{(nil *main.T)} +// (struct{(nil *main.T)} main.T2) diff --git a/gnovm/tests/files/type0.gno b/gnovm/tests/files/type0.gno index 739cd711f93..38e385a04d9 100644 --- a/gnovm/tests/files/type0.gno +++ b/gnovm/tests/files/type0.gno @@ -8,4 +8,4 @@ func main() { } // Output: -// 0 +// (0 main.newInt) diff --git a/gnovm/tests/files/zrealm10.gno b/gnovm/tests/files/zrealm10.gno index 12925ddd680..97bb9d439e2 100644 --- a/gnovm/tests/files/zrealm10.gno +++ b/gnovm/tests/files/zrealm10.gno @@ -18,8 +18,8 @@ func main() { } // Output: -// struct{(1 int)} -// struct{(3 int)} +// (struct{(1 int)} gno.land/r/test.MyStruct) +// (struct{(3 int)} gno.land/r/test.MyStruct) // Realm: // switchrealm["gno.land/r/test"] diff --git a/gnovm/tests/files/zrealm11.gno b/gnovm/tests/files/zrealm11.gno index 0f1616db14d..0f4d26a44c0 100644 --- a/gnovm/tests/files/zrealm11.gno +++ b/gnovm/tests/files/zrealm11.gno @@ -18,8 +18,8 @@ func main() { } // Output: -// struct{(1 int)} -// struct{(-1 int)} +// (struct{(1 int)} gno.land/r/test.MyStruct) +// (struct{(-1 int)} gno.land/r/test.MyStruct) // Realm: // switchrealm["gno.land/r/test"] diff --git a/gnovm/tests/files/zrealm8.gno b/gnovm/tests/files/zrealm8.gno index e8ca92c8b69..1452301dac6 100644 --- a/gnovm/tests/files/zrealm8.gno +++ b/gnovm/tests/files/zrealm8.gno @@ -18,8 +18,8 @@ func main() { } // Output: -// struct{(1 int)} -// struct{(2 int)} +// (struct{(1 int)} gno.land/r/test.MyStruct) +// (struct{(2 int)} gno.land/r/test.MyStruct) // Realm: // switchrealm["gno.land/r/test"] diff --git a/gnovm/tests/files/zrealm9.gno b/gnovm/tests/files/zrealm9.gno index 52e2da3565e..306ca02a92a 100644 --- a/gnovm/tests/files/zrealm9.gno +++ b/gnovm/tests/files/zrealm9.gno @@ -18,8 +18,8 @@ func main() { } // Output: -// struct{(1 int)} -// struct{(0 int)} +// (struct{(1 int)} gno.land/r/test.MyStruct) +// (struct{(0 int)} gno.land/r/test.MyStruct) // Realm: // switchrealm["gno.land/r/test"] diff --git a/gnovm/tests/files/zrealm_crossrealm0.gno b/gnovm/tests/files/zrealm_crossrealm0.gno index 053e2258465..5bf34c2c852 100644 --- a/gnovm/tests/files/zrealm_crossrealm0.gno +++ b/gnovm/tests/files/zrealm_crossrealm0.gno @@ -14,4 +14,4 @@ func main() { } // Output: -// struct{("test" string)} +// (struct{("test" string)} gno.land/r/demo/tests.TestRealmObject) diff --git a/gnovm/tests/files/zrealm_crossrealm1.gno b/gnovm/tests/files/zrealm_crossrealm1.gno index 59b2d317b8a..686468b40c7 100644 --- a/gnovm/tests/files/zrealm_crossrealm1.gno +++ b/gnovm/tests/files/zrealm_crossrealm1.gno @@ -17,4 +17,4 @@ func main() { } // Output: -// struct{("test" string)} +// (struct{("test" string)} gno.land/r/demo/tests.TestRealmObject) diff --git a/gnovm/tests/files/zrealm_crossrealm6.gno b/gnovm/tests/files/zrealm_crossrealm6.gno index c17e317f2eb..d2e7a4b096a 100644 --- a/gnovm/tests/files/zrealm_crossrealm6.gno +++ b/gnovm/tests/files/zrealm_crossrealm6.gno @@ -18,4 +18,4 @@ func main() { } // Output: -// struct{("modified" string)} +// (struct{("modified" string)} gno.land/p/demo/tests.TestRealmObject2) diff --git a/gnovm/tests/files/zrealm_std1.gno b/gnovm/tests/files/zrealm_std1.gno index 85391bd26b1..87f75bcb871 100644 --- a/gnovm/tests/files/zrealm_std1.gno +++ b/gnovm/tests/files/zrealm_std1.gno @@ -25,7 +25,7 @@ func main() { } // Output: -// slice[ref(1ed29bd278d735e20e296bd4afe927501941392f:4)] +// (slice[ref(1ed29bd278d735e20e296bd4afe927501941392f:4)] std.AddressList) // error: address already exists // has: true // has: false diff --git a/gnovm/tests/files/zrealm_std2.gno b/gnovm/tests/files/zrealm_std2.gno index 68c09a741d8..1ae1fb4a881 100644 --- a/gnovm/tests/files/zrealm_std2.gno +++ b/gnovm/tests/files/zrealm_std2.gno @@ -26,7 +26,7 @@ func main() { } // Output: -// slice[ref(1ed29bd278d735e20e296bd4afe927501941392f:4)] +// (slice[ref(1ed29bd278d735e20e296bd4afe927501941392f:4)] std.AddressList) // error: address already exists // has: true // has: false diff --git a/gnovm/tests/files/zrealm_tests0.gno b/gnovm/tests/files/zrealm_tests0.gno index 9eaf7fb9a96..6244f391574 100644 --- a/gnovm/tests/files/zrealm_tests0.gno +++ b/gnovm/tests/files/zrealm_tests0.gno @@ -23,7 +23,7 @@ func main() { // Realm: // switchrealm["gno.land/r/demo/tests"] -// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:10]={ +// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:14]={ // "Fields": [ // { // "T": { @@ -37,13 +37,13 @@ func main() { // } // ], // "ObjectInfo": { -// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:10", +// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:14", // "ModTime": "0", -// "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:9", +// "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:13", // "RefCount": "1" // } // } -// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:9]={ +// c[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:13]={ // "Data": null, // "List": [ // { @@ -65,8 +65,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "94c14b2efc4bb2f3c24ee42292f161fd1ebd72a3", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" +// "Hash": "63ef2b51ca911a9b1727588bacb958ec3cb2a392", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:10" // } // } // } @@ -90,8 +90,8 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "1e36da78d1dc72e5cbac56c27590332574c89678", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:8" +// "Hash": "54c554e1d1f61e19feb13bb229f43540338c0f8f", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:12" // } // } // } @@ -115,15 +115,15 @@ func main() { // }, // "V": { // "@type": "/gno.RefValue", -// "Hash": "43b13870b750f78cda919fa13a5d955d297242bd", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:10" +// "Hash": "4e50e2cdaeb022a6fcbdb96d9fbd7f3af8df1379", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:14" // } // } // } // } // ], // "ObjectInfo": { -// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:9", +// "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:13", // "ModTime": "0", // "OwnerID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:2", // "RefCount": "1" @@ -134,8 +134,8 @@ func main() { // "ObjectInfo": { // "ID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:2", // "IsEscaped": true, -// "ModTime": "8", -// "RefCount": "3" +// "ModTime": "12", +// "RefCount": "5" // }, // "Parent": null, // "Source": { @@ -199,6 +199,225 @@ func main() { // "Type": { // "@type": "/gno.DeclaredType", // "Base": { +// "@type": "/gno.PrimitiveType", +// "value": "2048" +// }, +// "Methods": [], +// "Name": "Word", +// "PkgPath": "gno.land/r/demo/tests" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.SliceType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.Word" +// }, +// "Vrd": false +// }, +// "Methods": [ +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "n", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "realm_method38d.gno", +// "IsMethod": true, +// "Name": "Add", +// "PkgPath": "gno.land/r/demo/tests", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "File": "realm_method38d.gno", +// "Line": "5", +// "Nonce": "0", +// "PkgPath": "gno.land/r/demo/tests" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "n", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "n", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": null, +// "FileName": "realm_method38d.gno", +// "IsMethod": true, +// "Name": "Add", +// "PkgPath": "gno.land/r/demo/tests", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "File": "realm_method38d.gno", +// "Line": "5", +// "Nonce": "0", +// "PkgPath": "gno.land/r/demo/tests" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [ +// { +// "Embedded": false, +// "Name": "n", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// } +// } +// } +// ], +// "Name": "nat", +// "PkgPath": "gno.land/r/demo/tests" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { +// "@type": "/gno.StructType", +// "Fields": [ +// { +// "Embedded": false, +// "Name": "neg", +// "Tag": "", +// "Type": { +// "@type": "/gno.PrimitiveType", +// "value": "4" +// } +// }, +// { +// "Embedded": false, +// "Name": "abs", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ], +// "PkgPath": "gno.land/r/demo/tests" +// }, +// "Methods": [], +// "Name": "Int", +// "PkgPath": "gno.land/r/demo/tests" +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.TypeType" +// }, +// "V": { +// "@type": "/gno.TypeValue", +// "Type": { +// "@type": "/gno.DeclaredType", +// "Base": { // "@type": "/gno.StructType", // "Fields": [ // { @@ -505,7 +724,17 @@ func main() { // "T": { // "@type": "/gno.FuncType", // "Params": [], -// "Results": [] +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] // }, // "V": { // "@type": "/gno.FuncValue", @@ -514,6 +743,158 @@ func main() { // "Escaped": true, // "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" // }, +// "FileName": "realm_compositelit.gno", +// "IsMethod": false, +// "Name": "GetZeroType", +// "PkgPath": "gno.land/r/demo/tests", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "File": "realm_compositelit.gno", +// "Line": "17", +// "Nonce": "0", +// "PkgPath": "gno.land/r/demo/tests" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:5" +// }, +// "FileName": "realm_method38d.gno", +// "IsMethod": false, +// "Name": "GetAbs", +// "PkgPath": "gno.land/r/demo/tests", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "File": "realm_method38d.gno", +// "Line": "10", +// "Nonce": "0", +// "PkgPath": "gno.land/r/demo/tests" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:5" +// }, +// "FileName": "realm_method38d.gno", +// "IsMethod": false, +// "Name": "AbsAdd", +// "PkgPath": "gno.land/r/demo/tests", +// "Source": { +// "@type": "/gno.RefNode", +// "BlockNode": null, +// "Location": { +// "File": "realm_method38d.gno", +// "Line": "17", +// "Nonce": "0", +// "PkgPath": "gno.land/r/demo/tests" +// } +// }, +// "Type": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [ +// { +// "Embedded": false, +// "Name": "", +// "Tag": "", +// "Type": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// } +// ] +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.FuncType", +// "Params": [], +// "Results": [] +// }, +// "V": { +// "@type": "/gno.FuncValue", +// "Closure": { +// "@type": "/gno.RefValue", +// "Escaped": true, +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" +// }, // "FileName": "tests.gno", // "IsMethod": false, // "Name": "IncCounter", @@ -556,7 +937,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -610,7 +991,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -654,7 +1035,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -698,7 +1079,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -755,7 +1136,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -802,7 +1183,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -836,7 +1217,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -870,7 +1251,7 @@ func main() { // "Closure": { // "@type": "/gno.RefValue", // "Escaped": true, -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:4" +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:6" // }, // "FileName": "tests.gno", // "IsMethod": false, @@ -906,8 +1287,8 @@ func main() { // "@type": "/gno.SliceValue", // "Base": { // "@type": "/gno.RefValue", -// "Hash": "5e5535af7afef6f523a897c051944639ef56c057", -// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:9" +// "Hash": "5f12a61dd16d828be8584debc0e395e8d2136acb", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:13" // }, // "Length": "3", // "Maxcap": "3", @@ -916,6 +1297,37 @@ func main() { // }, // { // "T": { +// "@type": "/gno.PointerType", +// "Elt": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.Int" +// } +// }, +// "V": { +// "@type": "/gno.PointerValue", +// "Base": null, +// "Index": "0", +// "TV": { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.Int" +// }, +// "V": { +// "@type": "/gno.RefValue", +// "Hash": "90b77781ec2b1e153ac020b1102354174bde972e", +// "ObjectID": "0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:7" +// } +// } +// } +// }, +// { +// "T": { +// "@type": "/gno.RefType", +// "ID": "gno.land/r/demo/tests.nat" +// } +// }, +// { +// "T": { // "@type": "/gno.PrimitiveType", // "value": "32" // } @@ -949,7 +1361,7 @@ func main() { // } // ] // } -// d[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:7] +// d[0ffe7732b4d549b4cf9ec18bd68641cd2c75ad0a:11] // switchrealm["gno.land/r/demo/tests_foo"] // switchrealm["gno.land/r/demo/tests_foo"] // switchrealm["gno.land/r/demo/tests_foo"]