MCPcopy Create free account
hub / github.com/crossoverJie/gscript / printArray

Method printArray

internal_function.go:84–109  ·  view source on GitHub ↗

打印数组对象 Person[] p

(value []interface{})

Source from the content-addressed store, hash-verified

82
83// 打印数组对象 Person[] p
84func (v *Visitor) printArray(value []interface{}) []interface{} {
85 if len(value) == 0 {
86 return nil
87 }
88 var retList []interface{}
89 for _, val := range value {
90 switch val.(type) {
91 case *LeftValue:
92 leftValue := val.(*LeftValue).GetValue()
93 switch leftValue.(type) {
94 case *stack.ClassObject:
95 classObject := leftValue.(*stack.ClassObject)
96 var data []interface{}
97 for _, val := range classObject.AllField() {
98 data = append(data, val)
99 }
100 // [[1 a] [1 b]] Person[] list = {p1,p2};
101 retList = append(retList, data)
102 }
103 }
104 }
105 if len(retList) > 0 {
106 return retList
107 }
108 return value
109}
110
111func assertEqual(v *Visitor, ctx *parser.FunctionCallContext) interface{} {
112 paramValues := v.buildParamValues(ctx)

Callers 1

gPrintlnFunction · 0.80

Calls 2

AllFieldMethod · 0.80
GetValueMethod · 0.65

Tested by

no test coverage detected