github.com/tardisgo/tardisgo@v0.0.0-20161119180838-e0dd9a7e46b5/haxe/builtin.go (about) 1 // Copyright 2014 Elliott Stoneham and The TARDIS Go Authors 2 // Use of this source code is governed by an MIT-style 3 // license that can be found in the LICENSE file. 4 5 package haxe 6 7 import "golang.org/x/tools/go/ssa" 8 9 func (l langType) append(args []ssa.Value, errorInfo string) string { 10 source := l.IndirectValue(args[1], errorInfo) 11 if l.LangType(args[1].Type().Underlying(), false, errorInfo) == "String" { 12 source = "Force.toUTF8slice(this._goroutine," + source + ")" // if we have a string, we must convert it to a slice 13 } 14 target := l.IndirectValue(args[0], errorInfo) 15 ret := "Slice.append(" + target + "," + source + ")" 16 //fmt.Printf("APPEND DEBUG: %s - %+v - %s\n", ulSize, args, ret) 17 18 return ret 19 } 20 21 func (l langType) copy(register string, args []ssa.Value, errorInfo string) string { 22 ret := "" 23 if register != "" { 24 ret += register 25 } 26 source := l.IndirectValue(args[1], errorInfo) 27 if l.LangType(args[1].Type().Underlying(), false, errorInfo) == "String" { 28 source = "Force.toUTF8slice(this._goroutine," + source + ")" // if we have a string, we must convert it to a slice 29 } 30 code := "Slice.copy(" + l.IndirectValue(args[0], errorInfo) + "," + source + ")" 31 return ret + code 32 } 33 34 func (l langType) DebugRef(userName string, val interface{}, errorInfo string) string { 35 return `this.setDebugVar("` + userName + `",` + l.IndirectValue(val, errorInfo) + ");" 36 }