/** * Is this name in the visible to the current scope * * @param name to be looked for * @return a location where the left-most 16 bits of number of scopes down it is and the * right-most 16 bits represents its index in that scope */ public int isDefined(String name) { return isDefined(name, 0); }
/** * Is this name in the visible to the current scope * * @param name to be looked for * @return a location where the left-most 16 bits of number of scopes down it is and the * right-most 16 bits represents its index in that scope */ public int isDefined(String name) { return isDefined(name, 0); }
/** * Is this name in the visible to the current scope * * @param name to be looked for * @return a location where the left-most 16 bits of number of scopes down it is and the * right-most 16 bits represents its index in that scope */ public int isDefined(String name) { return isDefined(name, 0); }
/** * Is this name in the visible to the current scope * * @param name to be looked for * @return a location where the left-most 16 bits of number of scopes down it is and the * right-most 16 bits represents its index in that scope */ public int isDefined(String name) { return isDefined(name, 0); }
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 int isDefined(String name, int depth) { int slot = exists(name); if (slot >= 0) return (depth << 16) | slot; return enclosingScope.isDefined(name, depth + 1); }
public boolean is_id_var() { String ident = lexer.getIdent().intern(); return getCurrentScope().isDefined(ident) >= 0; }
public int isDefined(String name, int depth) { if (isBlockOrEval) { int slot = exists(name); if (slot >= 0) return (depth << 16) | slot; return enclosingScope.isDefined(name, depth + 1); } else { return (depth << 16) | exists(name); } }
public int isDefined(String name, int depth) { if (isBlockOrEval) { int slot = exists(name); if (slot >= 0) return (depth << 16) | slot; return enclosingScope.isDefined(name, depth + 1); } else { return (depth << 16) | exists(name); } }
private int identifierToken(int last_state, int result, String value) { if (result == RipperParser.tIDENTIFIER && !isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parser.getCurrentScope().isDefined(value) >= 0) { setState(EXPR_END|EXPR_LABEL); } identValue = value.intern(); return result; }
public int tokenize_ident(int result) { String value = createTokenString(); if (!isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parser.getCurrentScope().isDefined(value) >= 0) { setState(EXPR_END); } identValue = value.intern(); return result; }
private int identifierToken(int result, String value) { if (result == Tokens.tIDENTIFIER && last_state != LexState.EXPR_DOT && parserSupport.getCurrentScope().isDefined(value) >= 0) { setState(LexState.EXPR_END); } yaccValue = new Token(value, result, getPosition()); return result; }
@JRubyMethod public IRubyObject local_variable_set(ThreadContext context, IRubyObject symbol, IRubyObject value) { String name = symbol.asJavaString().intern(); DynamicScope evalScope = binding.getEvalScope(context.runtime); int slot = evalScope.getStaticScope().isDefined(name); if (slot == -1) { // Yay! New variable associated with this binding slot = evalScope.getStaticScope().addVariable(name.intern()); evalScope.growIfNeeded(); } return evalScope.setValue(slot & 0xffff, value, slot >> 16); }
@JRubyMethod public IRubyObject local_variable_get(ThreadContext context, IRubyObject symbol) { String name = symbol.asJavaString().intern(); DynamicScope evalScope = binding.getEvalScope(context.runtime); int slot = evalScope.getStaticScope().isDefined(name); if (slot == -1) throw context.runtime.newNameError("local variable `" + name + "' not defined for " + inspect(), name); return evalScope.getValueOrNil(slot & 0xffff, slot >> 16, context.nil); }
@JRubyMethod(name = "local_variable_defined?") public IRubyObject local_variable_defined_p(ThreadContext context, IRubyObject symbol) { return context.runtime.newBoolean(binding.getEvalScope(context.runtime).getStaticScope().isDefined(symbol.asJavaString()) != -1); }
@JRubyMethod public IRubyObject local_variable_get(ThreadContext context, IRubyObject symbol) { String name = symbol.asJavaString().intern(); DynamicScope evalScope = binding.getEvalScope(context.runtime); int slot = evalScope.getStaticScope().isDefined(name); if (slot == -1) throw context.runtime.newNameError("local variable `" + name + "' not defined for " + inspect(), name); return evalScope.getValueOrNil(slot & 0xffff, slot >> 16, context.nil); }
@Deprecated public String shadowing_lvar(String name) { if (name == "_") return name; StaticScope current = getCurrentScope(); if (current.exists(name) >= 0) yyerror("duplicated argument name"); if (current.isBlockScope() && warnings.isVerbose() && current.isDefined(name) >= 0 && Options.PARSER_WARN_LOCAL_SHADOWING.load()) { warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getPosition(), "shadowing outer local variable - " + name); } return name; }
private int identifierToken(int result, ByteList value) { Ruby runtime = parserSupport.getConfiguration().getRuntime(); String id = runtime.newSymbol(value).idString(); if (result == RubyParser.tIDENTIFIER && !isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parserSupport.getCurrentScope().isDefined(id) >= 0) { setState(EXPR_END|EXPR_LABEL); } yaccValue = value; return result; }
@Override public Object execute(ParserSupport support, RubyYaccLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { String identifier = (String) ((Token)yyVals[-2+yyTop]).getValue(); if (support.getCurrentScope().getLocalScope().isDefined(identifier) >= 0) { support.yyerror("duplicate optional argument name"); } support.getCurrentScope().getLocalScope().addVariable(identifier); yyVal = support.assignable(((Token)yyVals[-2+yyTop]), ((Node)yyVals[0+yyTop])); return yyVal; } };
public BlockArgNode newBlockArg(ISourcePosition position, Token nameToken) { String identifier = (String) nameToken.getValue(); if (getCurrentScope().getLocalScope().isDefined(identifier) >= 0) { throw new SyntaxException(PID.BAD_IDENTIFIER, position, lexer.getCurrentLine(), "duplicate block argument name"); } return new BlockArgNode(position, getCurrentScope().getLocalScope().addVariable(identifier), identifier); }