ES6 Object and assignment destructors + object stuff #28
@ -13,7 +13,7 @@ import me.topchetoeu.jscript.common.parsing.Source;
|
||||
|
||||
public class CompoundNode extends Node {
|
||||
public final Node[] statements;
|
||||
public final boolean hasScope;
|
||||
public boolean hasScope;
|
||||
public Location end;
|
||||
|
||||
@Override public void resolve(CompileResult target) {
|
||||
|
@ -107,6 +107,7 @@ public abstract class FunctionNode extends Node {
|
||||
this.end = end;
|
||||
this.params = params;
|
||||
this.body = body;
|
||||
this.body.hasScope = false;
|
||||
}
|
||||
|
||||
public static void compileWithName(Node stm, CompileResult target, boolean pollute, String name) {
|
||||
|
@ -19,6 +19,13 @@ public class FunctionScope extends Scope {
|
||||
|
||||
public final boolean passtrough;
|
||||
|
||||
@Override public boolean hasNonStrict(String name) {
|
||||
if (functionVarMap.containsKey(name)) return true;
|
||||
if (blacklistNames.contains(name)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public Variable define(Variable var, Location loc) {
|
||||
checkNotEnded();
|
||||
if (strictVarMap.containsKey(var.name)) throw alreadyDefinedErr(loc, var.name);
|
||||
@ -32,13 +39,6 @@ public class FunctionScope extends Scope {
|
||||
return variables.add(var);
|
||||
}
|
||||
}
|
||||
@Override public Variable defineStrict(Variable var, Location loc) {
|
||||
checkNotEnded();
|
||||
if (functionVarMap.containsKey(var.name)) throw alreadyDefinedErr(loc, var.name);
|
||||
if (blacklistNames.contains(var.name)) throw alreadyDefinedErr(loc, var.name);
|
||||
|
||||
return super.defineStrict(var, loc);
|
||||
}
|
||||
public Variable defineSpecial(Variable var, Location loc) {
|
||||
checkNotEnded();
|
||||
if (strictVarMap.containsKey(var.name)) throw alreadyDefinedErr(loc, var.name);
|
||||
|
@ -86,6 +86,11 @@ public class Scope {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this scope's function parent has a non-strict variable of the given name
|
||||
*/
|
||||
public boolean hasNonStrict(String name) { return false; }
|
||||
|
||||
/**
|
||||
* Defines an ES2015-style variable
|
||||
* @param readonly True if const, false if let
|
||||
@ -96,6 +101,7 @@ public class Scope {
|
||||
public Variable defineStrict(Variable var, Location loc) {
|
||||
checkNotEnded();
|
||||
if (strictVarMap.containsKey(var.name)) throw alreadyDefinedErr(loc, var.name);
|
||||
if (hasNonStrict(var.name)) throw alreadyDefinedErr(loc, var.name);
|
||||
|
||||
strictVarMap.put(var.name, var);
|
||||
return variables.add(var);
|
||||
|
Loading…
Reference in New Issue
Block a user