globals accepts {} too
This commit is contained in:
parent
4258503c0e
commit
bae0da31c2
|
|
@ -58,9 +58,9 @@ export class Compiler {
|
|||
bytecode: Bytecode
|
||||
pipeCounter = 0
|
||||
|
||||
constructor(public input: string, globals?: string[]) {
|
||||
constructor(public input: string, globals?: string[] | Record<string, any>) {
|
||||
try {
|
||||
if (globals) setGlobals(globals)
|
||||
if (globals) setGlobals(Array.isArray(globals) ? globals : Object.keys(globals))
|
||||
const cst = parser.parse(input)
|
||||
const errors = checkTreeForErrors(cst)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ export function specializeKeyword(ident: string) {
|
|||
|
||||
// tell the dotGet searcher about builtin globals
|
||||
export const globals: string[] = []
|
||||
export const setGlobals = (newGlobals: string[]) => {
|
||||
export const setGlobals = (newGlobals: string[] | Record<string, any>) => {
|
||||
globals.length = 0
|
||||
globals.push(...newGlobals)
|
||||
globals.push(...(Array.isArray(newGlobals) ? newGlobals : Object.keys(newGlobals)))
|
||||
}
|
||||
|
||||
// The only chars that can't be words are whitespace, apostrophes, closing parens, and EOF.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user