works
This commit is contained in:
parent
66807c02c9
commit
560a946745
|
|
@ -69,6 +69,10 @@ describe('compiler', () => {
|
||||||
test('function call', () => {
|
test('function call', () => {
|
||||||
expect(`add = fn a b: a + b; add 2 9`).toEvaluateTo(11)
|
expect(`add = fn a b: a + b; add 2 9`).toEvaluateTo(11)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('function call with no args', () => {
|
||||||
|
expect(`bloop = fn: 'bloop'; bloop`).toEvaluateTo('bloop')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('errors', () => {
|
describe('errors', () => {
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,6 @@ export class Compiler {
|
||||||
return [`TRY_LOAD ${value}`]
|
return [`TRY_LOAD ${value}`]
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now, just treat them all like identifiers
|
|
||||||
case terms.FunctionCallOrIdentifier: {
|
|
||||||
return [`TRY_LOAD ${value}`]
|
|
||||||
}
|
|
||||||
|
|
||||||
case terms.BinOp: {
|
case terms.BinOp: {
|
||||||
const { left, op, right } = getBinaryParts(node)
|
const { left, op, right } = getBinaryParts(node)
|
||||||
const instructions: string[] = []
|
const instructions: string[] = []
|
||||||
|
|
@ -138,6 +133,12 @@ export class Compiler {
|
||||||
return instructions
|
return instructions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case terms.FunctionCallOrIdentifier: {
|
||||||
|
// For now, just treat them all like identifiers, but we might
|
||||||
|
// need something like TRY_CALL in the future.
|
||||||
|
return [`TRY_LOAD ${value}`]
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
### Function Calls
|
### Function Calls
|
||||||
Stack order (bottom to top):
|
Stack order (bottom to top):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user