public Node declare(ISourcePosition position, String name, int depth) { int slot = exists(name); if (slot >= 0) { return isBlockOrEval ? new DVarNode(position, ((depth << 16) | slot), name) : new LocalVarNode(position, ((depth << 16) | slot), name); } return isBlockOrEval ? enclosingScope.declare(position, name, depth + 1) : new VCallNode(position, name); }
public Node declare(ISourcePosition position, String name, int depth) { int slot = exists(name); if (slot >= 0) { return isBlockOrEval ? new DVarNode(position, ((depth << 16) | slot), name) : new LocalVarNode(position, ((depth << 16) | slot), name); } return isBlockOrEval ? enclosingScope.declare(position, name, depth + 1) : new VCallNode(position, name); }
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 isBlockOrEval ? new DAsgnNode(position, name, ((depth << 16) | slot), value) : new LocalAsgnNode(position, name, ((depth << 16) | slot), value); } else if (!isBlockOrEval && (topScope == this)) { slot = addVariable(name); return new LocalAsgnNode(position, name, slot , value); } // If we are not a block-scope and we go there, we know that 'topScope' 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 isBlockOrEval ? enclosingScope.assign(position, name, value, topScope, depth + 1) : ((IRStaticScope)topScope).addAssign(position, name, value); }
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 isBlockOrEval ? new DAsgnNode(position, name, ((depth << 16) | slot), value) : new LocalAsgnNode(position, name, ((depth << 16) | slot), value); } else if (!isBlockOrEval && (topScope == this)) { slot = addVariable(name); return new LocalAsgnNode(position, name, slot , value); } // If we are not a block-scope and we go there, we know that 'topScope' 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 isBlockOrEval ? enclosingScope.assign(position, name, value, topScope, depth + 1) : ((IRStaticScope)topScope).addAssign(position, name, value); }