a million fixes
This commit is contained in:
parent
b1696499e5
commit
c294d7fd6a
12 changed files with 140 additions and 168 deletions
|
|
@ -14,7 +14,8 @@ export const _rt = {
|
|||
mul: (a: number) => (b: number) => a * b,
|
||||
div: (a: number) => (b: number) => a / b,
|
||||
mod: (a: number) => (b: number) => a % b,
|
||||
cat: (a: string) => (b: string) => a + b,
|
||||
pow: (a: number) => (b: number) => a ** b,
|
||||
cat: (a: any) => (b: any) => Array.isArray(a) ? [...a, ...b] : a + b,
|
||||
max: (a: number) => (b: number) => Math.max(a, b),
|
||||
min: (a: number) => (b: number) => Math.min(a, b),
|
||||
|
||||
|
|
@ -110,7 +111,6 @@ export const _rt = {
|
|||
|
||||
batch: (events: any[]) => ({ _tag: 'Batch', _0: events }),
|
||||
noOp: { _tag: 'NoOp' },
|
||||
rerender: { _tag: 'Rerender' },
|
||||
focus: (key: string) => ({ _tag: 'Focus', _0: key }),
|
||||
|
||||
nth: (i: number) => (xs: any[] | string) => i >= 0 && i < xs.length
|
||||
|
|
@ -142,6 +142,7 @@ export const _rt = {
|
|||
return printed;
|
||||
},
|
||||
rebind: (name: string, pathOrValue: any, maybeValue?: any) => {
|
||||
console.log("rebind", store, name, pathOrValue, maybeValue);
|
||||
if (maybeValue === undefined) {
|
||||
store[name] = pathOrValue;
|
||||
} else {
|
||||
|
|
@ -202,12 +203,12 @@ export const _rt = {
|
|||
const defs = parser.parse();
|
||||
const ast = defs[0].body;
|
||||
// validate free vars
|
||||
const free = freeVars(ast);
|
||||
const allowed = new Set([
|
||||
...Object.keys(store),
|
||||
...Object.keys(_rt),
|
||||
'True'
|
||||
])
|
||||
// const free = freeVars(ast);
|
||||
// const allowed = new Set([
|
||||
// ...Object.keys(store),
|
||||
// ...Object.keys(_rt),
|
||||
// 'True'
|
||||
// ])
|
||||
|
||||
const compiled = compile(defs[0].body);
|
||||
const fn = new Function('_rt', 'store', `return ${compiled}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue