This commit is contained in:
parent
0db420aae4
commit
7245af0438
5 changed files with 35 additions and 30 deletions
|
|
@ -55,7 +55,7 @@ func (v ValueType) String() string {
|
|||
}
|
||||
|
||||
// GoToValue convert go values to anglais VM-values. Works for some values (nil, bool, float64, int, string, slices, maps)
|
||||
func GoToValue(gov interface{}) Value {
|
||||
func GoToValue(gov any) Value {
|
||||
switch v := gov.(type) {
|
||||
case nil:
|
||||
return &NilValue{}
|
||||
|
|
@ -79,7 +79,7 @@ func GoToValue(gov interface{}) Value {
|
|||
return &StringValue{
|
||||
v,
|
||||
}
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
values := map[string]Value{}
|
||||
for key, value := range v {
|
||||
values[key] = GoToValue(value)
|
||||
|
|
@ -447,16 +447,17 @@ func (v *ListValue) Type() ValueType {
|
|||
}
|
||||
|
||||
func (v *ListValue) String() string {
|
||||
out := "["
|
||||
var out strings.Builder
|
||||
out.WriteString("[")
|
||||
for i, item := range v.Items {
|
||||
if i != 0 {
|
||||
out += ", "
|
||||
out.WriteString(", ")
|
||||
}
|
||||
out += item.DebugString()
|
||||
out.WriteString(item.DebugString())
|
||||
}
|
||||
out += "]"
|
||||
out.WriteString("]")
|
||||
|
||||
return out
|
||||
return out.String()
|
||||
}
|
||||
|
||||
func (v *ListValue) DebugString() string {
|
||||
|
|
@ -613,20 +614,21 @@ func (v *TupleValue) Type() ValueType {
|
|||
}
|
||||
|
||||
func (v *TupleValue) String() string {
|
||||
out := "("
|
||||
var out strings.Builder
|
||||
out.WriteString("(")
|
||||
for i, item := range v.Items {
|
||||
if i != 0 {
|
||||
out += ", "
|
||||
out.WriteString(", ")
|
||||
}
|
||||
out += item.DebugString()
|
||||
out.WriteString(item.DebugString())
|
||||
}
|
||||
|
||||
if len(v.Items) <= 1 {
|
||||
out += ","
|
||||
out.WriteString(",")
|
||||
}
|
||||
out += ")"
|
||||
out.WriteString(")")
|
||||
|
||||
return out
|
||||
return out.String()
|
||||
}
|
||||
|
||||
func (v *TupleValue) DebugString() string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue