Browse Source

checking return codes for sen_compile_program* functions

tags/v3.c-vm
Inderjit Gill 1 year ago
parent
commit
bc85457e05
15 changed files with 207 additions and 82 deletions
  1. +1
    -0
      .gitignore
  2. +38
    -9
      client/src/wasm.c
  3. +21
    -7
      client/www/package-lock.json
  4. +2
    -1
      client/www/src/job.js
  5. +7
    -2
      client/www/src/store.js
  6. +15
    -12
      client/www/src/worker.js
  7. +4
    -0
      core/dist/.gitignore
  8. +52
    -25
      core/src/seni/lib.c
  9. +10
    -6
      core/src/seni/lib.h
  10. +2
    -1
      core/src/seni/result_functions.c
  11. +2
    -1
      core/src/seni/types.h
  12. +21
    -8
      core/src/test.c
  13. +8
    -3
      core/test_win.bat
  14. +10
    -5
      docs/api.org
  15. +14
    -2
      native/src/native.c

+ 1
- 0
.gitignore View File

@@ -24,6 +24,7 @@ pids
# Dependency directory
/core/node_modules
/core/test
/core/test.exe
/client/node_modules
/client/www/node_modules
coverage

+ 38
- 9
client/src/wasm.c View File

@@ -133,17 +133,28 @@ export int compile_to_render_packets(void) {

sen_reset_vm(g_vm);

sen_program* program = NULL;
sen_result_program result_program;

if (g_use_genotype_when_compiling) {
sen_genotype* genotype = sen_deserialize_genotype(g_genotype_cursor);
program = sen_compile_program_with_genotype(g_source_buffer, genotype, g_e->word_lut,
MAX_PROGRAM_SIZE);
result_program = sen_compile_program_with_genotype(g_source_buffer, genotype,
g_e->word_lut, MAX_PROGRAM_SIZE);
genotype_return_to_pool(genotype);

if (is_result_program_error(result_program)) {
SEN_ERROR("compile_to_render_packets");
return 0;
}
} else {
program = sen_compile_program(g_source_buffer, g_e->word_lut, MAX_PROGRAM_SIZE);
result_program = sen_compile_program(g_source_buffer, g_e->word_lut, MAX_PROGRAM_SIZE);
if (is_result_program_error(result_program)) {
SEN_ERROR("compile_to_render_packets");
return 0;
}
}

sen_program* program = result_program.result;

vm_debug_info_reset(g_vm);
bool res = vm_run(g_vm, g_e, program);

@@ -225,11 +236,19 @@ export i32 build_traits() {

// TIMING_UNIT timing_a = get_timing();

sen_trait_list* trait_list = sen_compile_trait_list(g_source_buffer, g_e->word_lut);
bool res = sen_serialize_trait_list(trait_list, g_traits_cursor);
sen_result_trait_list result_trait_list =
sen_compile_trait_list(g_source_buffer, g_e->word_lut);
if (is_result_trait_list_error(result_trait_list)) {
SEN_ERROR("build_traits");
return -1;
}

sen_trait_list* trait_list = result_trait_list.result;

bool res = sen_serialize_trait_list(trait_list, g_traits_cursor);
if (res == false) {
SEN_ERROR("sen_serialize_trait_list returned false");
return 0;
return -1;
}

i32 num_traits = trait_list_count(trait_list);
@@ -420,7 +439,13 @@ export void unparse_with_genotype() {

sen_genotype* genotype = sen_deserialize_genotype(g_genotype_cursor);

sen_unparse_with_genotype(g_out_source_cursor, g_source_buffer, genotype, g_e->word_lut);
sen_error err = sen_unparse_with_genotype(g_out_source_cursor, g_source_buffer, genotype,
g_e->word_lut);
if (is_error(err)) {
SEN_ERROR("unparse_with_genotype: sen_unparse_with_genotype");
genotype_return_to_pool(genotype);
return;
}

genotype_return_to_pool(genotype);

@@ -430,7 +455,11 @@ export void unparse_with_genotype() {
export void simplify_script() {
debug_size_source_buffer();

sen_simplify_script(g_out_source_cursor, g_source_buffer, g_e->word_lut);
sen_error err = sen_simplify_script(g_out_source_cursor, g_source_buffer, g_e->word_lut);

if (is_error(err)) {
SEN_ERROR("simplify_script: sen_simplify_script");
}

debug_size_out_source_buffer();
}

+ 21
- 7
client/www/package-lock.json View File

@@ -3017,12 +3017,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -3037,17 +3039,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -3164,7 +3169,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@@ -3176,6 +3182,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -3190,6 +3197,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -3197,12 +3205,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.2.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.1",
"yallist": "^3.0.0"
@@ -3221,6 +3231,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@@ -3301,7 +3312,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -3313,6 +3325,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@@ -3434,6 +3447,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",

+ 2
- 1
client/www/src/job.js View File

@@ -137,6 +137,7 @@ function request(type, data) {
if (logToConsole) {
console.log(`result ${type} id:${worker.getId()}`);
}
// console.log(`job:request received: ${result}`);
worker.release();
resolve(result);
}).catch(error => {
@@ -144,7 +145,7 @@ function request(type, data) {
worker.release();
}
// handle error
console.error(`worker: error of ${error}`);
console.error(`worker (job:${type}): error of ${error}`);
reject(error);
});
});

+ 7
- 2
client/www/src/store.js View File

@@ -70,8 +70,13 @@ function actionSetScript(state, { script }) {
Job.request(jobBuildTraits, {
script: newState.script,
scriptHash: newState.scriptHash
}).then(({ traits }) => {
newState.traits = traits;
}).then(({ validTraits, traits }) => {
if (validTraits) {
newState.traits = traits;
} else {
newState.traits = [];
}

resolveAsCurrentState(resolve, newState);
}).catch(error => {
// handle error

+ 15
- 12
client/www/src/worker.js View File

@@ -321,7 +321,7 @@ function render({ script /*, scriptHash*/, genotype }) {
const wasmMemory = SeniWasm.instance.memory.buffer;
const memory = wasmMemory.slice();

return [{ ok: true, logMessages }, { title, memory, buffers }];
return [{ logMessages }, { title, memory, buffers }];
}

function unparse({ script/*, scriptHash*/, genotype }) {
@@ -340,7 +340,7 @@ function unparse({ script/*, scriptHash*/, genotype }) {

const logMessages = konsoleProxy.collectMessages();

return [{ ok: true, logMessages }, { script: newScript }];
return [{ logMessages }, { script: newScript }];
}

function buildTraits({ script /*, scriptHash */ }) {
@@ -348,15 +348,18 @@ function buildTraits({ script /*, scriptHash */ }) {

SeniWasm.setString(SeniWasm.source_buffer, script);

// konsoleProxy.log('worker:buildTraits');
const numTraits = SeniWasm.buildTraits();
// konsoleProxy.log(`built ${numTraits} traits`);

const traits = SeniWasm.getString(SeniWasm.traits_buffer);
const validTraits = numTraits === -1;

const logMessages = konsoleProxy.collectMessages();
let traits = [];

if (validTraits) {
traits = SeniWasm.getString(SeniWasm.traits_buffer);
}

return [{ ok: true, logMessages }, { traits }];
const logMessages = konsoleProxy.collectMessages();
return [{ logMessages }, { validTraits, traits }];
}

// transfers the contents of g_genotype_list from the wasm side
@@ -388,7 +391,7 @@ function createInitialGeneration({ populationSize, traits }) {

const logMessages = konsoleProxy.collectMessages();

return [{ok: true, logMessages}, { genotypes }];
return [{ logMessages }, { genotypes }];
}

function singleGenotypeFromSeed({ seed, traits }) {
@@ -404,7 +407,7 @@ function singleGenotypeFromSeed({ seed, traits }) {

const logMessages = konsoleProxy.collectMessages();

return [{ok: true, logMessages}, { genotype: genotypes[0] }];
return [{ logMessages }, { genotype: genotypes[0] }];
}

function simplifyScript({ script }) {
@@ -418,7 +421,7 @@ function simplifyScript({ script }) {

const logMessages = konsoleProxy.collectMessages();

return [{ ok: true, logMessages }, { script: newScript }];
return [{ logMessages }, { script: newScript }];
}

function newGeneration({genotypes, populationSize, traits, mutationRate, rng}) {
@@ -438,7 +441,7 @@ function newGeneration({genotypes, populationSize, traits, mutationRate, rng}) {

const logMessages = konsoleProxy.collectMessages();

return [{ok: true, logMessages }, { genotypes: newGenotypes }];
return [{ logMessages }, { genotypes: newGenotypes }];
}

const options = {
@@ -540,7 +543,6 @@ function messageHandler(type, data) {
postMessage will always return an array of two items: [status, result]

status = {
ok: true
error: { message: "something fucked up" }
systemInitialised: true
logMessages: []
@@ -563,6 +565,7 @@ addEventListener('message', e => {
postMessage([status, result], transferrable);
} else {
const sendData = JSON.stringify([status, result]);
// console.log(`worker.js:sendData = ${sendData}`);
postMessage(sendData);
}
} catch (error) {

+ 4
- 0
core/dist/.gitignore View File

@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

+ 52
- 25
core/src/seni/lib.c View File

@@ -54,9 +54,15 @@ sen_env* sen_allocate_env() {

void sen_free_env(sen_env* env) { env_free(env); }

sen_program* sen_compile_program(char* source, sen_word_lut* word_lut, i32 program_max_size) {
sen_result_program sen_compile_program(char* source, sen_word_lut* word_lut,
i32 program_max_size) {
sen_result_node result_node = parser_parse(word_lut, source);
sen_node* ast = result_node.result;
if (is_result_node_error(result_node)) {
SEN_ERROR("sen_compile_program: parser_parse error");
return result_program_error(result_node.error);
}

sen_node* ast = result_node.result;

// ast_pretty_print(ast, word_lut);

@@ -66,22 +72,25 @@ sen_program* sen_compile_program(char* source, sen_word_lut* word_lut, i32 progr

sen_program* program = program_construct(&compiler_config);
sen_result_program result_program = compile_program(program, ast);
if (is_result_program_error(result_program)) {
SEN_ERROR("sen_compile_program: compile_program");
// todo: return an error here
return NULL;
}
program = result_program.result;

parser_return_nodes_to_pool(ast);

return program;
if (is_result_program_error(result_program)) {
SEN_ERROR("sen_compile_program: compile_program");
}
return result_program;
}

sen_program* sen_compile_program_with_genotype(char* source, sen_genotype* genotype,
sen_word_lut* word_lut, i32 program_max_size) {
sen_result_program sen_compile_program_with_genotype(char* source, sen_genotype* genotype,
sen_word_lut* word_lut,
i32 program_max_size) {
sen_result_node result_node = parser_parse(word_lut, source);
sen_node* ast = result_node.result;
if (is_result_node_error(result_node)) {
SEN_ERROR("sen_compile_program_with_genotype: parser_parse error");
return result_program_error(result_node.error);
}

sen_node* ast = result_node.result;

sen_compiler_config compiler_config;
compiler_config.program_max_size = program_max_size;
@@ -91,21 +100,25 @@ sen_program* sen_compile_program_with_genotype(char* source, sen_genotype* genot

sen_result_program result_program =
compile_program_with_genotype(program, word_lut, ast, genotype);

parser_return_nodes_to_pool(ast);

if (is_result_program_error(result_program)) {
SEN_ERROR("sen_compile_program_with_genotype: compile_program_with_genotype");
// todo: return an error code here
return NULL;
}

parser_return_nodes_to_pool(ast);

return result_program.result;
return result_program;
}

void sen_unparse_with_genotype(sen_cursor* out_cursor, char* source, sen_genotype* genotype,
sen_word_lut* word_lut) {
sen_error sen_unparse_with_genotype(sen_cursor* out_cursor, char* source,
sen_genotype* genotype, sen_word_lut* word_lut) {
sen_result_node result_node = parser_parse(word_lut, source);
sen_node* ast = result_node.result;
if (is_result_node_error(result_node)) {
SEN_ERROR("sen_unparse_with_genotype: parser_parse error");
return result_node.error;
}

sen_node* ast = result_node.result;

cursor_reset(out_cursor);

@@ -114,11 +127,18 @@ void sen_unparse_with_genotype(sen_cursor* out_cursor, char* source, sen_genotyp
cursor_write_null(out_cursor);

parser_return_nodes_to_pool(ast);

return NONE;
}

void sen_simplify_script(sen_cursor* out_cursor, char* source, sen_word_lut* word_lut) {
sen_error sen_simplify_script(sen_cursor* out_cursor, char* source, sen_word_lut* word_lut) {
sen_result_node result_node = parser_parse(word_lut, source);
sen_node* ast = result_node.result;
if (is_result_node_error(result_node)) {
SEN_ERROR("sen_simplify_script: parser_parse error");
return result_node.error;
}

sen_node* ast = result_node.result;

cursor_reset(out_cursor);

@@ -127,6 +147,8 @@ void sen_simplify_script(sen_cursor* out_cursor, char* source, sen_word_lut* wor
cursor_write_null(out_cursor);

parser_return_nodes_to_pool(ast);

return NONE;
}

sen_genotype* sen_deserialize_genotype(sen_cursor* cursor) {
@@ -142,9 +164,14 @@ sen_genotype* sen_deserialize_genotype(sen_cursor* cursor) {
return genotype;
}

sen_trait_list* sen_compile_trait_list(char* source, sen_word_lut* word_lut) {
sen_result_trait_list sen_compile_trait_list(char* source, sen_word_lut* word_lut) {
sen_result_node result_node = parser_parse(word_lut, source);
sen_node* ast = result_node.result;
if (is_result_node_error(result_node)) {
SEN_ERROR("sen_compile_trait_list: parser_parse error");
return result_trait_list_error(result_node.error);
}

sen_node* ast = result_node.result;

sen_compiler_config compiler_config;
compiler_config.program_max_size = MAX_TRAIT_PROGRAM_SIZE;
@@ -154,7 +181,7 @@ sen_trait_list* sen_compile_trait_list(char* source, sen_word_lut* word_lut) {

parser_return_nodes_to_pool(ast);

return trait_list;
return result_trait_list_ok(trait_list);
}

bool sen_serialize_trait_list(sen_trait_list* trait_list, sen_cursor* cursor) {

+ 10
- 6
core/src/seni/lib.h View File

@@ -14,14 +14,18 @@ void sen_reset_vm(sen_vm* vm);
sen_env* sen_allocate_env();
void sen_free_env(sen_env* env);

sen_program* sen_compile_program(char* source, sen_word_lut* word_lut, i32 program_max_size);
sen_program* sen_compile_program_with_genotype(char* source, sen_genotype* genotype,
sen_word_lut* word_lut, i32 program_max_size);
void sen_unparse_with_genotype(sen_cursor* out_cursor, char* source, sen_genotype* genotype,
sen_word_lut* word_lut);
sen_result_program sen_compile_program(char* source, sen_word_lut* word_lut,
i32 program_max_size);
sen_result_program sen_compile_program_with_genotype(char* source, sen_genotype* genotype,
sen_word_lut* word_lut,
i32 program_max_size);
sen_error sen_unparse_with_genotype(sen_cursor* out_cursor, char* source,
sen_genotype* genotype, sen_word_lut* word_lut);

sen_error sen_simplify_script(sen_cursor* out_cursor, char* source, sen_word_lut* word_lut);

sen_genotype* sen_deserialize_genotype(sen_cursor* cursor);

sen_trait_list* sen_compile_trait_list(char* source, sen_word_lut* word_lut);
sen_result_trait_list sen_compile_trait_list(char* source, sen_word_lut* word_lut);
bool sen_serialize_trait_list(sen_trait_list* trait_list, sen_cursor* cursor);
sen_trait_list* sen_deserialize_trait_list(sen_cursor* cursor);

+ 2
- 1
core/src/seni/result_functions.c View File

@@ -4,8 +4,9 @@ RESULT_STRUCT_FUNCTIONS(bool, bool)
RESULT_STRUCT_FUNCTIONS(f32, f32)
RESULT_STRUCT_FUNCTIONS(i32, i32)
RESULT_STRUCT_FUNCTIONS(sen_bytecode*, bytecode)
RESULT_STRUCT_FUNCTIONS(sen_fn_info*, fn_info)
RESULT_STRUCT_FUNCTIONS(sen_node*, node)
RESULT_STRUCT_FUNCTIONS(sen_program*, program)
RESULT_STRUCT_FUNCTIONS(sen_fn_info*, fn_info)
RESULT_STRUCT_FUNCTIONS(sen_trait_list*, trait_list)

OPTION_STRUCT_FUNCTIONS(i32, i32)

+ 2
- 1
core/src/seni/types.h View File

@@ -56,8 +56,9 @@ RESULT_STRUCT(bool, bool)
RESULT_STRUCT(f32, f32)
RESULT_STRUCT(i32, i32)
RESULT_STRUCT(sen_bytecode*, bytecode)
RESULT_STRUCT(sen_fn_info*, fn_info)
RESULT_STRUCT(sen_node*, node)
RESULT_STRUCT(sen_program*, program)
RESULT_STRUCT(sen_fn_info*, fn_info)
RESULT_STRUCT(sen_trait_list*, trait_list)

OPTION_STRUCT(i32, i32)

+ 21
- 8
core/src/test.c View File

@@ -595,9 +595,10 @@ void test_strtof(void) {

#define VM_COMPILE(EXPR) \
sen_systems_startup(); \
sen_env* e = env_allocate(); \
sen_program* prog = sen_compile_program(EXPR, e->word_lut, 256); \
sen_vm* vm = \
sen_env* e = env_allocate(); \
sen_result_program prog_result = sen_compile_program(EXPR, e->word_lut, 256); \
sen_program* prog = prog_result.result; \
sen_vm* vm = \
vm_allocate(STACK_SIZE, HEAP_SIZE, HEAP_MIN_SIZE, VERTEX_PACKET_NUM_VERTICES); \
vm_debug_info_reset(vm); \
vm_run(vm, e, prog)
@@ -1501,7 +1502,10 @@ void vm_compile_f32_with_2_genes(char* expr, int seed, f32 expected_res, f32 exp
sen_env* e = env_allocate();
sen_genotype* genotype = genotype_construct_initial_value(seed, expr);

sen_program* prog = sen_compile_program_with_genotype(expr, genotype, e->word_lut, 256);
sen_result_program prog_result =
sen_compile_program_with_genotype(expr, genotype, e->word_lut, 256);
sen_program* prog = prog_result.result;

sen_vm* vm = vm_allocate(STACK_SIZE, HEAP_SIZE, HEAP_MIN_SIZE, VERTEX_PACKET_NUM_VERTICES);

TEST_ASSERT(genotype);
@@ -1534,7 +1538,10 @@ void vm_compile_f32_with_3_genes(char* expr, int seed, f32 expected_res, f32 exp
sen_env* e = env_allocate();
sen_genotype* genotype = genotype_construct_initial_value(seed, expr);

sen_program* prog = sen_compile_program_with_genotype(expr, genotype, e->word_lut, 256);
sen_result_program prog_result =
sen_compile_program_with_genotype(expr, genotype, e->word_lut, 256);
sen_program* prog = prog_result.result;

sen_vm* vm = vm_allocate(STACK_SIZE, HEAP_SIZE, HEAP_MIN_SIZE, VERTEX_PACKET_NUM_VERTICES);

TEST_ASSERT(genotype);
@@ -1572,7 +1579,10 @@ void vm_compile_f32_with_4_genes(char* expr, int seed, f32 expected_res, f32 exp
sen_env* e = env_allocate();
sen_genotype* genotype = genotype_construct_initial_value(seed, expr);

sen_program* prog = sen_compile_program_with_genotype(expr, genotype, e->word_lut, 256);
sen_result_program prog_result =
sen_compile_program_with_genotype(expr, genotype, e->word_lut, 256);
sen_program* prog = prog_result.result;

sen_vm* vm = vm_allocate(STACK_SIZE, HEAP_SIZE, HEAP_MIN_SIZE, VERTEX_PACKET_NUM_VERTICES);

TEST_ASSERT(genotype);
@@ -1939,8 +1949,10 @@ void test_serialization(void) {
void test_serialization_program(void) {
parser_subsystem_startup();

sen_env* env = env_allocate();
sen_program* program = sen_compile_program("(gen/int min: 2 max: 6)", env->word_lut, 256);
sen_env* env = env_allocate();
sen_result_program prog_result =
sen_compile_program("(gen/int min: 2 max: 6)", env->word_lut, 256);
sen_program* program = prog_result.result;

i32 buffer_size = 4096;
char* buffer = (char*)calloc(buffer_size, sizeof(char));
@@ -2252,6 +2264,7 @@ int main(void) {
RUN_TEST(test_macro_pool);
RUN_TEST(test_mathutil);
RUN_TEST(test_parser);
RUN_TEST(test_parser_failures);
RUN_TEST(test_uv_mapper);
RUN_TEST(test_colour);
RUN_TEST(test_strtof);

+ 8
- 3
core/test_win.bat View File

@@ -2,10 +2,15 @@

setlocal EnableDelayedExpansion


pushd dist

rem cl can expand wildcards
set test_sources=src\test.c ..\core\src\lib\unity\unity.c ..\core\src\seni\*.c
set test_sources=..\src\test.c ..\..\core\src\lib\unity\unity.c ..\..\core\src\seni\*.c

rem https://docs.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-alphabetically
cl /nologo /W4 /wd4146 /wd4127 /wd4001 -Zi -Za /D_CRT_SECURE_NO_DEPRECATE /DSENI_BUILD_WINDOWS /TC !test_sources! /link /OUT:test.exe /I ..\core.src
cl /I ..\..\core.src /nologo /W4 /wd4146 /wd4127 /wd4001 -Zi -Za /D_CRT_SECURE_NO_DEPRECATE /DSENI_BUILD_WINDOWS /TC !test_sources! /link /OUT:test.exe

popd

.\test.exe
.\dist\test.exe

+ 10
- 5
docs/api.org View File

@@ -18,11 +18,16 @@

* functions
** keywords
| name | description |
|-------+-------------|
| [[loop]] | |
| [[fence]] | |
| [[nth]] | |
| name | description |
|------------+-------------|
| [[loop]] | |
| [[fence]] | |
| [[nth]] | |
| address-of | |
| fn-call | |
| define | |
| fn | |
| | |

** misc


+ 14
- 2
native/src/native.c View File

@@ -90,7 +90,13 @@ void execute_source(char* source) {
//
TIMING_UNIT compilation_start = get_timing();

sen_program* program = sen_compile_program(source, env->word_lut, MAX_PROGRAM_SIZE);
sen_program_result program_result =
sen_compile_program(source, env->word_lut, MAX_PROGRAM_SIZE);
if (is_result_program_error(result_program)) {
SEN_ERROR("execute_source");
return;
}
sen_program* program = program_result.result;

TIMING_UNIT compilation_stop = get_timing();

@@ -236,7 +242,13 @@ void print_compiled_program(char* source) {
sen_env* e = sen_allocate_env();

// compile program
sen_program* program = sen_compile_program(source, e->word_lut, MAX_PROGRAM_SIZE);
sen_program_result program_result =
sen_compile_program(source, e->word_lut, MAX_PROGRAM_SIZE);
if (is_result_program_error(result_program)) {
SEN_ERROR("print_compiled_program");
return;
}
sen_program* program = program_result.result;

// print
printf("%s\n", source);

Loading…
Cancel
Save