about summary refs log tree commit diff stats
path: root/subx
Commit message (Expand)AuthorAgeFilesLines
* 4573Kartik Agaram2018-09-211-1/+1
* 4572Kartik Agaram2018-09-211-1/+3
* 4571Kartik Agaram2018-09-211-66/+74
* 4569Kartik Agaram2018-09-211-2/+2
* 4568Kartik Agaram2018-09-211-2/+7
* 4567 - support automated tests in SubXKartik Agaram2018-09-213-11/+179
* 4566Kartik Agaram2018-09-211-2/+2
* 4565Kartik Agaram2018-09-213-3/+22
* 4564Kartik Agaram2018-09-202-5/+5
* 4563Kartik Agaram2018-09-201-0/+15
* 4562Kartik Agaram2018-09-203-8/+8
* 4561Kartik Agaram2018-09-205-51/+51
* 4560Kartik Agaram2018-09-202-0/+3
* 4559Kartik Agaram2018-09-202-0/+16
* 4558Kartik Agaram2018-09-201-1/+1
* 4557Kartik Agaram2018-09-202-4/+17
* 4556Kartik Agaram2018-09-202-10/+58
* 4555Kartik Agaram2018-09-202-3/+2
* 4554Kartik Agaram2018-09-202-2/+2
* 4553Kartik Agaram2018-09-202-0/+55
* 4552Kartik Agaram2018-09-201-6/+13
* 4551Kartik Agaram2018-09-201-0/+1
* 4550Kartik Agaram2018-09-202-1/+19
* 4548: start of a compiler for a new experimental low-level languageKartik Agaram2018-09-177-0/+148
* 4547Kartik Agaram2018-09-163-3/+3
* 4545Kartik Agaram2018-09-151-34/+0
* 4544Kartik Agaram2018-09-126-55/+96
* 4543Kartik Agaram2018-09-121-6/+31
* 4542Kartik Agaram2018-09-121-2/+2
* 4541Kartik Agaram2018-09-112-3/+2
* 4540Kartik Agaram2018-09-111-2/+2
* 4538Kartik Agaram2018-09-075-16/+16
* 4537Kartik Agaram2018-09-077-41/+97
* 4535 - support for global variable namesKartik Agaram2018-09-017-77/+203
* 4534Kartik Agaram2018-09-011-0/+0
* 4533Kartik Agaram2018-09-012-0/+3
* 4532Kartik Agaram2018-09-012-28/+36
* 4531 - automatically compute segment addressesKartik Agaram2018-09-0114-61/+83
* 4530 - create an apps/ directoryKartik Agaram2018-09-0111-205/+217
* 4529 - move examples to a sub-directoryKartik Agaram2018-09-0121-12/+11
* 4528 - commandline arguments working nativelyKartik Agaram2018-08-313-22/+9
* 4527 - reading commandline argumentsKartik Agaram2018-08-308-14/+166
* 4526Kartik Agaram2018-08-291-1/+1
* 4524Kartik Agaram2018-08-204-6/+6
* 4523 - Give up on pass-through phasesKartik Agaram2018-08-207-269/+4
* 4522Kartik Agaram2018-08-141-3/+3
* 4520 - several syscalls for filesKartik Agaram2018-08-134-0/+180
* 4519Kartik Agaram2018-08-131-5/+5
* 4518Kartik Agaram2018-08-131-3/+24
* 4517Kartik Agaram2018-08-132-2/+3
; ++i) { const instruction& inst = get(Recipe, r).steps.at(i); if (!inst.is_label) continue; if (is_jump_target(inst.label)) { if (!contains_key(offset, inst.label)) { put(offset, inst.label, i); } else { raise << maybe(get(Recipe, r).name) << "duplicate label '" << inst.label << "'" << end(); // have all jumps skip some random but noticeable and deterministic amount of code put(offset, inst.label, 9999); } } } for (int i = 0; i < SIZE(get(Recipe, r).steps); ++i) { instruction& inst = get(Recipe, r).steps.at(i); if (inst.name == "jump") { if (inst.ingredients.empty()) { raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' expects an ingredient but got 0\n" << end(); return; } replace_offset(inst.ingredients.at(0), offset, i, r); } if (inst.name == "jump-if" || inst.name == "jump-unless") { if (SIZE(inst.ingredients) < 2) { raise << maybe(get(Recipe, r).name) << "'" << to_original_string(inst) << "' expects 2 ingredients but got " << SIZE(inst.ingredients) << '\n' << end(); return; } replace_offset(inst.ingredients.at(1), offset, i, r); } if ((inst.name == "loop" || inst.name == "break") && SIZE(inst.ingredients) >= 1) { replace_offset(inst.ingredients.at(0), offset, i, r); } if ((inst.name == "loop-if" || inst.name == "loop-unless" || inst.name == "break-if" || inst.name == "break-unless") && SIZE(inst.ingredients) >= 2) { replace_offset(inst.ingredients.at(1), offset, i, r); } } } void replace_offset(reagent& x, /*const*/ map<string, int>& offset, const int current_offset, const recipe_ordinal r) { if (!is_literal(x)) { raise << maybe(get(Recipe, r).name) << "jump target must be offset or label but is '" << x.original_string << "'\n" << end(); x.set_value(0); // no jump by default return; } if (x.initialized) return; if (is_integer(x.name)) return; // non-labels will be handled like other number operands if (!is_jump_target(x.name)) { raise << maybe(get(Recipe, r).name) << "can't jump to label '" << x.name << "'\n" << end(); x.set_value(0); // no jump by default return; } if (!contains_key(offset, x.name)) { raise << maybe(get(Recipe, r).name) << "can't find label '" << x.name << "'\n" << end(); x.set_value(0); // no jump by default return; } x.set_value(get(offset, x.name) - current_offset); } :(scenario break_to_label) def main [ { { break +target:label 1:num <- copy 0 } } +target ] -mem: storing 0 in location 1 :(scenario jump_if_to_label) def main [ { { jump-if 1, +target:label 1:num <- copy 0 } } +target ] -mem: storing 0 in location 1 :(scenario loop_unless_to_label) def main [ { { loop-unless 0, +target:label # loop/break with a label don't care about braces 1:num <- copy 0 } } +target ] -mem: storing 0 in location 1 :(scenario jump_runs_code_after_label) def main [ # first a few lines of padding to exercise the offset computation 1:num <- copy 0 2:num <- copy 0 3:num <- copy 0 jump +target:label 4:num <- copy 0 +target 5:num <- copy 0 ] +mem: storing 0 in location 5 -mem: storing 0 in location 4 :(scenario jump_fails_without_target) % Hide_errors = true; def main [ jump ] +error: main: 'jump' expects an ingredient but got 0 :(scenario jump_fails_without_target_2) % Hide_errors = true; def main [ jump-if true ] +error: main: 'jump-if true' expects 2 ingredients but got 1 :(scenario recipe_fails_on_duplicate_jump_target) % Hide_errors = true; def main [ +label 1:num <- copy 0 +label 2:num <- copy 0 ] +error: main: duplicate label '+label' :(scenario jump_ignores_nontarget_label) % Hide_errors = true; def main [ # first a few lines of padding to exercise the offset computation 1:num <- copy 0 2:num <- copy 0 3:num <- copy 0 jump $target:label 4:num <- copy 0 $target 5:num <- copy 0 ] +error: main: can't jump to label '$target'