mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
impliment do wraps
This commit is contained in:
59
src/jumpStatments.go
Normal file
59
src/jumpStatments.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package main
|
||||
|
||||
import "strings"
|
||||
|
||||
var returnCompile = makeRegex(`( *)return( +)(.|\n)+`)
|
||||
|
||||
type CallJumpStatment struct {
|
||||
TYPE string
|
||||
value any
|
||||
line int
|
||||
code string
|
||||
path string
|
||||
}
|
||||
|
||||
type PassBackJumpStatment struct {
|
||||
TYPE string
|
||||
value any
|
||||
line int
|
||||
code string
|
||||
path string
|
||||
}
|
||||
|
||||
func isReturn(code UNPARSEcode) bool {
|
||||
return returnCompile.MatchString(code.code)
|
||||
}
|
||||
|
||||
func parseReturn(code UNPARSEcode, index int, codeline []UNPARSEcode) (CallJumpStatment, bool, ArErr, int) {
|
||||
resp, worked, err, i := translateVal(UNPARSEcode{
|
||||
code: strings.TrimSpace(code.code)[6:],
|
||||
realcode: code.realcode,
|
||||
line: code.line,
|
||||
path: code.path,
|
||||
}, index, codeline, 0)
|
||||
return CallJumpStatment{
|
||||
TYPE: "return",
|
||||
value: resp,
|
||||
line: code.line,
|
||||
code: code.realcode,
|
||||
path: code.path,
|
||||
}, worked, err, i
|
||||
}
|
||||
|
||||
func runJumpStatment(code CallJumpStatment, stack stack) (any, ArErr) {
|
||||
var val any
|
||||
if code.value != nil {
|
||||
v, err := runVal(code.value, stack)
|
||||
if err.EXISTS {
|
||||
return nil, err
|
||||
}
|
||||
val = v
|
||||
}
|
||||
return PassBackJumpStatment{
|
||||
TYPE: code.TYPE,
|
||||
value: val,
|
||||
line: code.line,
|
||||
code: code.code,
|
||||
path: code.path,
|
||||
}, ArErr{}
|
||||
}
|
||||
Reference in New Issue
Block a user