public AssignableNode assign(ISourcePosition position, RubySymbol symbolID, Node value, StaticScope topScope, int depth) { String id = symbolID.idString(); int slot = exists(id); // 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, symbolID, ((depth << 16) | slot), value) : new LocalAsgnNode(position, symbolID, ((depth << 16) | slot), value); } else if (!isBlockOrEval && (topScope == this)) { slot = addVariable(id); return new LocalAsgnNode(position, symbolID, 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, symbolID, value, topScope, depth + 1) : topScope.addAssign(position, symbolID, value); }
public AssignableNode assign(ISourcePosition position, RubySymbol symbolID, Node value, StaticScope topScope, int depth) { String id = symbolID.idString(); int slot = exists(id); // 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, symbolID, ((depth << 16) | slot), value) : new LocalAsgnNode(position, symbolID, ((depth << 16) | slot), value); } else if (!isBlockOrEval && (topScope == this)) { slot = addVariable(id); return new LocalAsgnNode(position, symbolID, 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, symbolID, value, topScope, depth + 1) : topScope.addAssign(position, symbolID, value); }