/** * Add a new named capture variable to this (current) scope. * * @param name name of variable. * @return index of variable */ public int addNamedCaptureVariable(String name) { int index = addVariableThisScope(name); growNamedCaptures(index); return index; }
/** * Add a new named capture variable to this (current) scope. * * @param name name of variable. * @return index of variable */ public int addNamedCaptureVariable(String name) { int index = addVariableThisScope(name); growNamedCaptures(index); return index; }
public IRubyObject arg_var(IRubyObject identifier) { String name = lexer.getIdent(); StaticScope current = getCurrentScope(); // Multiple _ arguments are allowed. To not screw with tons of arity // issues in our runtime we will allocate unnamed bogus vars so things // still work. MRI does not use name as intern'd value so they don't // have this issue. if (name == "_") { int count = 0; while (current.exists(name) >= 0) { name = "_$" + count++; } } current.addVariableThisScope(name); return identifier; }
public IRubyObject arg_var(IRubyObject identifier) { String name = lexer.getIdent(); StaticScope current = getCurrentScope(); // Multiple _ arguments are allowed. To not screw with tons of arity // issues in our runtime we will allocate unnamed bogus vars so things // still work. MRI does not use name as intern'd value so they don't // have this issue. if (name == "_") { int count = 0; while (current.exists(name) >= 0) { name = "_$" + count++; } } current.addVariableThisScope(name); return identifier; }
private List<Integer> allocateNamedLocals(RegexpNode regexpNode) { String[] names = regexpNode.loadPattern(configuration.getRuntime()).getNames(); int length = names.length; List<Integer> locals = new ArrayList<Integer>(); StaticScope scope = getCurrentScope(); for (int i = 0; i < length; i++) { // TODO: Pass by non-local-varnamed things but make sure consistent with list we get from regexp if (RubyYaccLexer.getKeyword(names[i]) == null) { int slot = scope.isDefined(names[i]); if (slot >= 0) { locals.add(slot); } else { locals.add(getCurrentScope().addVariableThisScope(names[i])); } } } return locals; }
private List<Integer> allocateNamedLocals(RegexpNode regexpNode) { String[] names = regexpNode.loadPattern(configuration.getRuntime()).getNames(); int length = names.length; List<Integer> locals = new ArrayList<Integer>(); StaticScope scope = getCurrentScope(); for (int i = 0; i < length; i++) { // TODO: Pass by non-local-varnamed things but make sure consistent with list we get from regexp if (RubyYaccLexer.getKeyword(names[i]) == null) { int slot = scope.isDefined(names[i]); if (slot >= 0) { locals.add(slot); } else { locals.add(getCurrentScope().addVariableThisScope(names[i])); } } } return locals; }
public AssignableNode assignableInCurr(ByteList nameBytes, Node value) { RubySymbol name = symbolID(nameBytes); currentScope.addVariableThisScope(name.idString()); return currentScope.assign(lexer.getPosition(), name, makeNullNil(value)); }
public AssignableNode assignableInCurr(ByteList nameBytes, Node value) { RubySymbol name = symbolID(nameBytes); currentScope.addVariableThisScope(name.idString()); return currentScope.assign(lexer.getPosition(), name, makeNullNil(value)); }
public ArgumentNode arg_var(ByteList id) { RubySymbol name = symbolID(id); return new ArgumentNode(lexer.getPosition(), name, getCurrentScope().addVariableThisScope(name.idString())); }
public ArgumentNode arg_var(ByteList id) { RubySymbol name = symbolID(id); return new ArgumentNode(lexer.getPosition(), name, getCurrentScope().addVariableThisScope(name.idString())); }
public LocalVariable getNewLocalVariable(RubySymbol name, int depth) { if (depth == 0 && !(this instanceof IRFor)) { LocalVariable lvar = new ClosureLocalVariable(name, 0, getStaticScope().addVariableThisScope(name.idString())); localVars.put(name, lvar); return lvar; } else { // IRFor does not have it's own state if (!(this instanceof IRFor)) flags.add(IRFlags.ACCESS_PARENTS_LOCAL_VARIABLES); IRScope s = this; int d = depth; do { // account for for-loops while (s instanceof IRFor) { depth++; s = s.getLexicalParent(); } // walk up d--; if (d >= 0) s = s.getLexicalParent(); } while (d >= 0); return s.getNewLocalVariable(name, 0).cloneForDepth(depth); } }
public ArgumentNode arg_var(Token identifier) { String name = (String) identifier.getValue(); StaticScope current = getCurrentScope(); // Multiple _ arguments are allowed. To not screw with tons of arity // issues in our runtime we will allocate unnamed bogus vars so things // still work. MRI does not use name as intern'd value so they don't // have this issue. if (name == "_") { int count = 0; while (current.exists(name) >= 0) { name = "_$" + count++; } } return new ArgumentNode(identifier.getPosition(), name, current.addVariableThisScope(name)); }
public LocalVariable getNewLocalVariable(RubySymbol name, int depth) { if (depth == 0 && !(this instanceof IRFor)) { LocalVariable lvar = new ClosureLocalVariable(name, 0, getStaticScope().addVariableThisScope(name.idString())); localVars.put(name, lvar); return lvar; } else { // IRFor does not have it's own state if (!(this instanceof IRFor)) flags.add(IRFlags.ACCESS_PARENTS_LOCAL_VARIABLES); IRScope s = this; int d = depth; do { // account for for-loops while (s instanceof IRFor) { depth++; s = s.getLexicalParent(); } // walk up d--; if (d >= 0) s = s.getLexicalParent(); } while (d >= 0); return s.getNewLocalVariable(name, 0).cloneForDepth(depth); } }
public ArgumentNode arg_var(Token identifier) { String name = (String) identifier.getValue(); StaticScope current = getCurrentScope(); // Multiple _ arguments are allowed. To not screw with tons of arity // issues in our runtime we will allocate unnamed bogus vars so things // still work. MRI does not use name as intern'd value so they don't // have this issue. if (name == "_") { int count = 0; while (current.exists(name) >= 0) { name = "_$" + count++; } } return new ArgumentNode(identifier.getPosition(), name, current.addVariableThisScope(name)); }