MCPcopy Create free account
hub / github.com/deuill/go-php / context_eval

Function context_eval

engine/context.c:66–94  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64}
65
66void *context_eval(engine_context *context, char *script) {
67 zval str;
68 VALUE_SET_STRING(&str, script);
69
70 // Compile script value.
71 uint32_t compiler_options = CG(compiler_options);
72 CG(compiler_options) = ZEND_COMPILE_DEFAULT_FOR_EVAL;
73 zend_op_array *op = zend_compile_string(&str, "gophp-engine");
74 CG(compiler_options) = compiler_options;
75
76 zval_dtor(&str);
77
78 // Return error if script failed to compile.
79 if (!op) {
80 errno = 1;
81 return NULL;
82 }
83
84 // Attempt to execute compiled string.
85 zval tmp;
86 CONTEXT_EXECUTE(op, &tmp);
87
88 // Allocate result value and copy temporary execution result in.
89 zval *result = malloc(sizeof(zval));
90 value_copy(result, &tmp);
91
92 errno = 0;
93 return result;
94}
95
96void context_bind(engine_context *context, char *name, void *value) {
97 engine_value *v = (engine_value *) value;

Callers

nothing calls this directly

Calls 1

value_copyFunction · 0.85

Tested by

no test coverage detected