ES6 Support Groundwork + Fixes #26

Merged
TopchetoEU merged 49 commits from ES6 into master 2024-09-05 14:26:07 +00:00
4 changed files with 22 additions and 0 deletions
Showing only changes of commit 6481e992fa - Show all commits

View File

@ -39,6 +39,14 @@ public class FunctionScope extends Scope {
return childVar;
}
@Override public boolean has(String name) {
if (locals.has(name)) return true;
if (captures.has(name)) return true;
if (parent != null) return parent.has(name);
return false;
}
public int localsCount() {
return locals.size();
}

View File

@ -15,4 +15,9 @@ public final class GlobalScope extends Scope {
@Override public int offset() {
return 0;
}
@Override public boolean has(String name) {
return false;
}
public GlobalScope() { super(); }
}

View File

@ -29,6 +29,13 @@ public class LocalScope extends Scope {
return null;
}
@Override public boolean has(String name) {
if (locals.has(name)) return true;
if (parent != null) return parent.has(name);
return false;
}
@Override public boolean end() {
if (!super.end()) return false;
@ -40,6 +47,7 @@ public class LocalScope extends Scope {
return () -> locals.iterator();
}
public LocalScope(Scope parent) {
super(parent);
}

View File

@ -35,6 +35,7 @@ public abstract class Scope {
* which could break the semantics of a capture
*/
public abstract VariableDescriptor get(String name, boolean capture);
public abstract boolean has(String name);
/**
* Gets the index offset from this scope to its children
*/