summary refs log tree commit diff stats
path: root/lib
Commit message (Expand)AuthorAgeFilesLines
...
* Fix "Add Wider Ascii Chars sets and func for string formatting" (#20120)Clay Sweetser2022-07-311-3/+3
* Add Wider Ascii Chars sets and func for string formatting (#19994)Sultan Al Isaiee2022-07-311-12/+25
* [ORC] replace threadpool with createThread in the runnableExamples (#20106)ringabout2022-07-311-9/+16
* replace the broken link for ORC implementation with a working one (#20105)ringabout2022-07-311-1/+1
* Highlight Nim default in Markdown code in .nim (#20110)Andrey Makarov2022-07-312-11/+16
* remove shallowCopy for ARC/ORC (#20070)ringabout2022-07-263-20/+34
* fixes #20089; remove setPointer since strings/seqs are not pointers with ORC ...ringabout2022-07-261-2/+8
* .forbids pragma: defining forbidden tags (#20050)Lancer112112022-07-261-0/+9
* Markdown code blocks part 2; migrate Nim Manual (#20080)Andrey Makarov2022-07-251-24/+30
* fix #20067, fix #18976 [backport] (#20069)metagn2022-07-221-1/+3
* replace shallowcopy with move in ARC/ORC (#20061)flywind2022-07-181-6/+6
* Improve rand(bool) (#20045)Antonis Geralis2022-07-181-2/+4
* epoll: correct mapping [backport] (#20058)Jacek Sieka2022-07-181-5/+14
* Fixed typo in std/os doc (#20054)LetThereBeLemons2022-07-181-1/+1
* fix `pthread_mutex_t` size (#20055)Jacek Sieka2022-07-181-1/+1
* Display protocol name in exceptions raised by getProtoByName() (#19808)kraptor2022-07-161-1/+1
* Make `random.rand` work with `Ordinal` (#20043)Amjad Ben Hedhili2022-07-161-6/+9
* make AsyncSocket.getPeerAddr work ; fix #15022 (#20038)David Krause2022-07-161-0/+2
* Improve Markdown code blocks & start moving docs to Markdown style (#19954)Andrey Makarov2022-07-152-36/+119
* [Orc] fixes "streams.readDataStr segafaults" when accepting a string literal...flywind2022-07-151-0/+5
* fixes #20015; document `shallowCopy` does a deep copy with ARC/ORC (#20025)flywind2022-07-141-0/+2
* Add sink and lent annotations to the critbits module (#20021)silent-observer2022-07-141-8/+8
* Fixes Compilation error with --app:lib (#19965)Juan M Gómez2022-07-101-1/+1
* sysrand: fix syscall signature [backport] (#19982)Jacek Sieka2022-07-071-4/+3
* Fixes return values of execCmd on macos (#19963)Daniel Clarke2022-07-051-1/+1
* Fixing `nimRawSetJmp` for vcc and clangcl on Windows (#19959)rockcavera2022-07-041-17/+21
* jsffi add missing braces (#19948)Juan Carlos2022-06-301-10/+10
* Fix jsre (#19917)Juan Carlos2022-06-281-3/+5
* fix typo in nre.nim (#19915)flintforge2022-06-211-2/+1
* Fix nimRawSetjmp for VCC [backport: 1.2] (#19899)Tanguy2022-06-201-1/+1
* Better range error messages (#19867)Tanguy2022-06-151-0/+3
* Windows: enable nimRawSetjmp by default [backport] (#19891)Tanguy2022-06-141-0/+7
* Correctly import libcrypto functions using dynlib (#19881)Ardek Romak2022-06-131-35/+37
* Pass headers and body correctly to FetchOptions (#19884) [backport]Jake Leahy2022-06-131-2/+3
* Friendlier error message with solution (#19880)Carlo Capocasa2022-06-111-0/+5
* [js] add testcase for array indexDefect and remove todo (#19838)flywind2022-06-101-4/+0
* remove noop option `gc:v2` (#19810)flywind2022-06-101-12/+2
* fix #19862; make widestrs consistent between refc and orc (#19874) [backport]flywind2022-06-091-0/+3
* Deprecate std/sums (#18439)Antonis Geralis2022-06-091-0/+2
* Add Microtasks docs (#19870)Juan Carlos2022-06-081-1/+1
* Fix `find` routines' api to default to `last=-1` (#19761)Zoom2022-06-071-41/+50
* Add Microtasks (#19860)Juan Carlos2022-06-041-0/+5
* RST: improve simple tables (#19859)Andrey Makarov2022-06-046-91/+220
* change the type of mangleJsName; fixes CStringConv warnings (#19852)flywind2022-06-011-6/+6
* [Minor] remove unused and unnecessary local variable (#19853)flywind2022-06-011-1/+0
* Zectbumo fixes 19824 (#19825)Alfred Morgan2022-05-301-6/+8
* Add `document.hidden` and `document.visibilityState` properties (#19817)tandy10002022-05-241-0/+2
* Add Array.shift (#19811)Juan Carlos2022-05-241-0/+9
* Fix typo in sequtils documentation (#19789)Anthony Dario2022-05-131-1/+1
* string is missing formatting when calling fmt (#19780)Alfred Morgan2022-05-101-2/+2
g '{' and '}' //: respectively. //: //: Conditional and unconditional 'loop' and 'break' should give us 80% of the //: benefits of the control-flow primitives we're used to in other languages, //: like 'if', 'while', 'for', etc. :(scenarios transform) :(scenario brace_conversion) recipe main [ { break 1:number <- copy 0 } ] +after-brace: recipe main +after-brace: jump 1:offset +after-brace: copy ... //: one-time setup :(after "int main") Transform.push_back(transform_braces); :(code) void transform_braces(const recipe_ordinal r) { const int OPEN = 0, CLOSE = 1; // use signed integer for step index because we'll be doing arithmetic on it list<pair<int/*OPEN/CLOSE*/, /*step*/long long int> > braces; for (long long int index = 0; index < SIZE(Recipe[r].steps); ++index) { const instruction& inst = Recipe[r].steps.at(index); if (inst.label == "{") { trace("brace") << maybe(Recipe[r].name) << "push (open, " << index << ")" << end(); braces.push_back(pair<int,long long int>(OPEN, index)); } if (inst.label == "}") { trace("brace") << "push (close, " << index << ")" << end(); braces.push_back(pair<int,long long int>(CLOSE, index)); } } stack</*step*/long long int> open_braces; trace("after-brace") << "recipe " << Recipe[r].name << end(); for (long long int index = 0; index < SIZE(Recipe[r].steps); ++index) { instruction& inst = Recipe[r].steps.at(index); if (inst.label == "{") { open_braces.push(index); continue; } if (inst.label == "}") { open_braces.pop(); continue; } if (inst.is_label) continue; if (inst.operation != Recipe_ordinal["loop"] && inst.operation != Recipe_ordinal["loop-if"] && inst.operation != Recipe_ordinal["loop-unless"] && inst.operation != Recipe_ordinal["break"] && inst.operation != Recipe_ordinal["break-if"] && inst.operation != Recipe_ordinal["break-unless"]) { trace("after-brace") << inst.name << " ..." << end(); continue; } // check for errors if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) { if (inst.ingredients.empty()) { raise_error << inst.name << " expects 1 or 2 ingredients, but got none\n" << end(); continue; } } // update instruction operation if (inst.name.find("-if") != string::npos) inst.operation = Recipe_ordinal["jump-if"]; else if (inst.name.find("-unless") != string::npos) inst.operation = Recipe_ordinal["jump-unless"]; else inst.operation = Recipe_ordinal["jump"]; // check for explicitly provided targets if (inst.name.find("-if") != string::npos || inst.name.find("-unless") != string::npos) { // conditional branches check arg 1 if (SIZE(inst.ingredients) > 1 && is_literal(inst.ingredients.at(1))) { trace("after-brace") << "jump " << inst.ingredients.at(1).name << ":offset" << end(); continue; } } else { // unconditional branches check arg 0 if (!inst.ingredients.empty() && is_literal(inst.ingredients.at(0))) { trace("after-brace") << "jump " << inst.ingredients.at(0).name << ":offset" << end(); continue; } } // if implicit, compute target reagent target; target.type = new type_tree(Type_ordinal["offset"]); target.set_value(0); if (open_braces.empty()) raise_error << inst.name << " needs a '{' before\n" << end(); else if (inst.name.find("loop") != string::npos) target.set_value(open_braces.top()-index); else // break instruction target.set_value(matching_brace(open_braces.top(), braces, r) - index - 1); inst.ingredients.push_back(target); // log computed target if (inst.name.find("-if") != string::npos) trace("after-brace") << "jump-if " << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); else if (inst.name.find("-unless") != string::npos) trace("after-brace") << "jump-unless " << inst.ingredients.at(0).name << ", " << no_scientific(target.value) << ":offset" << end(); else trace("after-brace") << "jump " << no_scientific(target.value) << ":offset" << end(); } } // returns a signed integer not just so that we can return -1 but also to // enable future signed arithmetic long long int matching_brace(long long int index, const list<pair<int, long long int> >& braces, recipe_ordinal r) { int stacksize = 0; for (list<pair<int, long long int> >::const_iterator p = braces.begin(); p != braces.end(); ++p) { if (p->second < index) continue; stacksize += (p->first ? 1 : -1); if (stacksize == 0) return p->second; } raise_error << maybe(Recipe[r].name) << "unbalanced '{'\n" << end(); return SIZE(Recipe[r].steps); // exit current routine } // temporarily suppress run void transform(string form) { load(form); transform_all(); } //: Make sure these pseudo recipes get consistent numbers in all tests, even //: though they aren't implemented. :(before "End Primitive Recipe Declarations") BREAK, BREAK_IF, BREAK_UNLESS, LOOP, LOOP_IF, LOOP_UNLESS, :(before "End Primitive Recipe Numbers") Recipe_ordinal["break"] = BREAK; Recipe_ordinal["break-if"] = BREAK_IF; Recipe_ordinal["break-unless"] = BREAK_UNLESS; Recipe_ordinal["loop"] = LOOP; Recipe_ordinal["loop-if"] = LOOP_IF; Recipe_ordinal["loop-unless"] = LOOP_UNLESS; :(scenario loop) recipe main [ 1:number <- copy 0 2:number <- copy 0 { 3:number <- copy 0 loop } ] +after-brace: recipe main +after-brace: copy ... +after-brace: copy ... +after-brace: copy ... +after-brace: jump -2:offset :(scenario break_empty_block) recipe main [ 1:number <- copy 0 { break } ] +after-brace: recipe main +after-brace: copy ... +after-brace: jump 0:offset :(scenario break_cascading) recipe main [ 1:number <- copy 0 { break } { break } ] +after-brace: recipe main +after-brace: copy ... +after-brace: jump 0:offset +after-brace: jump 0:offset :(scenario break_cascading_2) recipe main [ 1:number <- copy 0 2:number <- copy 0 { break 3:number <- copy 0 } { break } ] +after-brace: recipe main +after-brace: copy ... +after-brace: copy ... +after-brace: jump 1:offset +after-brace: copy ... +after-brace: jump 0:offset :(scenario break_if) recipe main [ 1:number <- copy 0 2:number <- copy 0 { break-if 2:number 3:number <- copy 0 } { break } ] +after-brace: recipe main +after-brace: copy ... +after-brace: copy ... +after-brace: jump-if 2, 1:offset +after-brace: copy ... +after-brace: jump 0:offset :(scenario break_nested) recipe main [ 1:number <- copy 0 { 2:number <- copy 0 break { 3:number <- copy 0 } 4:number <- copy 0 } ] +after-brace: jump 4:offset :(scenario break_nested_degenerate) recipe main [ 1:number <- copy 0 { 2:number <- copy 0 break { } 4:number <- copy 0 } ] +after-brace: jump 3:offset :(scenario break_nested_degenerate_2) recipe main [ 1:number <- copy 0 { 2:number <- copy 0 break { } } ] +after-brace: jump 2:offset :(scenario break_label) % Hide_errors = true; recipe main [ 1:number <- copy 0 { break +foo:offset } ] +after-brace: jump +foo:offset :(scenario break_unless) recipe main [ 1:number <- copy 0 2:number <- copy 0 { break-unless 2:number 3:number <- copy 0 } ] +after-brace: recipe main +after-brace: copy ... +after-brace: copy ... +after-brace: jump-unless 2, 1:offset +after-brace: copy ... :(scenario loop_unless) recipe main [ 1:number <- copy 0 2:number <- copy 0 { loop-unless 2:number 3:number <- copy 0 } ] +after-brace: recipe main +after-brace: copy ... +after-brace: copy ... +after-brace: jump-unless 2, -1:offset +after-brace: copy ... :(scenario loop_nested) recipe main [ 1:number <- copy 0 { 2:number <- copy 0 { 3:number <- copy 0 } loop-if 4:boolean 5:number <- copy 0 } ] +after-brace: recipe main +after-brace: jump-if 4, -5:offset :(scenario loop_label) recipe main [ 1:number <- copy 0 +foo 2:number <- copy 0 ] +after-brace: recipe main +after-brace: copy ... +after-brace: copy ... //: test how things actually run :(scenarios run) :(scenario brace_conversion_and_run) recipe test-factorial [ 1:number <- copy 5 2:number <- copy 1 { 3:boolean <- equal 1:number, 1 break-if 3:boolean # $print 1:number 2:number <- multiply 2:number, 1:number 1:number <- subtract 1:number, 1 loop } 4:number <- copy 2:number # trigger a read ] +mem: location 2 is 120 :(scenario break_outside_braces_fails) % Hide_errors = true; recipe main [ break ] +error: break needs a '{' before :(scenario break_conditional_without_ingredient_fails) % Hide_errors = true; recipe main [ { break-if } ] +error: break-if expects 1 or 2 ingredients, but got none