MCPcopy
hub / github.com/lmorg/murex / compile

Function compile

lang/interpreter.go:21–199  ·  view source on GitHub ↗
(tree *[]functions.FunctionT, parent *Process)

Source from the content-addressed store, hash-verified

19const ExpressionFunctionName = "expr"
20
21func compile(tree *[]functions.FunctionT, parent *Process) (*[]Process, int) {
22 if parent == nil {
23 panic("nil parent")
24 }
25
26 if tree == nil {
27 panic("nil tree")
28 }
29
30 rm := parent.RunMode
31 if len(*tree) > 0 && (string((*tree)[0].Command) == "runmode" ||
32 string((*tree)[0].Command) == "runmode:") {
33 _, params, err := ParseStatementParameters((*tree)[0].Raw, parent)
34 if err != nil {
35 return nil, ErrUnableToParseParametersInRunmode
36 }
37
38 switch strings.Join(params, " ") {
39
40 // function wide scopes
41
42 case "unsafe function":
43 rm = runmode.FunctionUnsafe
44
45 case "try function":
46 rm = runmode.FunctionTry
47
48 case "trypipe function":
49 rm = runmode.FunctionTryPipe
50
51 case "tryerr function":
52 rm = runmode.FunctionTryErr
53
54 case "trypipeerr function":
55 rm = runmode.FunctionTryPipeErr
56
57 // module wide scopes
58
59 case "unsafe module":
60 rm = runmode.ModuleUnsafe
61 ModuleRunModes[parent.FileRef.Source.Module] = rm
62
63 case "try module":
64 rm = runmode.ModuleTry
65 ModuleRunModes[parent.FileRef.Source.Module] = rm
66
67 case "trypipe module":
68 rm = runmode.ModuleTryPipe
69 ModuleRunModes[parent.FileRef.Source.Module] = rm
70
71 case "tryerr module":
72 rm = runmode.ModuleTryErr
73 ModuleRunModes[parent.FileRef.Source.Module] = rm
74
75 case "trypipeerr module":
76 rm = runmode.ModuleTryPipeErr
77 ModuleRunModes[parent.FileRef.Source.Module] = rm
78

Callers 1

ExecuteMethod · 0.85

Calls 15

NewSystemProcessStructFunction · 0.92
NewStdinFunction · 0.92
NewForkManagementFunction · 0.85
createProcessFunction · 0.85
SetRuneMethod · 0.80
CommandNameMethod · 0.80
MethodMethod · 0.80
LogicAndMethod · 0.80
LogicOrMethod · 0.80
NewChainMethod · 0.80
PipeOutMethod · 0.80
PipeErrMethod · 0.80

Tested by

no test coverage detected