public StaticScope newBlockScope(StaticScope parent) { return new BlockStaticScope(parent); }
public int isDefined(String name, int depth) { int slot = exists(name); if (slot >= 0) return (depth << 16) | slot; return enclosingScope.isDefined(name, depth + 1); }
public AssignableNode addAssign(ISourcePosition position, String name, Node value) { int slot = addVariable(name); // No bit math to store level since we know level is zero for this case return new DAsgnNode(position, name, slot, value); }
@Override public String toString() { return "BlockScope: " + super.toString() + "\n" + getEnclosingScope(); }
/** * @see org.jruby.parser.StaticScope#getAllNamesInScope() */ public String[] getAllNamesInScope() { String[] variables = enclosingScope.getAllNamesInScope(); String[] ourVariables = getVariables(); // we know variables cannot be null since localstaticscope will create a 0 length one. int newSize = variables.length + ourVariables.length; String[] names = new String[newSize]; System.arraycopy(variables, 0, names, 0, variables.length); System.arraycopy(ourVariables, 0, names, variables.length, ourVariables.length); return names; }
public AssignableNode assign(ISourcePosition position, String name, Node value, StaticScope topScope, int depth) { int slot = exists(name); // We can assign if we already have variable of that name here or we are the only // scope in the chain (which Local scopes always are). if (slot >= 0) { return new LocalAsgnNode(position, name, ((depth << 16) | slot), value); } else if (topScope == this) { slot = addVariable(name); return new LocalAsgnNode(position, name, slot , value); } // We know this is a block scope because a local scope cannot be within a local scope // If topScope was itself it would have created a LocalAsgnNode above. return ((BlockStaticScope) topScope).addAssign(position, name, value); }
public int isDefined(String name, int depth) { int slot = exists(name); if (slot >= 0) return (depth << 16) | slot; return enclosingScope.isDefined(name, depth + 1); }
public AssignableNode addAssign(ISourcePosition position, String name, Node value) { int slot = addVariable(name); // No bit math to store level since we know level is zero for this case return new DAsgnNode(position, name, slot, value); }
@Override public String toString() { return "BlockScope: " + super.toString() + "\n" + getEnclosingScope(); }
/** * @see org.jruby.parser.StaticScope#getAllNamesInScope() */ public String[] getAllNamesInScope() { String[] variables = enclosingScope.getAllNamesInScope(); String[] ourVariables = getVariables(); // we know variables cannot be null since localstaticscope will create a 0 length one. int newSize = variables.length + ourVariables.length; String[] names = new String[newSize]; System.arraycopy(variables, 0, names, 0, variables.length); System.arraycopy(ourVariables, 0, names, variables.length, ourVariables.length); return names; }
public AssignableNode assign(ISourcePosition position, String name, Node value, StaticScope topScope, int depth) { int slot = exists(name); // We can assign if we already have variable of that name here or we are the only // scope in the chain (which Local scopes always are). if (slot >= 0) { return new LocalAsgnNode(position, name, ((depth << 16) | slot), value); } else if (topScope == this) { slot = addVariable(name); return new LocalAsgnNode(position, name, slot , value); } // We know this is a block scope because a local scope cannot be within a local scope // If topScope was itself it would have created a LocalAsgnNode above. return ((BlockStaticScope) topScope).addAssign(position, name, value); }
public Node declare(ISourcePosition position, String name, int depth) { int slot = exists(name); if (slot >= 0) return new DVarNode(position, ((depth << 16) | slot), name); return enclosingScope.declare(position, name, depth + 1); }
public StaticScope newBlockScope(StaticScope parent, String[] names) { return new BlockStaticScope(parent, names); }
protected AssignableNode assign(ISourcePosition position, String name, Node value, StaticScope topScope, int depth) { int slot = exists(name); if (slot >= 0) return new DAsgnNode(position, name, ((depth << 16) | slot), value); return enclosingScope.assign(position, name, value, topScope, depth + 1); }
public StaticScope newBlockScope(StaticScope parent, String[] names) { return new BlockStaticScope(parent, names); }
public Node declare(ISourcePosition position, String name, int depth) { int slot = exists(name); if (slot >= 0) return new DVarNode(position, ((depth << 16) | slot), name); return enclosingScope.declare(position, name, depth + 1); }
public StaticScope newBlockScope(StaticScope parent) { return new BlockStaticScope(parent); }
protected AssignableNode assign(ISourcePosition position, String name, Node value, StaticScope topScope, int depth) { int slot = exists(name); if (slot >= 0) return new DAsgnNode(position, name, ((depth << 16) | slot), value); return enclosingScope.assign(position, name, value, topScope, depth + 1); }