// 1 "runtime/parser.j" // 1 "" // 1 "" // 31 "" // 1 "/usr/include/stdc-predef.h" 1 3 4 // 32 "" 2 // 1 "runtime/parser.j" globals constant integer JHCR_Parser_OpWidth = 2 constant integer JHCR_Parser_TypeWidth = 3 constant integer JHCR_Parser_RegWidth = 9 constant integer JHCR_Parser_LabelWidth = 6 integer JHCR_Parser_S = 0 integer JHCR_Parser_current_fn = 0 integer JHCR_Parser_prev_ins = 0 integer array JHCR_Parser_fn_labels integer array JHCR_Parser_fn_entry endglobals function JHCR_Parser_parse_ins takes string JHCR_Parser_s returns integer local integer JHCR_Parser_ins = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S, JHCR_Parser_S+2)) local integer JHCR_Parser_new = JHCR_Ins_alloc() local integer JHCR_Parser_b set JHCR_Ins_op[JHCR_Parser_new] = JHCR_Parser_ins set JHCR_Ins_next[JHCR_Parser_new] = 0 if JHCR_Parser_ins <= JHCR_Ins_GetGlobalArray then set JHCR_Ins_type[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+ 5)) set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+5, JHCR_Parser_S+14)) set JHCR_Ins_a2[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+14, JHCR_Parser_S+23)) set JHCR_Ins_a3[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+23, JHCR_Parser_S+32)) set JHCR_Parser_S = JHCR_Parser_S + 32 elseif JHCR_Parser_ins <= JHCR_Ins_Bind then set JHCR_Ins_type[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+ 5)) set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+5, JHCR_Parser_S+14)) set JHCR_Ins_a2[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+14, JHCR_Parser_S+23)) set JHCR_Parser_S = JHCR_Parser_S + 23 elseif JHCR_Parser_ins == JHCR_Ins_Lit then set JHCR_Ins_type[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+ 5)) set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+5, JHCR_Parser_S+14)) set JHCR_Parser_b = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+14, JHCR_Parser_S+20)) if JHCR_Ins_type[JHCR_Parser_new] == JHCR_Types_string then set JHCR_Ins_string[JHCR_Parser_new] = SubString(JHCR_Parser_s, JHCR_Parser_S+20, JHCR_Parser_S+20+JHCR_Parser_b) elseif JHCR_Ins_type[JHCR_Parser_new] == JHCR_Types_integer then set JHCR_Ins_integer[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+20, JHCR_Parser_S+20+JHCR_Parser_b)) elseif JHCR_Ins_type[JHCR_Parser_new] == JHCR_Types_real then set JHCR_Ins_real[JHCR_Parser_new] = S2R(SubString(JHCR_Parser_s, JHCR_Parser_S+20, JHCR_Parser_S+20+JHCR_Parser_b)) elseif JHCR_Ins_type[JHCR_Parser_new] == JHCR_Types_boolean then set JHCR_Ins_boolean[JHCR_Parser_new] = SubString(JHCR_Parser_s, JHCR_Parser_S+20, JHCR_Parser_S+20+JHCR_Parser_b)=="true" endif set JHCR_Parser_S = JHCR_Parser_S + 20 + JHCR_Parser_b elseif JHCR_Parser_ins == JHCR_Ins_Call then set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+11)) set JHCR_Ins_a2[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+11, JHCR_Parser_S+17)) set JHCR_Parser_S = JHCR_Parser_S + 17 elseif JHCR_Parser_ins == JHCR_Ins_Convert then set JHCR_Ins_type[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+ 5)) set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+5, JHCR_Parser_S+14)) set JHCR_Ins_a2[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+14, JHCR_Parser_S+17)) set JHCR_Ins_a3[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+17, JHCR_Parser_S+26)) set JHCR_Parser_S = JHCR_Parser_S + 26 elseif JHCR_Parser_ins == JHCR_Ins_Label then set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+8)) set JHCR_Parser_S = JHCR_Parser_S + 8 elseif JHCR_Parser_ins == JHCR_Ins_Jmp then set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+8)) set JHCR_Parser_S = JHCR_Parser_S + 8 elseif JHCR_Parser_ins == JHCR_Ins_Fun then set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+8)) if JHCR_Ins_a1[JHCR_Parser_new] < 0 then set JHCR_Parser_b = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+8, JHCR_Parser_S+14)) set JHCR_Ins_string[JHCR_Parser_new] = SubString(JHCR_Parser_s, JHCR_Parser_S+14, JHCR_Parser_S+14 +JHCR_Parser_b) set JHCR_Parser_S = JHCR_Parser_S + 14 + JHCR_Parser_b else set JHCR_Parser_S = JHCR_Parser_S + 8 endif elseif JHCR_Parser_ins == JHCR_Ins_JmpT then set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+8)) set JHCR_Ins_a2[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+8, JHCR_Parser_S+17)) set JHCR_Parser_S = JHCR_Parser_S + 17 elseif JHCR_Parser_ins == JHCR_Ins_Not then set JHCR_Ins_a1[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+11)) set JHCR_Ins_a2[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+11, JHCR_Parser_S+20)) set JHCR_Parser_S = JHCR_Parser_S + 20 elseif JHCR_Parser_ins == JHCR_Ins_Ret then set JHCR_Ins_type[JHCR_Parser_new] = S2I(SubString(JHCR_Parser_s, JHCR_Parser_S+2, JHCR_Parser_S+ 5)) set JHCR_Parser_S = JHCR_Parser_S + 5 endif return JHCR_Parser_new endfunction function JHCR_Parser_parse_and_print takes string JHCR_Parser_instruction returns nothing local integer JHCR_Parser_len = StringLength(JHCR_Parser_instruction) local integer JHCR_Parser_ins set JHCR_Parser_S = 0 loop exitwhen JHCR_Parser_S >= JHCR_Parser_len set JHCR_Parser_ins = JHCR_Parser_parse_ins(JHCR_Parser_instruction) call JHCR_Ins_print(JHCR_Parser_ins) endloop endfunction function JHCR_Parser_parse_and_init takes string JHCR_Parser_instruction returns nothing local integer JHCR_Parser_len = StringLength(JHCR_Parser_instruction) local integer JHCR_Parser_ins set JHCR_Parser_S = 0 loop exitwhen JHCR_Parser_S >= JHCR_Parser_len set JHCR_Parser_ins = JHCR_Parser_parse_ins(JHCR_Parser_instruction) if JHCR_Ins_op[JHCR_Parser_ins] == JHCR_Ins_Fun then set JHCR_Parser_current_fn = JHCR_Ins_a1[JHCR_Parser_ins] if JHCR_Parser_fn_labels[JHCR_Parser_current_fn + 100] == 0 then set JHCR_Parser_fn_labels[JHCR_Parser_current_fn + 100] = JHCR_Table_alloc() endif if JHCR_Parser_fn_entry[JHCR_Parser_current_fn + 100] != 0 then call JHCR_Ins_destroy(JHCR_Parser_fn_entry[JHCR_Parser_current_fn + 100]) endif set JHCR_Parser_fn_entry[JHCR_Parser_current_fn + 100] = JHCR_Parser_ins if JHCR_Parser_current_fn < 0 then call JHCR_StringTable_set(JHCR_Wrap_name2id, JHCR_Ins_string[JHCR_Parser_ins], JHCR_Parser_current_fn) endif call JHCR_Modified_set_modified(JHCR_Parser_current_fn) set JHCR_Parser_prev_ins = 0 elseif JHCR_Ins_op[JHCR_Parser_ins] == JHCR_Ins_Label then call JHCR_Table_set_integer(JHCR_Parser_fn_labels[JHCR_Parser_current_fn + 100], JHCR_Ins_a1[JHCR_Parser_ins], JHCR_Parser_ins) endif if JHCR_Parser_prev_ins != 0 then set JHCR_Ins_next[JHCR_Parser_prev_ins] = JHCR_Parser_ins endif set JHCR_Parser_prev_ins = JHCR_Parser_ins endloop endfunction function JHCR_Parser_parse_globals takes string JHCR_Parser_instruction, integer JHCR_Parser_entry returns integer local integer JHCR_Parser_len = StringLength(JHCR_Parser_instruction) local integer JHCR_Parser_ins set JHCR_Parser_S = 0 loop exitwhen JHCR_Parser_S >= JHCR_Parser_len set JHCR_Parser_ins = JHCR_Parser_parse_ins(JHCR_Parser_instruction) if JHCR_Parser_entry == 0 then set JHCR_Parser_entry = JHCR_Parser_ins endif if JHCR_Parser_prev_ins != 0 then set JHCR_Ins_next[JHCR_Parser_prev_ins] = JHCR_Parser_ins endif set JHCR_Parser_prev_ins = JHCR_Parser_ins endloop return JHCR_Parser_entry endfunction