MCPcopy Create free account
hub / github.com/evilsocket/sum / compile

Function compile

service/compiler.go:48–68  ·  view source on GitHub ↗

Compiles a raw oracle.

(oracle *pb.Oracle)

Source from the content-addressed store, hash-verified

46
47// Compiles a raw oracle.
48func compile(oracle *pb.Oracle) (*compiled, error) {
49 callString, args, err := validate(oracle)
50 if err != nil {
51 return nil, err
52 }
53 // create the vm and define the oracle function
54 vm := otto.New()
55 if _, err := vm.Run(oracle.Code); err != nil {
56 return nil, err
57 }
58 // use the vm to precompile the function call
59 call, _ := vm.Compile("", callString)
60 // done ^_^
61 return &compiled{
62 oracle: oracle,
63 pool: CreateExecutionPool(vm),
64 args: args,
65 argc: len(args),
66 call: call,
67 }, nil
68}

Callers 9

NewFunction · 0.85
TestServiceCompiledIsFunction · 0.85
TestServiceCompiledIsNotFunction · 0.85
TestServiceCompilerFunction · 0.85
BenchmarkCompileFunction · 0.85
BenchmarkCompiledIsFunction · 0.85
benchVMFunction · 0.85
CreateOracleMethod · 0.85
UpdateOracleMethod · 0.85

Calls 3

validateFunction · 0.85
CreateExecutionPoolFunction · 0.85
RunMethod · 0.65

Tested by 6

TestServiceCompiledIsFunction · 0.68
TestServiceCompiledIsNotFunction · 0.68
TestServiceCompilerFunction · 0.68
BenchmarkCompileFunction · 0.68
BenchmarkCompiledIsFunction · 0.68
benchVMFunction · 0.68