JSInterpPtr js_create_interp (JSInterpOptions *options) { JSInterpPtr interp; JSByteCode *bc; JSInterpOptions default_options; interp = js_calloc (NULL, 1, sizeof (*interp)); if (interp == NULL) return NULL; if (options == NULL) { js_init_default_options (&default_options); options = &default_options; } memcpy (&interp->options, options, sizeof (*options)); /* Create virtual machine. */ interp->vm = js_vm_create (options->stack_size, options->dispatch_method, options->verbose, options->stacktrace_on_error, options->s_stdin, options->s_stdout, options->s_stderr); if (interp->vm == NULL) { js_free (interp); return NULL; } if (!options->no_compiler) { /* Define compiler to the virtual machine. */ bc = js_bc_read_data (js_compiler_bytecode, js_compiler_bytecode_len); js_vm_execute (interp->vm, bc); js_bc_free (bc); } /* Initialize our extensions. */ if (!js_define_module (interp, js_core_globals)) { js_vm_destroy (interp->vm); js_free (interp); return NULL; } /* Ok, we'r done. */ return interp; }
int main(){ JSVirtualMachine *vm; JSByteCode *bc = NULL; beginSerial(9600); vm = js_vm_create(128, 0, 0); //bc = read_eeprom_bytecode(0x00); //bc = js_bc_read_data(_bytecode, _bytecode_size); //init_builtin_digitalio(vm); //int s = js_vm_execute(vm, bc); //js_bc_free(bc); js_vm_destroy(vm); }