public override object Get(Token name) { if (EnvTracker.ContainsKey(name.Lexeme)) { var value = EnvTracker[name.Lexeme]; if (value.IsPrivate) { throw new RuntimeError(name, $"'{name.Lexeme}' is inaccessible due to it's protection level"); } return(ClassEnv.Values[name.Lexeme]); } if (ParentClass != null) { return(ParentClass.Get(name)); } throw new RuntimeError(name, $"Can't get undefined static property '{name.Lexeme}'"); }
public override void Set(Token name, object value) { if (EnvTracker.ContainsKey(name.Lexeme)) { var val = EnvTracker[name.Lexeme]; if (val.IsPrivate) { throw new RuntimeError(name, $"'{name.Lexeme}' is inaccessible due to it's protection level"); } ClassEnv.Values[name.Lexeme] = value; return; } else if (ParentClass != null) { Set(name, value); return; } else { throw new RuntimeError(name, $"Can't set proeprty on a class declaration'{name.Lexeme}'"); } }