| 64 | } |
| 65 | |
| 66 | void *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 | |
| 96 | void context_bind(engine_context *context, char *name, void *value) { |
| 97 | engine_value *v = (engine_value *) value; |
nothing calls this directly
no test coverage detected