@shd101wyy/yo 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +40 -11
  3. package/out/cjs/index.cjs +14 -14
  4. package/out/cjs/yo-cli.cjs +453 -403
  5. package/out/esm/index.mjs +22 -22
  6. package/out/types/src/codegen/expressions/index.d.ts +0 -1
  7. package/out/types/src/codegen/utils/index.d.ts +5 -3
  8. package/out/types/src/env.d.ts +7 -6
  9. package/out/types/src/error.d.ts +6 -3
  10. package/out/types/src/evaluator/async/await-analysis-types.d.ts +1 -1
  11. package/out/types/src/evaluator/builtins/arc_fns.d.ts +20 -0
  12. package/out/types/src/evaluator/builtins/array_fns.d.ts +8 -0
  13. package/out/types/src/evaluator/builtins/type_fns.d.ts +2 -2
  14. package/out/types/src/evaluator/builtins/var_fns.d.ts +1 -1
  15. package/out/types/src/evaluator/calls/numeric_type.d.ts +4 -0
  16. package/out/types/src/evaluator/types/utils.d.ts +10 -10
  17. package/out/types/src/evaluator/utils.d.ts +1 -1
  18. package/out/types/src/expr.d.ts +9 -4
  19. package/out/types/src/types/creators.d.ts +1 -1
  20. package/out/types/src/types/definitions.d.ts +1 -1
  21. package/out/types/src/types/guards.d.ts +1 -1
  22. package/out/types/src/types/utils.d.ts +3 -2
  23. package/out/types/src/utils.d.ts +3 -1
  24. package/out/types/src/value.d.ts +4 -4
  25. package/out/types/tsconfig.tsbuildinfo +1 -1
  26. package/package.json +15 -2
  27. package/scripts/check-liburing.js +51 -39
  28. package/std/collections/array_list.yo +2 -2
  29. package/std/prelude.yo +272 -189
  30. package/out/types/src/codegen/expressions/array.d.ts +0 -4
  31. package/out/types/src/evaluator/utils/array-utils.d.ts +0 -15
  32. package/out/types/src/tests/codegen.test.d.ts +0 -1
  33. package/out/types/src/tests/module-manager.test.d.ts +0 -1
  34. package/out/types/src/tests/parser.test.d.ts +0 -1
  35. package/out/types/src/tests/sample.test.d.ts +0 -0
  36. package/out/types/src/tests/std.test.d.ts +0 -1
  37. package/std/monad.yo +0 -152
package/out/esm/index.mjs CHANGED
@@ -1,19 +1,19 @@
1
- import{readFileSync as da}from"node:fs";import Ta from"path";var v=class{constructor({characterIndex:n,message:t}){this.characterIndex=n,this.message=t}},q=class{constructor(n,t){this.tokenAndErrorList=[];this.tokenAndErrorList=n,this.isAssertionError=t||!1}toString(){return this.tokenAndErrorList.map(({token:t,errorMessage:o})=>`Error: ${o}
2
- ${be({token:t})}`).join(`
1
+ import{readFileSync as ba}from"node:fs";import Va from"path";var v=class{constructor({characterIndex:n,message:t}){this.characterIndex=n,this.message=t}},D=class{constructor(n,t,o){this.tokenAndErrorList=[];this.tokenAndErrorList=n,this.isAssertionError=t||!1,this.kind=o}toString(){return this.tokenAndErrorList.map(({token:t,errorMessage:o})=>`Error: ${o}
2
+ ${Ve({token:t})}`).join(`
3
3
 
4
- `)}};function be({token:e}){let{position:n,modulePath:t,inputString:o}=e,{row:i,column:r}=n,l=o.split(`
4
+ `)}};function Ve({token:e}){let{position:n,modulePath:t,inputString:o}=e,{row:i,column:r}=n,l=o.split(`
5
5
  `)[i];return`${t}:${i+1}:${r+1}:
6
6
  ${l}
7
- ${" ".repeat(r+Math.floor(e.value.length/2))}^`}function y({token:e,errorMessage:n,cause:t,isAssertionError:o}){let i=`${n.trim()}
7
+ ${" ".repeat(r+Math.floor(e.value.length/2))}^`}function f({token:e,errorMessage:n,cause:t,isAssertionError:o,kind:i}){let r=`${n.trim()}
8
8
 
9
- ${be({token:e})}`;return new q([{token:e,errorMessage:i+(t?.message?`
10
- `+t.message:"")}],o)}var z=(m=>(m.Operator="operator",m.Dot=".",m.LParen="(",m.RParen=")",m.LBracket="[",m.RBracket="]",m.LCurlyBracket="{",m.RCurlyBracket="}",m.Char="char",m.String="string",m.Identifier="identifier",m.Integer="integer",m.Float="float",m.Bool="bool",m.Semicolon=";",m.Comma=",",m.SingleLineComment="single_line_comment",m.MultiLineComment="multi_line_comment",m.Whitespace="whitespace",m.BacktickIdentifier="backtick_identifier",m))(z||{}),G={modulePath:"_",inputString:"_",type:"identifier",value:"_",position:{row:0,column:0,character:0}},ht={modulePath:"drop",inputString:"drop",type:"identifier",value:"drop",position:{row:0,column:0,character:0}},oe=["=","+","-","*","/","<",">","@","$","~","&","%","|","!","?","^",".",":","\\","#"];function P(e){return oe.includes(e)}function Ce(e){let n=!0;for(let t=0;t<e.length;t++){let o=e[t];if(!P(o)){n=!1;break}}return n}var j=/^[_a-zA-Z\xA0-\uFFFF][_a-zA-Z0-9\xA0-\uFFFF]*[!?]?$/;function Ve(e,n){let t=")";if(!e[n])return-1;let o=e[n].type;if(o==="{")t="}";else if(o==="(")t=")";else if(o==="[")t="]";else throw this.formatErrorMessage(e[n],"Expected '{', '(' or '['");n=n+1;let i=1,r=-1;for(;;){let p=e[n];if(!p)return-1;if(p.type===t){if(i=i-1,i===0){r=n;break}}else p.type===o&&(i=i+1);n=n+1}return r}function Fe(e,n){let t=[],o=0,i=0;for(let r=0;r<e.length;r++){let p=e[r],l=r-i,f=r,c="",u=r;if(e[u]===".")for(;e[u]===".";)c+=e[u],u=u+1;else for(;P(e[u])&&e[u]!==".";)c+=e[u],u=u+1;if(c&&!c.startsWith("//")&&!c.startsWith("/*")){t.push({type:c==="."?".":"operator",value:c,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=u-1;continue}switch(p){case" ":case" ":case`
9
+ ${Ve({token:e})}`;return new D([{token:e,errorMessage:r+(t?.message?`
10
+ `+t.message:"")}],o,i)}var z=(m=>(m.Operator="operator",m.Dot=".",m.LParen="(",m.RParen=")",m.LBracket="[",m.RBracket="]",m.LCurlyBracket="{",m.RCurlyBracket="}",m.Char="char",m.String="string",m.Identifier="identifier",m.Integer="integer",m.Float="float",m.Bool="bool",m.Semicolon=";",m.Comma=",",m.SingleLineComment="single_line_comment",m.MultiLineComment="multi_line_comment",m.Whitespace="whitespace",m.BacktickIdentifier="backtick_identifier",m))(z||{}),q={modulePath:"_",inputString:"_",type:"identifier",value:"_",position:{row:0,column:0,character:0}},vt={modulePath:"drop",inputString:"drop",type:"identifier",value:"drop",position:{row:0,column:0,character:0}},Q=["=","+","-","*","/","<",">","@","$","~","&","%","|","!","?","^",".",":","\\","#"];function P(e){return Q.includes(e)}function $e(e){let n=!0;for(let t=0;t<e.length;t++){let o=e[t];if(!P(o)){n=!1;break}}return n}var j=/^[_a-zA-Z\xA0-\uFFFF][_a-zA-Z0-9\xA0-\uFFFF]*[!?]?$/;function Fe(e,n){let t=")";if(!e[n])return-1;let o=e[n].type;if(o==="{")t="}";else if(o==="(")t=")";else if(o==="[")t="]";else throw this.formatErrorMessage(e[n],"Expected '{', '(' or '['");n=n+1;let i=1,r=-1;for(;;){let p=e[n];if(!p)return-1;if(p.type===t){if(i=i-1,i===0){r=n;break}}else p.type===o&&(i=i+1);n=n+1}return r}function xe(e,n){let t=[],o=0,i=0;for(let r=0;r<e.length;r++){let p=e[r],l=r-i,y=r,c="",u=r;if(e[u]===".")for(;e[u]===".";)c+=e[u],u=u+1;else for(;P(e[u])&&e[u]!==".";)c+=e[u],u=u+1;if(c&&!c.startsWith("//")&&!c.startsWith("/*")){t.push({type:c==="."?".":"operator",value:c,position:{row:o,column:l,character:y},modulePath:n,inputString:e}),r=u-1;continue}switch(p){case" ":case" ":case`
11
11
  `:case"\r":{let s="",a=r,d=o;for(;e[a]===" "||e[a]===" "||e[a]===`
12
12
  `||e[a]==="\r";)s+=e[a],e[a]===`
13
- `&&(o++,i=a+1),a=a+1;t.push({type:"whitespace",value:s,position:{row:d,column:l,character:f},modulePath:n,inputString:e}),r=a-1;break}case"/":if(e[r+1]==="/"){let s="",a=r;for(;e[a]!==`
14
- `&&a<e.length;)s+=e[a],a=a+1;t.push({type:"single_line_comment",value:s,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=a-1}else if(e[r+1]==="*"){let s=r,a="",d=o,V=1;for(a+=e[s],s++,a+=e[s],s++;V>0&&s<e.length;){if(e[s]===`
15
- `&&(i=s+1,o++),e[s]==="/"&&e[s+1]==="*"){V++,a+="/*",s+=2;continue}if(e[s]==="*"&&e[s+1]==="/"){V--,a+="*/",s+=2;continue}a+=e[s],s++}if(V>0)throw new v({message:"Unterminated multi-line comment",characterIndex:e.length-1});t.push({type:"multi_line_comment",value:a,position:{row:d,column:l,character:f},modulePath:n,inputString:e}),r=s-1}else throw new v({message:`Unexpected character ${p}`,characterIndex:r+1});break;case"(":t.push({type:"(",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case")":t.push({type:")",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"[":t.push({type:"[",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"]":t.push({type:"]",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"{":t.push({type:"{",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"}":t.push({type:"}",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case"'":{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==="'"){r=a;break}s+=e[a]}if(s.length===1||s.length===2&&s[0]==="\\")t.push({type:"char",value:`'${s}'`,position:{row:o,column:l,character:f},modulePath:n,inputString:e});else throw new v({message:`Invalid char '${s}', expected char to have length 1.`,characterIndex:r});break}case'"':{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==='"'){r=a;break}s+=e[a]}t.push({type:"string",value:`"${s}"`,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break}case"`":{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==="`"){r=a;break}s+=e[a]}if(!j.test(s))throw new v({message:`Invalid backtick identifier \`${s}\``,characterIndex:r});t.push({type:"backtick_identifier",value:`\`${s}\``,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break}case",":t.push({type:",",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;case";":t.push({type:";",value:p,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;default:if(/[0-9]/.test(p)){let s=r,a=p;r=r+1;let d=/[0-9_]/;for(e[r-1]==="0"&&typeof e[r]=="string"&&(e[r]==="x"||e[r]==="X"?(a+=e[r],r=r+1,d=/[0-9A-Fa-f]/):e[r]==="b"||e[r]==="B"?(a+=e[r],r=r+1,d=/[01]/):(e[r]==="o"||e[r]==="O")&&(a+=e[r],r=r+1,d=/[0-7]/));typeof e[r]=="string"&&d.test(e[r]);)a+=e[r],r=r+1;if(e[r]==="."&&e[s-1]!=="."&&(e[r+1]??"").match(/[0-9]/)){for(a+=e[r],r=r+1;typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"float",value:a,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=r-1}else{if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"integer",value:a,position:{row:o,column:l,character:f},modulePath:n,inputString:e}),r=r-1}}else if(/[_a-zA-Z\xA0-\uFFFF]/.test(p)){let s=p,a=r;for(r=r+1;typeof e[r]=="string"&&/[_a-zA-Z0-9\xA0-\uFFFF]/.test(e[r]);)s+=e[r],r=r+1;if(r=r-1,(e[r+1]==="!"||e[r+1]==="?")&&j.test(s+e[r+1])&&(r=r+1,s+=e[r]),j.test(s))switch(s){case"true":case"false":t.push({type:"bool",value:s,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break;default:t.push({type:"identifier",value:s,position:{row:o,column:l,character:f},modulePath:n,inputString:e});break}else throw new v({message:`Invalid identifier ${s}`,characterIndex:a})}else throw new v({message:`Unexpected character ${p}`,characterIndex:r});break}}return t}var L=class{constructor({modulePath:n,inputString:t}){this.modulePath=n,this.inputString=t,this.tokens=Fe(t,n),this.program=[],this.parse(this.tokens)}skipWhitespace(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t+1;return t}skipWhitespaceBackward(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t-1;return t}isParenthesizedExpression(n,t,o){return t=this.skipWhitespace(n,t),o=this.skipWhitespaceBackward(n,o),!!n[t]&&n[t].type==="("&&!!n[o]&&n[o].type===")"&&Ve(n,t)===o}parseParenExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="(")throw y({token:n[t],errorMessage:"Expected left paren"});if(n[t+1]?.type===")")return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.tuple,position:n[t].position,modulePath:this.modulePath,inputString:this.inputString}},args:[],token:n[t]},index:t+2};let i=this.parseExpression({tokens:n,index:t+1}),r=i.expr;if(t=i.index,n[t].type===")")return{expr:r,index:t+1};{let p,l=[r];for(;;){if(!n[t])throw y({token:n[t-1],errorMessage:"Expected ) or , for tuple"});if(n[t].type===","){if(!p||p===",")p=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in (...)'});t=t+1}else if(n[t].type===";"){if(!p||p===";")p=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in (...)'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type===")")break;let{expr:c,index:u}=this.parseExpression({tokens:n,index:t});l.push(c),t=u}let f=p===";"||!p;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:f?_.Tuple[0]:_.tuple,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:l,token:n[o]},index:t+1}}}parseArrayExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="[")throw y({token:n[t],errorMessage:"Expected left bracket"});t=t+1;let i,r=[];for(;;){if(!n[t])throw y({token:n[t-1],errorMessage:"Expected ] or , for array"});if(n[t].type===","){if(!i||i===",")i=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in [...]'});t=t+1}else if(n[t].type===";"){if(!i||i===";")i=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in [...]'});t=t+1}if(n[t].type==="]")break;let{expr:c,index:u}=this.parseExpression({tokens:n,index:t});r.push(c),t=u}let p=i===";"||!i;if(p&&r.length>2)throw y({token:n[o],errorMessage:`Expected at 2 arguments for Array type, or 1 argument for Slice type, got ${r.length}`});let l=p&&r.length===2,f=p&&r.length===1;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:l?_.Array[0]:f?_.Slice[0]:_.array,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:r,token:n[o]},index:t+1}}parseCurlyBracketExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="{")throw y({token:n[t],errorMessage:"Expected left curly bracket"});let i=[],r;for(t=t+1;;){if(t=this.skipWhitespace(n,t),!n[t])throw y({token:n[t-1],errorMessage:'Unexpected end of curly bracket. Expected "}" or "," or ";"'});if(n[t].type===","){if(!r||r===",")r=",";else throw y({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in {...}'});t=t+1}else if(n[t].type===";"){if(!r||r===";")r=";";else throw y({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in {...}'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type==="}"){let f=n[this.skipWhitespaceBackward(n,t-1)];if(r===";"&&f&&(f.type===";"||f.type==="{")){let c={type:"identifier",value:_.tuple,position:f.position,modulePath:this.modulePath,inputString:this.inputString};i.push({tag:"FuncCall",func:{tag:"Atom",token:c},args:[],token:c})}break}let{expr:p,index:l}=this.parseExpression({tokens:n,index:t});i.push(p),t=l}if(r===","||!r){for(let l=0;l<i.length;l++){let f=i[l];if(F(f)){let c={type:"operator",value:":",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString},u={tag:"FuncCall",func:{tag:"Atom",token:c},isInfix:!0,args:[f,f],token:c};i[l]=u}}return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:"_",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}else return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.begin[0],position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}parsePrimary({tokens:n,index:t}){t=this.skipWhitespace(n,t);let o=n[t];if(!o)throw y({token:G,errorMessage:"Unexpected end of input"});let i=null;switch(o.type){case"identifier":case"operator":case"bool":case"integer":case"float":case"string":case"char":{i={expr:{tag:"Atom",token:o},index:t+1};break}case"(":{i=this.parseParenExpr({tokens:n,index:t});break}case"[":{i=this.parseArrayExpr({tokens:n,index:t});break}case"{":{i=this.parseCurlyBracketExpr({tokens:n,index:t});break}case".":{i={expr:{tag:"Atom",token:o},index:t+1};break}default:throw y({token:o,errorMessage:`Unexpected token "${o.type}"`})}return i}isOperatorAtLineStart(n,t){for(let o=n.length-1;o>=0;o--){let i=n[o];if(i.type==="whitespace"&&i.value.includes(`
16
- `))return n.slice(o+1).every(l=>l.type==="whitespace");if(i.type!=="whitespace")return!1}return n.every(o=>o.type==="whitespace")}parseLeftAssociativeOperator({primaryExpr:n,operatorToken:t,rhs:o,tokens:i,index:r}){if(o.tag==="FuncCall"&&o.isInfix&&o.func.tag==="Atom"&&o.func.token.type!=="."){let p=o.args[0],l=o.args[1],f=o.func,c={tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,p],isInfix:!0,token:t};return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:f,args:[c,l],isInfix:!0,token:f.token},tokens:i,index:r})}else return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,o],isInfix:!0,token:t},tokens:i,index:r})}getExprMinimumColumnNumber(n){return F(n)?n.token.position.column:Math.min(this.getExprMinimumColumnNumber(n.func),...n.args.map(t=>this.getExprMinimumColumnNumber(t)))}parsePrimaryEnd({primaryExpr:n,tokens:t,index:o}){let i=this.skipWhitespace(t,o),r=i!==o,p=t[o-1]?.type==="whitespace";o=i;let l=t[i];if(!l||l.type===";"||l.type===","||l.type===")"||l.type==="]"||l.type==="}")return{expr:n,index:o};let f=n.tag==="Atom"&&n.token.type===".";if(f||l.type==="."&&!r&&!p&&t[i+1]?.type!=="whitespace"){let{expr:c,index:u}=this.parsePrimary({tokens:t,index:f?o:o+1});o=u;let s={expr:{tag:"FuncCall",func:{tag:"Atom",token:f?n.token:l},args:f?[c]:[n,c],isInfix:!f,token:f?n.token:l},index:o};for(;t[o]&&t[o].type===".";){let{expr:a,index:d}=this.parsePrimary({tokens:t,index:o+1});s={expr:{tag:"FuncCall",func:{tag:"Atom",token:l},args:[s.expr,a],isInfix:!0,token:l},index:d},o=d}return this.parsePrimaryEnd({primaryExpr:s.expr,tokens:t,index:s.index})}else if((l.type==="operator"||l.type==="."&&!r||l.type==="backtick_identifier")&&t[o+1]?.type!=="("){let c=this.skipWhitespace(t,o+1),{expr:u,index:s}=this.parseExpression({tokens:t,index:c});if(u.tag==="FuncCall"&&u.isInfix&&u.func.tag==="Atom"&&u.func.token.type!=="."&&!this.isParenthesizedExpression(t,c,s-1)){let a=`Ambiguous operator precedence.
13
+ `&&(o++,i=a+1),a=a+1;t.push({type:"whitespace",value:s,position:{row:d,column:l,character:y},modulePath:n,inputString:e}),r=a-1;break}case"/":if(e[r+1]==="/"){let s="",a=r;for(;e[a]!==`
14
+ `&&a<e.length;)s+=e[a],a=a+1;t.push({type:"single_line_comment",value:s,position:{row:o,column:l,character:y},modulePath:n,inputString:e}),r=a-1}else if(e[r+1]==="*"){let s=r,a="",d=o,V=1;for(a+=e[s],s++,a+=e[s],s++;V>0&&s<e.length;){if(e[s]===`
15
+ `&&(i=s+1,o++),e[s]==="/"&&e[s+1]==="*"){V++,a+="/*",s+=2;continue}if(e[s]==="*"&&e[s+1]==="/"){V--,a+="*/",s+=2;continue}a+=e[s],s++}if(V>0)throw new v({message:"Unterminated multi-line comment",characterIndex:e.length-1});t.push({type:"multi_line_comment",value:a,position:{row:d,column:l,character:y},modulePath:n,inputString:e}),r=s-1}else throw new v({message:`Unexpected character ${p}`,characterIndex:r+1});break;case"(":t.push({type:"(",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;case")":t.push({type:")",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;case"[":t.push({type:"[",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;case"]":t.push({type:"]",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;case"{":t.push({type:"{",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;case"}":t.push({type:"}",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;case"'":{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==="'"){r=a;break}s+=e[a]}if(s.length===1||s.length===2&&s[0]==="\\")t.push({type:"char",value:`'${s}'`,position:{row:o,column:l,character:y},modulePath:n,inputString:e});else throw new v({message:`Invalid char '${s}', expected char to have length 1.`,characterIndex:r});break}case'"':{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==='"'){r=a;break}s+=e[a]}t.push({type:"string",value:`"${s}"`,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break}case"`":{let s="";for(let a=r+1;a<e.length;a++){if(e[a]==="\\"){s+=e[a],a=a+1,s+=e[a];continue}if(e[a]==="`"){r=a;break}s+=e[a]}if(!j.test(s))throw new v({message:`Invalid backtick identifier \`${s}\``,characterIndex:r});t.push({type:"backtick_identifier",value:`\`${s}\``,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break}case",":t.push({type:",",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;case";":t.push({type:";",value:p,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;default:if(/[0-9]/.test(p)){let s=r,a=p;r=r+1;let d=/[0-9_]/;for(e[r-1]==="0"&&typeof e[r]=="string"&&(e[r]==="x"||e[r]==="X"?(a+=e[r],r=r+1,d=/[0-9A-Fa-f]/):e[r]==="b"||e[r]==="B"?(a+=e[r],r=r+1,d=/[01]/):(e[r]==="o"||e[r]==="O")&&(a+=e[r],r=r+1,d=/[0-7]/));typeof e[r]=="string"&&d.test(e[r]);)a+=e[r],r=r+1;if(e[r]==="."&&e[s-1]!=="."&&(e[r+1]??"").match(/[0-9]/)){for(a+=e[r],r=r+1;typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"float",value:a,position:{row:o,column:l,character:y},modulePath:n,inputString:e}),r=r-1}else{if((e[r]==="e"||e[r]==="E")&&typeof e[r+1]=="string"&&(e[r+1]==="+"||e[r+1]==="-"||/[0-9]/.test(e[r+1])))for(a+=e[r],r=r+1,(e[r]==="+"||e[r]==="-")&&(a+=e[r],r=r+1);typeof e[r]=="string"&&/[0-9_]/.test(e[r]);)a+=e[r],r=r+1;t.push({type:"integer",value:a,position:{row:o,column:l,character:y},modulePath:n,inputString:e}),r=r-1}}else if(/[_a-zA-Z\xA0-\uFFFF]/.test(p)){let s=p,a=r;for(r=r+1;typeof e[r]=="string"&&/[_a-zA-Z0-9\xA0-\uFFFF]/.test(e[r]);)s+=e[r],r=r+1;if(r=r-1,(e[r+1]==="!"||e[r+1]==="?")&&j.test(s+e[r+1])&&(r=r+1,s+=e[r]),j.test(s))switch(s){case"true":case"false":t.push({type:"bool",value:s,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break;default:t.push({type:"identifier",value:s,position:{row:o,column:l,character:y},modulePath:n,inputString:e});break}else throw new v({message:`Invalid identifier ${s}`,characterIndex:a})}else throw new v({message:`Unexpected character ${p}`,characterIndex:r});break}}return t}var L=class{constructor({modulePath:n,inputString:t}){this.modulePath=n,this.inputString=t,this.tokens=xe(t,n),this.program=[],this.parse(this.tokens)}skipWhitespace(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t+1;return t}skipWhitespaceBackward(n,t){for(;n[t]&&(n[t].type==="whitespace"||n[t].type==="single_line_comment"||n[t].type==="multi_line_comment");)t=t-1;return t}isParenthesizedExpression(n,t,o){return t=this.skipWhitespace(n,t),o=this.skipWhitespaceBackward(n,o),!!n[t]&&n[t].type==="("&&!!n[o]&&n[o].type===")"&&Fe(n,t)===o}parseParenExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="(")throw f({token:n[t],errorMessage:"Expected left paren"});if(n[t+1]?.type===")")return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.tuple,position:n[t].position,modulePath:this.modulePath,inputString:this.inputString}},args:[],token:n[t]},index:t+2};let i=this.parseExpression({tokens:n,index:t+1}),r=i.expr;if(t=i.index,n[t].type===")")return{expr:r,index:t+1};{let p,l=[r];for(;;){if(!n[t])throw f({token:n[t-1],errorMessage:"Expected ) or , for tuple"});if(n[t].type===","){if(!p||p===",")p=",";else throw f({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in (...)'});t=t+1}else if(n[t].type===";"){if(!p||p===";")p=";";else throw f({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in (...)'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type===")")break;let{expr:c,index:u}=this.parseExpression({tokens:n,index:t});l.push(c),t=u}let y=p===";"||!p;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:y?_.Tuple[0]:_.tuple,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:l,token:n[o]},index:t+1}}}parseArrayExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="[")throw f({token:n[t],errorMessage:"Expected left bracket"});t=t+1;let i,r=[];for(;;){if(!n[t])throw f({token:n[t-1],errorMessage:"Expected ] or , for array"});if(n[t].type===","){if(!i||i===",")i=",";else throw f({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in [...]'});t=t+1}else if(n[t].type===";"){if(!i||i===";")i=";";else throw f({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in [...]'});t=t+1}if(n[t].type==="]")break;let{expr:c,index:u}=this.parseExpression({tokens:n,index:t});r.push(c),t=u}let p=i===";"||!i;if(p&&r.length>2)throw f({token:n[o],errorMessage:`Expected at 2 arguments for Array type, or 1 argument for Slice type, got ${r.length}`});let l=p&&r.length===2,y=p&&r.length===1;return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:l?_.Array[0]:y?_.Slice[0]:_.array,position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:r,token:n[o]},index:t+1}}parseCurlyBracketExpr({tokens:n,index:t}){let o=t;if(n[t].type!=="{")throw f({token:n[t],errorMessage:"Expected left curly bracket"});let i=[],r;for(t=t+1;;){if(t=this.skipWhitespace(n,t),!n[t])throw f({token:n[t-1],errorMessage:'Unexpected end of curly bracket. Expected "}" or "," or ";"'});if(n[t].type===","){if(!r||r===",")r=",";else throw f({token:n[t],errorMessage:'Cannot mix "," with ";" as separator in {...}'});t=t+1}else if(n[t].type===";"){if(!r||r===";")r=";";else throw f({token:n[t],errorMessage:'Cannot mix ";" with "," as separator in {...}'});t=t+1}if(t=this.skipWhitespace(n,t),n[t].type==="}"){let y=n[this.skipWhitespaceBackward(n,t-1)];if(r===";"&&y&&(y.type===";"||y.type==="{")){let c={type:"identifier",value:_.tuple,position:y.position,modulePath:this.modulePath,inputString:this.inputString};i.push({tag:"FuncCall",func:{tag:"Atom",token:c},args:[],token:c})}break}let{expr:p,index:l}=this.parseExpression({tokens:n,index:t});i.push(p),t=l}if(r===","||!r){for(let l=0;l<i.length;l++){let y=i[l];if($(y)){let c={type:"operator",value:":",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString},u={tag:"FuncCall",func:{tag:"Atom",token:c},isInfix:!0,args:[y,y],token:c};i[l]=u}}return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:"_",position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}else return{expr:{tag:"FuncCall",func:{tag:"Atom",token:{type:"identifier",value:_.begin[0],position:n[o].position,modulePath:this.modulePath,inputString:this.inputString}},args:i,token:n[o]},index:t+1}}parsePrimary({tokens:n,index:t}){t=this.skipWhitespace(n,t);let o=n[t];if(!o)throw f({token:q,errorMessage:"Unexpected end of input"});let i=null;switch(o.type){case"identifier":case"operator":case"bool":case"integer":case"float":case"string":case"char":{i={expr:{tag:"Atom",token:o},index:t+1};break}case"(":{i=this.parseParenExpr({tokens:n,index:t});break}case"[":{i=this.parseArrayExpr({tokens:n,index:t});break}case"{":{i=this.parseCurlyBracketExpr({tokens:n,index:t});break}case".":{i={expr:{tag:"Atom",token:o},index:t+1};break}default:throw f({token:o,errorMessage:`Unexpected token "${o.type}"`})}return i}isOperatorAtLineStart(n,t){for(let o=n.length-1;o>=0;o--){let i=n[o];if(i.type==="whitespace"&&i.value.includes(`
16
+ `))return n.slice(o+1).every(l=>l.type==="whitespace");if(i.type!=="whitespace")return!1}return n.every(o=>o.type==="whitespace")}parseLeftAssociativeOperator({primaryExpr:n,operatorToken:t,rhs:o,tokens:i,index:r}){if(o.tag==="FuncCall"&&o.isInfix&&o.func.tag==="Atom"&&o.func.token.type!=="."){let p=o.args[0],l=o.args[1],y=o.func,c={tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,p],isInfix:!0,token:t};return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:y,args:[c,l],isInfix:!0,token:y.token},tokens:i,index:r})}else return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:t},args:[n,o],isInfix:!0,token:t},tokens:i,index:r})}getExprMinimumColumnNumber(n){return $(n)?n.token.position.column:Math.min(this.getExprMinimumColumnNumber(n.func),...n.args.map(t=>this.getExprMinimumColumnNumber(t)))}parsePrimaryEnd({primaryExpr:n,tokens:t,index:o}){let i=this.skipWhitespace(t,o),r=i!==o,p=t[o-1]?.type==="whitespace";o=i;let l=t[i];if(!l||l.type===";"||l.type===","||l.type===")"||l.type==="]"||l.type==="}")return{expr:n,index:o};let y=n.tag==="Atom"&&n.token.type===".";if(y||l.type==="."&&!r&&!p&&t[i+1]?.type!=="whitespace"){let{expr:c,index:u}=this.parsePrimary({tokens:t,index:y?o:o+1});o=u;let s={expr:{tag:"FuncCall",func:{tag:"Atom",token:y?n.token:l},args:y?[c]:[n,c],isInfix:!y,token:y?n.token:l},index:o};for(;t[o]&&t[o].type===".";){let{expr:a,index:d}=this.parsePrimary({tokens:t,index:o+1});s={expr:{tag:"FuncCall",func:{tag:"Atom",token:l},args:[s.expr,a],isInfix:!0,token:l},index:d},o=d}return this.parsePrimaryEnd({primaryExpr:s.expr,tokens:t,index:s.index})}else if((l.type==="operator"||l.type==="."&&!r||l.type==="backtick_identifier")&&t[o+1]?.type!=="("){let c=this.skipWhitespace(t,o+1),{expr:u,index:s}=this.parseExpression({tokens:t,index:c});if(u.tag==="FuncCall"&&u.isInfix&&u.func.tag==="Atom"&&u.func.token.type!=="."&&!this.isParenthesizedExpression(t,c,s-1)){let a=`Ambiguous operator precedence.
17
17
  Please use parentheses to clarify:
18
18
 
19
19
  ${g(n)} ${l.value} (${g(u)})
@@ -21,31 +21,31 @@ ${g(n)} ${l.value} (${g(u)})
21
21
  (${g(n)} ${l.value} ${g(u.args[0])}) ${g(u.func)} ${g(u.args[1])}
22
22
 
23
23
  Or use newline after "${l.value}" to confirm the right-associativity.
24
- `,V=t.slice(o+1,c).some(Ee=>Ee.type==="whitespace"&&Ee.value.includes(`
25
- `)),re=t.slice(0,o),x=this.isOperatorAtLineStart(re,o),U=t.slice(o+1,c),De=x&&U.length>0&&U[0]?.type==="whitespace"&&U[0]?.value.includes(`
26
- `);if(!(V&&!x)){if(!De){if(x)return this.parseLeftAssociativeOperator({primaryExpr:n,operatorToken:l,rhs:u,tokens:t,index:s});throw y({token:l,errorMessage:a})}}}return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:l},args:[n,u],isInfix:!0,token:l},tokens:t,index:s})}else if(!r&&l.type==="("){let c=this.parseFunctionCall({func:n,tokens:t,index:o+1,hasWhitespace:!1});return this.parsePrimaryEnd({primaryExpr:c.expr,tokens:t,index:c.index})}else{let c=this.parseFunctionCall({func:n,tokens:t,index:o,hasWhitespace:!0});return this.parsePrimaryEnd({primaryExpr:c.expr,tokens:t,index:c.index})}}parseFunctionArguments({tokens:n,index:t,hasWhitespace:o}){let i=[];if(t=this.skipWhitespace(n,t),!o&&n[t]?.type===")")return{args:i,index:t+1};for(;;){let{expr:r,index:p}=this.parseExpression({tokens:n,index:t});i.push(r),t=p;let l=n[t];if(l?.type===",")t=t+1;else{if(!l||l.type===";"||l.type==="]"||l.type==="}")return{args:i,index:t};if(l.type===")")return{args:i,index:o?t:t+1};throw y({token:l,errorMessage:o?"Expected ; to end the function call":`Expected , to separate arguments
24
+ `,V=t.slice(o+1,c).some(Ce=>Ce.type==="whitespace"&&Ce.value.includes(`
25
+ `)),Z=t.slice(0,o),k=this.isOperatorAtLineStart(Z,o),U=t.slice(o+1,c),je=k&&U.length>0&&U[0]?.type==="whitespace"&&U[0]?.value.includes(`
26
+ `);if(!(V&&!k)){if(!je){if(k)return this.parseLeftAssociativeOperator({primaryExpr:n,operatorToken:l,rhs:u,tokens:t,index:s});throw f({token:l,errorMessage:a})}}}return this.parsePrimaryEnd({primaryExpr:{tag:"FuncCall",func:{tag:"Atom",token:l},args:[n,u],isInfix:!0,token:l},tokens:t,index:s})}else if(!r&&l.type==="("){let c=this.parseFunctionCall({func:n,tokens:t,index:o+1,hasWhitespace:!1});return this.parsePrimaryEnd({primaryExpr:c.expr,tokens:t,index:c.index})}else{let c=this.parseFunctionCall({func:n,tokens:t,index:o,hasWhitespace:!0});return this.parsePrimaryEnd({primaryExpr:c.expr,tokens:t,index:c.index})}}parseFunctionArguments({tokens:n,index:t,hasWhitespace:o}){let i=[];if(t=this.skipWhitespace(n,t),!o&&n[t]?.type===")")return{args:i,index:t+1};for(;;){let{expr:r,index:p}=this.parseExpression({tokens:n,index:t});i.push(r),t=p;let l=n[t];if(l?.type===",")t=t+1;else{if(!l||l.type===";"||l.type==="]"||l.type==="}")return{args:i,index:t};if(l.type===")")return{args:i,index:o?t:t+1};throw f({token:l,errorMessage:o?"Expected ; to end the function call":`Expected , to separate arguments
27
27
  or ) to end the function call`})}}}parseFunctionCall({func:n,tokens:t,index:o,hasWhitespace:i}){let{args:r,index:p}=this.parseFunctionArguments({tokens:t,index:o,hasWhitespace:i});return o=p,{expr:{tag:"FuncCall",func:n,args:r,token:n.token},index:o}}parseExpression({tokens:n,index:t}){t=this.skipWhitespace(n,t);let{expr:o,index:i}=this.parsePrimary({tokens:n,index:t});return this.parsePrimaryEnd({primaryExpr:o,tokens:n,index:i})}programToString(){return this.program.map(t=>g(t)).join(`;
28
- `)}parse(n){let t=0,o=[];for(;t<n.length;){switch(n[t].type){case"whitespace":case";":case"single_line_comment":case"multi_line_comment":{t=t+1;continue}}if(t>=n.length)break;try{let{expr:p,index:l}=this.parseExpression({tokens:n,index:t});o.push(p),t=l}catch(p){this.parserError=p;break}}let i=n[this.skipWhitespaceBackward(n,n.length-1)];if(i&&i.type===";"){let r={type:"identifier",value:_.tuple,position:i.position,modulePath:this.modulePath,inputString:this.inputString};o.push({tag:"FuncCall",func:{tag:"Atom",token:r},args:[],token:r})}this.program=o}getProgram(){return this.program}getParserError(){return this.parserError}getTokens(){return this.tokens}};function ie(e){let n=new L({modulePath:`auto-generated://
28
+ `)}parse(n){let t=0,o=[];for(;t<n.length;){switch(n[t].type){case"whitespace":case";":case"single_line_comment":case"multi_line_comment":{t=t+1;continue}}if(t>=n.length)break;try{let{expr:p,index:l}=this.parseExpression({tokens:n,index:t});o.push(p),t=l}catch(p){this.parserError=p;break}}let i=n[this.skipWhitespaceBackward(n,n.length-1)];if(i&&i.type===";"){let r={type:"identifier",value:_.tuple,position:i.position,modulePath:this.modulePath,inputString:this.inputString};o.push({tag:"FuncCall",func:{tag:"Atom",token:r},args:[],token:r})}this.program=o}getProgram(){return this.program}getParserError(){return this.parserError}getTokens(){return this.tokens}};function J(e){let n=new L({modulePath:`auto-generated://
29
29
  // === START auto-generated code ===
30
30
  ${e}
31
31
  // === END auto-generated code ===
32
32
  `,inputString:e});if(n.getParserError())throw n.getParserError();let t=n.getProgram();if(t.length!==1)throw new Error(`Expected exactly one expression from parsed code, got ${t.length}: "${e}"
33
33
  ${t.map(o=>g(o)).join(`
34
34
  `)}
35
- `);return t[0]}import{createHash as Ye}from"crypto";var Qe=0;function Ae(){return`id${Qe++}`}function Je(e){return"yo"+Ye("sha1").update(e).digest("hex").slice(0,8)}var Ie=new Map;function ce(e,n){let t="";for(let r=0;r<n.length;r++)if(P(n[r])){let p=oe.indexOf(n[r]);t+=`${p}`}else t+=n[r];let o=Je(e)+"_"+t,i=Ie.get(o);return i===void 0?i=0:i++,Ie.set(o,i),o+(i==0?"":`_${i}`)}var fe=null;function Ue(){if(fe)return fe;let e=Pe(),n=ze(e),t={id:"unit",tag:"unit",module:n};return n.receiverType=t,fe=t,t}function ze(e){return{id:`module_${Ae()}`,tag:"Module",fields:[],env:e,module:void 0}}function k(e){return e?.tag==="FuncCall"}function F(e){return e?.tag==="Atom"}function w(e){return e.tag==="Atom"&&e.token.type==="operator"}function A(e,n,t){if(e.tag!=="FuncCall"||e.func.tag!=="Atom")return!1;let o=e.func.token.value;return e.func.token.type==="backtick_identifier"&&(o=o.slice(1,-1)),e.tag==="FuncCall"&&e.func.tag==="Atom"&&(typeof n=="string"?o===n:n.includes(o))&&(t===void 0||e.args.length===t)}var _={compt:["compt"],ref:["ref"],forall:["forall","\u2200"],where:["where"],quote:["quote",":"],unquote:["unquote","#"],unquote_splicing:["unquote_splicing","...#"],return:["return"],recur:["recur"],fn:["fn"],unsafe_fn:["unsafe_fn"],extern:["extern"],cond:["cond"],type:["type"],match:["match"],test:["test"],struct:["struct"],object:["object"],newtype:["newtype"],enum:["enum"],union:["union"],module:["module"],impl:["impl"],Impl:["Impl"],begin:["begin"],module_begin:["module_begin"],import:["import"],export:["export"],open:["open"],clone:["clone","%"],break:["break"],continue:["continue"],while:["while"],if:["if"],op_and:["&&"],op_or:["||"],not:["not"],gensym:["gensym"],dyn:["dyn"],Dyn:["Dyn"],Fn:["Fn"],c_include:["c_include"],undefined:["undefined"],null:["null"],true:["true"],false:["false"],unique:["unique","^"],Ptr:["*"],Iso:["Iso"],Tuple:["Tuple"],Array:["Array"],Slice:["Slice"],Future:["Future"],Concrete:["Concrete"],Type:["Type"],Module:["Module"],ComptList:["ComptList"],tuple:"tuple",array:"array",compt_list:"compt_list"};function I(e){return!!(e.tag==="FuncCall"&&e.isInfix&&e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="backtick_identifier")&&e.args.length===2)}function g(e,n){let o={...{prettyPrint:!1,indentSize:2,maxLineLength:80,indentLevel:0},...n};return o.prettyPrint?T(e,o):h(e)}function h(e){let n="";switch(e.tag){case"Atom":{n=e.token.value;break}case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){e.func.token.value==="."?n=`${e.func.token.value}${h(e.args[0])}`:n=`${e.func.token.value}(${h(e.args[0])})`;break}else if(e.args.length===2&&e.isInfix){let i=h(e.args[0]),r=h(e.args[1]);i=I(e.args[0])||w(e.args[0])?`(${i})`:i,r=I(e.args[1])||w(e.args[1])?`(${r})`:r,e.func.token.value==="."?n=`(${i}.${r})`:n=`${i} ${e.func.token.value} ${r}`;break}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){e.args.length===1?n=`(${h(e.args[0])},)`:n=`(${e.args.map(i=>h(i)).join(", ").trim()})`;break}let t=h(e.func);t=I(e.func)||w(e.func)?`(${t})`:t;let o=e.args.map(i=>h(i)).join(", ").trim();n=`${t}(${o})`;break}}return n}function T(e,n){let t=" ".repeat(n.indentLevel*n.indentSize),o={...n,indentLevel:n.indentLevel+1},i=" ".repeat(o.indentLevel*n.indentSize);switch(e.tag){case"Atom":return e.token.value;case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){if(e.func.token.value===".")return`${e.func.token.value}${T(e.args[0],n)}`;{let c=T(e.args[0],n);return`${e.func.token.value}(${c})`}}else if(e.args.length===2&&e.isInfix){let c=T(e.args[0],n),u=T(e.args[1],n);return c=I(e.args[0])||w(e.args[0])?`(${c})`:c,u=I(e.args[1])||w(e.args[1])?`(${u})`:u,e.func.token.value==="."?`(${c}.${u})`:`${c} ${e.func.token.value} ${u}`}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){if(e.args.length===0)return"()";if(e.args.length===1)return`(${T(e.args[0],n)},)`;{let c=e.args.map(s=>T(s,n)),u=`(${c.join(", ")})`;return u.length<=n.maxLineLength?u:`(
35
+ `);return t[0]}import{createHash as Qe}from"crypto";function Ue(e){return"yo"+Qe("sha1").update(e).digest("hex").slice(0,8)}var Ie=new Map;function ue(e){let n=Ie.get(e);return n===void 0&&(n=0),Ie.set(e,n+1),`${Ue(e)}_id_${n}`}var Ae=new Map;function pe(e,n){let t="";for(let r=0;r<n.length;r++)if(P(n[r])){let p=Q.indexOf(n[r]);t+=`${p}`}else t+=n[r];let o=Ue(e)+"_"+t,i=Ae.get(o);return i===void 0?i=0:i++,Ae.set(o,i),o+(i==0?"":`_${i}`)}var ce="__yo_self";var Nn=`(fn(${ce} : Self) -> unit)`,Dn=`(fn(${ce} : Self) -> unit)`,qn=`(fn(${ce} : Self) -> Self)`;var _e=null;function Le(){if(_e)return _e;let e=Oe(),n=Be(e),t={id:"unit",tag:"unit",module:n};return n.receiverType=t,_e=t,t}function Be(e){return{id:`module_${ue(e.modulePath)}`,tag:"Module",fields:[],env:e,module:void 0}}function x(e){return e?.tag==="FuncCall"}function $(e){return e?.tag==="Atom"}function w(e){return e.tag==="Atom"&&e.token.type==="operator"}function A(e,n,t){if(e.tag!=="FuncCall"||e.func.tag!=="Atom")return!1;let o=e.func.token.value;return e.func.token.type==="backtick_identifier"&&(o=o.slice(1,-1)),e.tag==="FuncCall"&&e.func.tag==="Atom"&&(typeof n=="string"?o===n:n.includes(o))&&(t===void 0||e.args.length===t)}var _={compt:["compt"],ref:["ref"],forall:["forall","\u2200"],where:["where"],quote:["quote",":"],unquote:["unquote","#"],unquote_splicing:["unquote_splicing","...#"],return:["return"],recur:["recur"],fn:["fn"],unsafe_fn:["unsafe_fn"],extern:["extern"],cond:["cond"],type:["type"],match:["match"],test:["test"],struct:["struct"],object:["object"],newtype:["newtype"],enum:["enum"],union:["union"],module:["module"],impl:["impl"],Impl:["Impl"],begin:["begin"],module_begin:["module_begin"],import:["import"],export:["export"],open:["open"],clone:["clone","%"],break:["break"],continue:["continue"],while:["while"],if:["if"],op_and:["&&"],op_or:["||"],not:["not"],gensym:["gensym"],dyn:["dyn"],Dyn:["Dyn"],Fn:["Fn"],c_include:["c_include"],undefined:["undefined"],null:["null"],true:["true"],false:["false"],unique:["unique","^"],Ptr:["*"],Iso:["Iso"],Tuple:["Tuple"],Array:["Array"],Slice:["Slice"],Future:["Future"],Concrete:["Concrete"],Type:["Type"],Module:["Module"],ComptList:["ComptList"],tuple:"tuple",array:"array",compt_list:"compt_list"};function I(e){return!!(e.tag==="FuncCall"&&e.isInfix&&e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="backtick_identifier")&&e.args.length===2)}function g(e,n){let o={...{prettyPrint:!1,indentSize:2,maxLineLength:80,indentLevel:0},...n};return o.prettyPrint?T(e,o):h(e)}function h(e){let n="";switch(e.tag){case"Atom":{n=e.token.value;break}case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){e.func.token.value==="."?n=`${e.func.token.value}${h(e.args[0])}`:n=`${e.func.token.value}(${h(e.args[0])})`;break}else if(e.args.length===2&&e.isInfix){let i=h(e.args[0]),r=h(e.args[1]);i=I(e.args[0])||w(e.args[0])?`(${i})`:i,r=I(e.args[1])||w(e.args[1])?`(${r})`:r,e.func.token.value==="."?n=`(${i}.${r})`:n=`${i} ${e.func.token.value} ${r}`;break}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){e.args.length===1?n=`(${h(e.args[0])},)`:n=`(${e.args.map(i=>h(i)).join(", ").trim()})`;break}let t=h(e.func);t=I(e.func)||w(e.func)?`(${t})`:t;let o=e.args.map(i=>h(i)).join(", ").trim();n=`${t}(${o})`;break}}return n}function T(e,n){let t=" ".repeat(n.indentLevel*n.indentSize),o={...n,indentLevel:n.indentLevel+1},i=" ".repeat(o.indentLevel*n.indentSize);switch(e.tag){case"Atom":return e.token.value;case"FuncCall":{if(e.func.tag==="Atom"&&(e.func.token.type==="operator"||e.func.token.type==="."||e.func.token.type==="backtick_identifier")){if(e.args.length===1){if(e.func.token.value===".")return`${e.func.token.value}${T(e.args[0],n)}`;{let c=T(e.args[0],n);return`${e.func.token.value}(${c})`}}else if(e.args.length===2&&e.isInfix){let c=T(e.args[0],n),u=T(e.args[1],n);return c=I(e.args[0])||w(e.args[0])?`(${c})`:c,u=I(e.args[1])||w(e.args[1])?`(${u})`:u,e.func.token.value==="."?`(${c}.${u})`:`${c} ${e.func.token.value} ${u}`}}if(e.func.tag==="Atom"&&e.func.token.type==="identifier"&&e.func.token.value===_.tuple){if(e.args.length===0)return"()";if(e.args.length===1)return`(${T(e.args[0],n)},)`;{let c=e.args.map(s=>T(s,n)),u=`(${c.join(", ")})`;return u.length<=n.maxLineLength?u:`(
36
36
  ${i}${c.join(`,
37
37
  ${i}`)}
38
38
  ${t})`}}let r=e.func.tag==="Atom"?e.func.token.value:null,p=r&&[..._.begin,..._.cond,..._.match,..._.fn,..._.if,..._.while].includes(r),l=T(e.func,n);if(l=I(e.func)||w(e.func)?`(${l})`:l,e.args.length===0)return`${l}()`;if(!p){let c=e.args.map(s=>T(s,n)),u=`${l}(${c.join(", ")})`;if(u.length<=n.maxLineLength)return u}if(p){if(r===_.begin[0]){if(e.args.length===1){let u=T(e.args[0],n);if(u.length<=n.maxLineLength&&!u.includes(`
39
39
  `))return`${l}(${u})`}let c=e.args.map(u=>T(u,o));return`${l}(
40
40
  ${i}${c.join(`,
41
41
  ${i}`)}
42
- ${t})`}else if(r===_.cond[0]){let c=e.args.map(u=>{if(k(u)&&u.isInfix&&A(u,"=>")){let s=u.args[0],a=T(u.args[1],o),d=T(s,n);if(k(s)&&s.isInfix&&!A(s,"=>")&&(d=`(${d})`),a.includes(`
43
- `)){let re=a.split(`
44
- `).map((x,U)=>U===0?x:`${i}${x}`).join(`
45
- `);return`${d} => ${re}`}else return`${d} => ${a}`}return T(u,o)});return`${l}(
42
+ ${t})`}else if(r===_.cond[0]){let c=e.args.map(u=>{if(x(u)&&u.isInfix&&A(u,"=>")){let s=u.args[0],a=T(u.args[1],o),d=T(s,n);if(x(s)&&s.isInfix&&!A(s,"=>")&&(d=`(${d})`),a.includes(`
43
+ `)){let Z=a.split(`
44
+ `).map((k,U)=>U===0?k:`${i}${k}`).join(`
45
+ `);return`${d} => ${Z}`}else return`${d} => ${a}`}return T(u,o)});return`${l}(
46
46
  ${i}${c.join(`,
47
47
  ${i}`)}
48
- ${t})`}}let f=e.args.map(c=>T(c,o));return`${l}(
49
- ${i}${f.join(`,
48
+ ${t})`}}let y=e.args.map(c=>T(c,o));return`${l}(
49
+ ${i}${y.join(`,
50
50
  ${i}`)}
51
- ${t})`}}return h(e)}var lt={tag:"Unit",type:Ue()};var ve=new Map,ne=new Map,yt=new Map;function _t(e){for(let[n,t]of ne.entries()){let o=t.filter(i=>i.sourceModulePath!==e);o.length===0?ne.delete(n):ne.set(n,o)}}function mt(){ve.clear(),ne.clear(),yt.clear()}function dt(e){let n=ve.get(e);if(n){for(let t of n)t.fields=t.fields.filter(o=>o.sourceModulePath!==e);ve.delete(e)}}function Ne({modulePath:e,inputString:n}){return{functionDeclarationFrameLevel:-1,frames:[],freeVariables:[],modulePath:e,inputString:n}}function Pe(){let e=Ne({modulePath:"",inputString:""});return R(e)}function R(e,n={id:ce(e.modulePath,"frame"),variables:[],isBeginBlockFrame:!1},t){let o=t?{...n,isBeginBlockFrame:!0}:n;return{functionDeclarationFrameLevel:e.functionDeclarationFrameLevel,freeVariables:e.freeVariables,frames:[...e.frames,o],modulePath:e.modulePath,inputString:e.inputString}}var Fa=process.env.YO_SKIP_PRELUDE==="1"||process.env.YO_SKIP_PRELUDE==="true";export{j as IdentifierRegex,oe as Operators,G as PlaceholderToken,ht as RAIIToken,z as TokenType,P as charIsOperator,mt as clearAllGlobalImplState,_t as clearGenericImplsFromModule,dt as clearImplsFromModule,Ve as findMatchingBracketTokenIndex,ie as generateExprFromCode,Ce as stringIsOperator,Fe as tokenize};
51
+ ${t})`}}return h(e)}var st={tag:"Unit",type:Le()};var be=new Map,Y=new Map,_t=new Map;function mt(e){for(let[n,t]of Y.entries()){let o=t.filter(i=>i.sourceModulePath!==e);o.length===0?Y.delete(n):Y.set(n,o)}}function dt(){be.clear(),Y.clear(),_t.clear()}function gt(e){let n=be.get(e);if(n){for(let t of n)t.fields=t.fields.filter(o=>o.sourceModulePath!==e);be.delete(e)}}function qe({modulePath:e,inputString:n}){return{functionDeclarationFrameLevel:-1,frames:[],freeVariables:[],modulePath:e,inputString:n}}function Oe(){let e=qe({modulePath:"",inputString:""});return N(e)}function N(e,n={id:pe(e.modulePath,"frame"),variables:[],isBeginBlockFrame:!1},t){let o=t?{...n,isBeginBlockFrame:!0}:n;return{functionDeclarationFrameLevel:e.functionDeclarationFrameLevel,freeVariables:e.freeVariables,frames:[...e.frames,o],modulePath:e.modulePath,inputString:e.inputString}}var wa=process.env.YO_SKIP_PRELUDE==="1"||process.env.YO_SKIP_PRELUDE==="true";export{j as IdentifierRegex,Q as Operators,q as PlaceholderToken,vt as RAIIToken,z as TokenType,P as charIsOperator,dt as clearAllGlobalImplState,mt as clearGenericImplsFromModule,gt as clearImplsFromModule,Fe as findMatchingBracketTokenIndex,J as generateExprFromCode,$e as stringIsOperator,xe as tokenize};
@@ -1,2 +1 @@
1
- export * from "./array";
2
1
  export * from "./generation";
@@ -1,4 +1,5 @@
1
1
  import { Emitter } from "../../emitter";
2
+ import { Environment } from "../../env";
2
3
  import { FunctionValue, FuncValueId } from "../../function-value";
3
4
  import { DynType, EnumType, FunctionType, IsoType, StructType, Type, TypeId } from "../../types";
4
5
  import { ModuleValue } from "../../value";
@@ -61,17 +62,18 @@ export interface CodeGenContext {
61
62
  dynType: DynType;
62
63
  concreteType: Type;
63
64
  dataType: Type;
64
- moduleValue: ModuleValue;
65
+ moduleValues: ModuleValue[];
65
66
  }>;
66
67
  currentLoopLabel?: string;
68
+ currentContinueLabel?: string;
67
69
  }
68
- export declare function sanitizeForCIdentifier(str: string): string;
70
+ export declare function sanitizeForCIdentifier(str: string, isExternC?: boolean): string;
69
71
  export declare function shouldAvoidConst(type: Type): boolean;
70
72
  export declare function getTypeString(type: Type | undefined, context: CodeGenContext): string;
71
73
  export declare function getVariableTypeString(type: Type, varName: string, context: CodeGenContext): string;
72
74
  export declare function getEnumVariantCName(enumType: EnumType, variantName: string, context: CodeGenContext): string;
73
- export declare function isGenericFunction(functionValue: FunctionValue): boolean;
74
75
  export declare function isComptFunction(functionValue: FunctionValue): boolean;
75
76
  export declare function isFunctionValueWithOnlyBuiltinYoInlineFunctionCall(functionValue: FunctionValue): string | null;
76
77
  export declare function canOptimizeAsNullablePointer(enumType: EnumType): Type | null;
77
78
  export declare function canOptimizeAsSimpleEnum(enumType: EnumType): boolean;
79
+ export declare function getVariableNameForCodegen(variableName: string, env: Environment | undefined): string;
@@ -7,8 +7,8 @@ export interface Variable {
7
7
  type: Type;
8
8
  value?: Value;
9
9
  isCompileTimeOnly: boolean;
10
- isOwningTheGcValue: boolean;
11
- isOwningTheSameGcValueAs?: Variable;
10
+ isOwningTheRcValue: boolean;
11
+ isOwningTheSameRcValueAs?: Variable;
12
12
  isReassignable?: boolean;
13
13
  initializedAtToken: Token | undefined;
14
14
  consumedAtToken: Token | undefined;
@@ -38,13 +38,14 @@ export declare function setEnvContainingPrelude(env: Environment): void;
38
38
  export declare function clearEnvContainingPrelude(): void;
39
39
  export declare function createEnvContainingPrelude(): Environment;
40
40
  export declare function isEvaluatingPreludeModule(): boolean;
41
- export declare function addVariableToEnv({ env, variable, deltaFrame, variableId, skipCheckingFunctionOverloading, addToBeginBlockFrame, }: {
41
+ export declare const YoSelf = "__yo_self";
42
+ export declare function addVariableToEnv({ env, variable, deltaFrame, variableId, addToBeginBlockFrame, allowVariableShadowing, }: {
42
43
  env: Environment;
43
44
  variable: Omit<Variable, "id" | "frameLevel">;
44
45
  deltaFrame?: number;
45
46
  variableId?: string;
46
- skipCheckingFunctionOverloading?: boolean;
47
47
  addToBeginBlockFrame?: boolean;
48
+ allowVariableShadowing?: boolean;
48
49
  }): {
49
50
  env: Environment;
50
51
  variable: Variable;
@@ -69,8 +70,8 @@ export declare function getVariableInfo(variable: Variable): {
69
70
  value: string;
70
71
  isCompileTimeOnly: boolean;
71
72
  isUndefined: boolean;
72
- isOwningTheGcValue: boolean;
73
- isOwningTheSameGcValueAs: string | undefined;
73
+ isOwningTheRcValue: boolean;
74
+ isOwningTheSameRcValueAs: string | undefined;
74
75
  isReassignable: boolean;
75
76
  isConsumed: boolean;
76
77
  };
@@ -3,6 +3,7 @@ export interface TokenAndError {
3
3
  token: Token;
4
4
  errorMessage: string;
5
5
  }
6
+ export type ErrorKind = "overflow";
6
7
  export declare class YoLexerError {
7
8
  characterIndex: number;
8
9
  message: string;
@@ -14,7 +15,8 @@ export declare class YoLexerError {
14
15
  export declare class YoError {
15
16
  tokenAndErrorList: TokenAndError[];
16
17
  isAssertionError: boolean;
17
- constructor(tokenAndErrorList: TokenAndError[], isAssertionError?: boolean);
18
+ kind?: ErrorKind;
19
+ constructor(tokenAndErrorList: TokenAndError[], isAssertionError?: boolean, kind?: ErrorKind);
18
20
  toString(): string;
19
21
  }
20
22
  export declare function getLineAtToken({ token }: {
@@ -28,13 +30,14 @@ export declare function getLineAtPosition({ modulePath, inputString, position, }
28
30
  column: number;
29
31
  };
30
32
  }): string;
31
- export declare function formatErrorMessage({ token, errorMessage, cause, isAssertionError, }: {
33
+ export declare function formatErrorMessage({ token, errorMessage, cause, isAssertionError, kind, }: {
32
34
  token: Token;
33
35
  errorMessage: string;
34
36
  cause?: Error;
35
37
  isAssertionError?: boolean;
38
+ kind?: ErrorKind;
36
39
  }): YoError;
37
- export declare function formatErrorMessages(tokenAndErrorList: TokenAndError[], isAssertionError?: boolean): YoError;
40
+ export declare function formatErrorMessages(tokenAndErrorList: TokenAndError[], isAssertionError?: boolean, kind?: ErrorKind): YoError;
38
41
  export declare function formatWarningMessages({ warningMessage, tokenAndWarningList, }: {
39
42
  warningMessage?: string;
40
43
  tokenAndWarningList: {
@@ -14,7 +14,7 @@ export interface CapturedVariable {
14
14
  name: string;
15
15
  type: Type;
16
16
  kind: "local" | "outer";
17
- isOwningTheSameGcValueAs: CapturedVariable | undefined;
17
+ isOwningTheSameRcValueAs: CapturedVariable | undefined;
18
18
  }
19
19
  export interface AwaitAnalysisResult {
20
20
  awaitPoints: AwaitPoint[];
@@ -56,3 +56,23 @@ export declare function evaluateYoIsoDispose({ expr, env, context, }: {
56
56
  env: Environment;
57
57
  context: EvaluatorContext;
58
58
  }): Expr;
59
+ export declare function evaluateYoDropArrayElement({ expr, env, context, }: {
60
+ expr: FuncCallExpr;
61
+ env: Environment;
62
+ context: EvaluatorContext;
63
+ }): Expr;
64
+ export declare function evaluateYoDupArrayElement({ expr, env, context, }: {
65
+ expr: FuncCallExpr;
66
+ env: Environment;
67
+ context: EvaluatorContext;
68
+ }): Expr;
69
+ export declare function evaluateYoDropTupleElement({ expr, env, context, }: {
70
+ expr: FuncCallExpr;
71
+ env: Environment;
72
+ context: EvaluatorContext;
73
+ }): Expr;
74
+ export declare function evaluateYoDupTupleElement({ expr, env, context, }: {
75
+ expr: FuncCallExpr;
76
+ env: Environment;
77
+ context: EvaluatorContext;
78
+ }): Expr;
@@ -0,0 +1,8 @@
1
+ import { Environment } from "../../env";
2
+ import { FuncCallExpr } from "../../expr";
3
+ import { EvaluatorContext } from "../context";
4
+ export declare function evaluateYoArrayFill({ expr, env, context, }: {
5
+ expr: FuncCallExpr;
6
+ env: Environment;
7
+ context: EvaluatorContext;
8
+ }): FuncCallExpr;
@@ -11,12 +11,12 @@ export declare function evaluateYoAreTypesCompatible({ expr, env, context, }: {
11
11
  env: Environment;
12
12
  context: EvaluatorContext;
13
13
  }): FuncCallExpr;
14
- export declare function evaluateYoTypeContainsGcType({ expr, env, context, }: {
14
+ export declare function evaluateYoTypeContainsRcType({ expr, env, context, }: {
15
15
  expr: FuncCallExpr;
16
16
  env: Environment;
17
17
  context: EvaluatorContext;
18
18
  }): FuncCallExpr;
19
- export declare function evaluateYoTypeCanFormGcCycle({ expr, env, context, }: {
19
+ export declare function evaluateYoTypeCanFormRcCycle({ expr, env, context, }: {
20
20
  expr: FuncCallExpr;
21
21
  env: Environment;
22
22
  context: EvaluatorContext;
@@ -6,7 +6,7 @@ export declare function evaluateYoVarPrintInfo({ expr, env, context, }: {
6
6
  env: Environment;
7
7
  context: EvaluatorContext;
8
8
  }): FuncCallExpr;
9
- export declare function evaluateYoVarIsOwningTheGcValue({ expr, env, context, }: {
9
+ export declare function evaluateYoVarIsOwningTheRcValue({ expr, env, context, }: {
10
10
  expr: FuncCallExpr;
11
11
  env: Environment;
12
12
  context: EvaluatorContext;
@@ -2,6 +2,10 @@ import { Environment } from "../../env";
2
2
  import { Expr, FuncCallExpr } from "../../expr";
3
3
  import { Type } from "../../types";
4
4
  import { EvaluatorContext } from "../context";
5
+ export declare function getNumericBounds(type: Type): {
6
+ min: number | bigint;
7
+ max: number | bigint;
8
+ } | undefined;
5
9
  export declare function isConvertibleNumericType(type: Type): boolean;
6
10
  export declare function tryToConvertToNumericType({ targetType, argExpr, expr, callerEnv, context, }: {
7
11
  targetType: Type;
@@ -15,40 +15,40 @@ export declare function addFunctionCodeToSelfTypeModule({ label, functionCode, S
15
15
  env: Environment;
16
16
  context: EvaluatorContext;
17
17
  }): Environment;
18
- export declare const DisposeFnSignature = "(fn(self : Self) -> unit)";
19
- export declare const DropFnSignature = "(fn(self : Self) -> unit)";
20
- export declare const DupFnSignature = "(fn(self : Self) -> Self)";
21
- export declare function addARCFunctionsToStructType({ structType, env, context, }: {
18
+ export declare const DisposeFnSignature = "(fn(__yo_self : Self) -> unit)";
19
+ export declare const DropFnSignature = "(fn(__yo_self : Self) -> unit)";
20
+ export declare const DupFnSignature = "(fn(__yo_self : Self) -> Self)";
21
+ export declare function addRcFunctionsToStructType({ structType, env, context, }: {
22
22
  structType: StructType;
23
23
  env: Environment;
24
24
  context: EvaluatorContext;
25
25
  }): Environment;
26
- export declare function addARCFunctionSignaturesToStructType({ structType, env, context, }: {
26
+ export declare function addRcFunctionSignaturesToStructType({ structType, env, context, }: {
27
27
  structType: StructType;
28
28
  env: Environment;
29
29
  context: EvaluatorContext;
30
30
  }): void;
31
- export declare function addARCFunctionsToEnumType({ enumType, env, context, }: {
31
+ export declare function addRcFunctionsToEnumType({ enumType, env, context, }: {
32
32
  enumType: EnumType;
33
33
  env: Environment;
34
34
  context: EvaluatorContext;
35
35
  }): Environment;
36
- export declare function addARCFunctionSignaturesToEnumType({ enumType, env, context, }: {
36
+ export declare function addRcFunctionSignaturesToEnumType({ enumType, env, context, }: {
37
37
  enumType: EnumType;
38
38
  env: Environment;
39
39
  context: EvaluatorContext;
40
40
  }): void;
41
- export declare function addARCFunctionsToDynType({ dynType, env, context, }: {
41
+ export declare function addRcFunctionsToDynType({ dynType, env, context, }: {
42
42
  dynType: DynType;
43
43
  env: Environment;
44
44
  context: EvaluatorContext;
45
45
  }): Environment;
46
- export declare function addARCFunctionsToSomeType({ someType, env, context, }: {
46
+ export declare function addRcFunctionsToSomeType({ someType, env, context, }: {
47
47
  someType: SomeType;
48
48
  env: Environment;
49
49
  context: EvaluatorContext;
50
50
  }): Environment;
51
- export declare function addARCFunctionsToIsoType({ isoType, env, context, }: {
51
+ export declare function addRcFunctionsToIsoType({ isoType, env, context, }: {
52
52
  isoType: IsoType;
53
53
  env: Environment;
54
54
  context: EvaluatorContext;
@@ -1,4 +1,4 @@
1
1
  import { Environment, Variable } from "../env";
2
2
  import { Expr } from "../expr";
3
3
  export declare function isValidVariableName(expr: Expr): boolean;
4
- export declare function findGcValueOwnerRelationship(rhs: Expr, env: Environment, _modulePath: string): Variable | undefined;
4
+ export declare function findRcValueOwnerRelationship(rhs: Expr, env: Environment, _modulePath: string): Variable | undefined;
@@ -138,6 +138,7 @@ export declare const BuiltinFunctions: {
138
138
  compt_assert: string[];
139
139
  compt_print: string[];
140
140
  va_start: string[];
141
+ __yo_array_fill: string[];
141
142
  typeof: string[];
142
143
  sizeof: string[];
143
144
  alignof: string[];
@@ -389,12 +390,12 @@ export declare const BuiltinFunctions: {
389
390
  __yo_compt_string_to_lower: string[];
390
391
  __yo_compt_string_slice: string[];
391
392
  __yo_type_to_string: string[];
392
- __yo_type_contains_gc_type: string[];
393
- __yo_type_can_form_gc_cycle: string[];
393
+ __yo_type_contains_rc_type: string[];
394
+ __yo_type_can_form_rc_cycle: string[];
394
395
  __yo_are_types_compatible: string[];
395
396
  __yo_type_impls: string[];
396
397
  __yo_var_print_info: string[];
397
- __yo_var_is_owning_the_gc_value: string[];
398
+ __yo_var_is_owning_the_rc_value: string[];
398
399
  __yo_var_has_other_aliases: string[];
399
400
  __yo_op_add: string[];
400
401
  __yo_op_sub: string[];
@@ -433,6 +434,10 @@ export declare const BuiltinFunctions: {
433
434
  ___dispose: string[];
434
435
  ___dup: string[];
435
436
  dispose: string[];
437
+ __yo_drop_array_element: string[];
438
+ __yo_dup_array_element: string[];
439
+ __yo_drop_tuple_element: string[];
440
+ __yo_dup_tuple_element: string[];
436
441
  __yo_noop: string[];
437
442
  __yo_return_self: string[];
438
443
  __yo_ms_sleep: string[];
@@ -445,7 +450,7 @@ export interface ExprToStringConfig {
445
450
  indentLevel?: number;
446
451
  }
447
452
  export declare function exprToString(expr: Expr, config?: ExprToStringConfig): string;
448
- export declare function attachTempVariableToExpr(expr: Expr, isOwningTheGcValue: boolean, isOwningTheSameGcValueAs?: Variable): void;
453
+ export declare function attachTempVariableToExpr(expr: Expr, isOwningTheRcValue: boolean, isOwningTheSameRcValueAs?: Variable): void;
449
454
  export declare function mergeAndCheckEnvs(env: Environment, bodies: Expr[]): Environment;
450
455
  export declare function replaceFuncCallExprWithFuncCallExpr(funcExpr: FuncCallExpr, newFuncExpr: FuncCallExpr): void;
451
456
  export declare function replaceFuncCallExprWithAtomExpr(funcExpr: FuncCallExpr, newAtomExpr: AtomExpr): void;
@@ -58,7 +58,7 @@ export declare function createIsoType(childType: Type, env: Environment): IsoTyp
58
58
  export declare function createSomeType(type: TypeHierarchyType, variableName: string, id?: string, requiredModules?: ModuleType[], negativeModules?: ModuleType[], recursiveTypeRef?: {
59
59
  functionValue: FunctionValue;
60
60
  argValues: Value[];
61
- }): SomeType;
61
+ }, env?: Environment): SomeType;
62
62
  export declare function createTypeHierarchy(level: number, baseType?: Type): TypeHierarchyType;
63
63
  export declare function getFunctionParameterExprs({ expr, labelExpr, typeExpr, defaultValueExpr, assignedValueExpr, }: {
64
64
  expr: Expr;
@@ -93,7 +93,7 @@ export interface FunctionParameter {
93
93
  type: Type;
94
94
  isCompileTimeOnly: boolean;
95
95
  isQuote: boolean;
96
- isOwningTheGcValue: boolean;
96
+ isOwningTheRcValue: boolean;
97
97
  exprs: FunctionParameterExprs;
98
98
  assignedValue?: Value;
99
99
  }
@@ -44,7 +44,7 @@ export declare function isSomeType(type?: Type): type is SomeType;
44
44
  export declare function isPtrType(type?: Type): type is PtrType;
45
45
  export declare function isIsoType(type?: Type): type is IsoType;
46
46
  export declare function isDynType(type?: Type): type is DynType;
47
- export declare function isGcType(type?: Type): boolean;
47
+ export declare function isRcType(type?: Type): boolean;
48
48
  export declare function isIntegerType(type?: Type): boolean;
49
49
  export declare function isFloatType(type?: Type): boolean;
50
50
  export declare function isSignedIntegerType(type?: Type): boolean;
@@ -19,8 +19,9 @@ export declare function typeImplementsFuture(type: Type | undefined): type is (S
19
19
  export declare function extractFutureModuleFromType(type: Type): FutureModuleType | undefined;
20
20
  export declare function typeRequiresComptModifier(type?: Type): boolean;
21
21
  export declare function typeProhibitsComptModifier(type?: Type): boolean;
22
- export declare function typeContainsGcType(type?: Type, checkedTypes?: Type[]): boolean;
22
+ export declare function typeContainsRcType(type?: Type, checkedTypes?: Type[]): boolean;
23
23
  export declare function typeContainsSomeType(type?: Type, checkedTypes?: Type[]): boolean;
24
+ export declare function typeContainsUnknownValue(type: Type): boolean;
24
25
  export declare function getAllSomeTypes(type: Type): Set<SomeType>;
25
26
  export declare function typeRequiresInference(type?: Type): boolean;
26
27
  export declare function getValueOfSomeTypeFromEnv(env: Environment, someType: SomeType): Type;
@@ -46,5 +47,5 @@ export declare function getTargetPointerSizeBytes(): number;
46
47
  export declare function getAlignmentOfType(type: Type): number | null;
47
48
  export declare function getSizeOfType(type: Type): number | null;
48
49
  export declare function prohibitVoidType(type: Type, token: Token): void;
49
- export declare function canTypeFormGcCycle(type: Type, visitedTypes?: Set<string>): boolean;
50
+ export declare function canTypeFormRcCycle(type: Type, visitedTypes?: Set<string>): boolean;
50
51
  export declare function typeContainsSelfTypeForDynamicDispatchCheck(type: Type, selfType: Type | undefined): boolean;
@@ -1,6 +1,8 @@
1
- export declare function randomId(): string;
2
1
  export declare function generateModuleId(modulePath: string): string;
2
+ export declare function randomId(modulePath: string): string;
3
+ export declare function resetModuleIdCounter(modulePath: string): void;
3
4
  export declare function generateNewTempVariableName(modulePath: string): string;
4
5
  export declare function isTempVariableName(modulePath: string, variableName: string): boolean;
5
6
  export declare function generateVarialeId(modulePath: string, variableName: string): string;
6
7
  export declare function hashString(input: string): string;
8
+ export declare function clearAllModuleCounters(): void;
@@ -13,7 +13,7 @@ export type ComptStringValue = {
13
13
  export type NumberValue = {
14
14
  tag: ValueTag.ComptInt | ValueTag.ComptFloat | ValueTag.U8 | ValueTag.I8 | ValueTag.U16 | ValueTag.I16 | ValueTag.U32 | ValueTag.I32 | ValueTag.U64 | ValueTag.I64 | ValueTag.F32 | ValueTag.F64 | ValueTag.Usize | ValueTag.Isize;
15
15
  type: Type;
16
- value: number;
16
+ value: number | bigint;
17
17
  };
18
18
  export type BooleanValue = {
19
19
  tag: ValueTag.Bool;
@@ -83,12 +83,12 @@ export declare function isExprValue(value?: Value): value is ExprValue;
83
83
  export declare function createTypeValue(value: Type): TypeValue;
84
84
  export declare function createComptStringValue(value: string): ComptStringValue;
85
85
  export declare function createComptListValue(childType: Type, elements: Value[]): ComptListValue;
86
- export declare function createNumberValue(tag: NumberValue["tag"], value: number): {
86
+ export declare function createNumberValue(tag: NumberValue["tag"], value: number | bigint): {
87
87
  tag: ValueTag.ComptInt | ValueTag.ComptFloat | ValueTag.U8 | ValueTag.I8 | ValueTag.U16 | ValueTag.I16 | ValueTag.U32 | ValueTag.I32 | ValueTag.U64 | ValueTag.I64 | ValueTag.F32 | ValueTag.F64 | ValueTag.Usize | ValueTag.Isize;
88
88
  type: Type;
89
- value: number;
89
+ value: number | bigint;
90
90
  };
91
- export declare function createComptIntValue(value: number): NumberValue;
91
+ export declare function createComptIntValue(value: bigint): NumberValue;
92
92
  export declare function createComptFloatValue(value: number): NumberValue;
93
93
  export declare function createBooleanValue(value: boolean): BooleanValue;
94
94
  export declare function createUnknownValue(type: Type, variableName?: string, recursiveTypeRef?: {