From 6e5b1bc8b997b64ce1421a14eb89d29d7168da7a Mon Sep 17 00:00:00 2001 From: = Date: Thu, 28 Mar 2024 09:40:37 -0700 Subject: [PATCH] temp disabled member expression evaluation (DEBUGGING) --- src/GigaScript/runtime/env.ts | 37 +++++++++++++++++++---------------- tests/main.g | 18 ----------------- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/src/GigaScript/runtime/env.ts b/src/GigaScript/runtime/env.ts index 5a7c980..0f25c1c 100644 --- a/src/GigaScript/runtime/env.ts +++ b/src/GigaScript/runtime/env.ts @@ -2,7 +2,7 @@ import { Value, DataConstructors, DataType, ObjectValue } from './types'; import * as NativeFunctions from '../native/functions'; import * as NativeValues from '../native/valueKeywords'; import { MemberExpr } from '../ast/expressions.ast'; -import { Identifier } from '../ast/literals.ast'; +import { Identifier, ObjectLiteral } from '../ast/literals.ast'; export function createGlobalScope(cwd: string): Environment { const env = new Environment(cwd); @@ -109,27 +109,30 @@ export default class Environment { value?: Value, property?: Identifier ): Value { - if (expr.object.kind === 'MemberExpr') - return this.lookupOrModifyObject( - expr.object as MemberExpr, - value, - expr.property as Identifier - ); + // if (expr.object.kind === 'MemberExpr') { + // console.log('complex object!'); + // return this.lookupOrModifyObject( + // expr.object as MemberExpr, + // value, + // expr.property as Identifier + // ); + // } - const varName = (expr.object as Identifier).symbol; - const env = this.resolve(varName); + // const varName = (expr.object as Identifier).symbol; + // const env = this.resolve(varName); - let oldVal = env.variables.get(varName) as ObjectValue; + // let oldVal = env.variables.get(varName) as ObjectValue; - const prop = property - ? property.symbol - : (expr.property as Identifier).symbol; - const currProp = (expr.property as Identifier).symbol; + // const prop = property + // ? property.symbol + // : (expr.property as Identifier).symbol; + // const currProp = (expr.property as Identifier).symbol; - if (value) oldVal.properties.set(prop, value); + // if (value) oldVal.properties.set(prop, value); - if (currProp) oldVal = oldVal.properties.get(currProp) as ObjectValue; + // if (currProp) oldVal = oldVal.properties.get(currProp) as ObjectValue; - return oldVal; + // return oldVal; + return DataConstructors.NULL(); } } diff --git a/tests/main.g b/tests/main.g index 8d43df3..3543fd3 100644 --- a/tests/main.g +++ b/tests/main.g @@ -1,12 +1,4 @@ -const test = 100; let string = "hello!"; - -func add(a, b) { - return a + b; -} - -print(add(1, 2)) - const obj = { x: 32, string, @@ -15,14 +7,4 @@ const obj = { } }; -print(obj.x) -print(obj.string) print(obj.complex.foo) - -try { - print("hello world!") - throw 'test' -} catch (e) { - print('an error was caught!') - print(e) -}