public Node(ISourcePosition position, boolean containsAssignment) { this.line = position.getLine(); this.containsVariableAssignment = containsAssignment; }
public void setFileAndLine(ISourcePosition position) { BacktraceElement b = backtrace[backtraceIndex]; b.filename = position.getFile(); b.line = position.getLine(); }
public void setFileAndLine(ISourcePosition position) { BacktraceElement b = backtrace[backtraceIndex]; b.filename = position.getFile(); b.line = position.getLine(); }
@Deprecated public static void update(BacktraceElement backtrace, String method, ISourcePosition position) { backtrace.method = method; backtrace.filename = position.getFile(); backtrace.line = position.getLine(); }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = new FixnumNode(lexer.tokline, lexer.tokline.getLine()+1); return yyVal; } };
@Deprecated public static void update(BacktraceElement backtrace, String method, ISourcePosition position) { backtrace.method = method; backtrace.filename = position.getFile(); backtrace.line = position.getLine(); }
/** * Prints a warning, only in verbose mode. */ @Override @Deprecated public void warning(ID id, ISourcePosition position, String message) { warning(id, position.getFile(), position.getLine(), message); }
/** * Wraps node with NEWLINE node. * *@param node */ public Node newline_node(Node node, ISourcePosition position) { if (node == null) return null; configuration.coverLine(position.getLine()); node.setNewline(); return node; }
public ISourcePosition getPosition() { if (tokline != null && ruby_sourceline == tokline.getLine()) return tokline; return new SimpleSourcePosition(getFile(), ruby_sourceline); }
/** * Prints a warning, unless $VERBOSE is nil. */ @Override @Deprecated public void warn(ID id, ISourcePosition position, String message) { if (!runtime.warningsEnabled()) return; warn(id, position.getFile(), position.getLine(), message); }
/** * Prints a warning, unless $VERBOSE is nil. */ @Override @Deprecated public void warn(ID id, ISourcePosition position, String message) { if (!runtime.warningsEnabled()) return; warn(id, position.getFile(), position.getLine(), message); }
public void compile_error(String message) { // mri: rb_compile_error_with_enc String line = lexer.getCurrentLine(); ISourcePosition position = lexer.getPosition(); String errorMessage = lexer.getFile() + ":" + (position.getLine() + 1) + ": "; if (line != null && line.length() > 5) { boolean addNewline = message != null && ! message.endsWith("\n"); message += (addNewline ? "\n" : "") + line; } throw getConfiguration().getRuntime().newSyntaxError(errorMessage + message); }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { Node body = ((Node)yyVals[-1+yyTop]); if (body == null) body = NilImplicitNode.NIL; yyVal = new DefsNode(((ISourcePosition)yyVals[-8+yyTop]), ((Node)yyVals[-7+yyTop]), support.symbolID(((ByteList)yyVals[-4+yyTop])), (ArgsNode) yyVals[-2+yyTop], support.getCurrentScope(), body, ((ISourcePosition)yyVals[0+yyTop]).getLine()); support.popCurrentScope(); support.setInDef(((Boolean)yyVals[-5+yyTop]).booleanValue()); lexer.setCurrentArg(((ByteList)yyVals[-3+yyTop])); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { Node body = support.makeNullNil(((Node)yyVals[-1+yyTop])); yyVal = new DefnNode(((ISourcePosition)yyVals[-6+yyTop]), support.symbolID(((ByteList)yyVals[-5+yyTop])), (ArgsNode) yyVals[-2+yyTop], support.getCurrentScope(), body, ((ISourcePosition)yyVals[0+yyTop]).getLine()); support.popCurrentScope(); support.setInDef(((Boolean)yyVals[-3+yyTop]).booleanValue()); lexer.setCurrentArg(((ByteList)yyVals[-4+yyTop])); return yyVal; } };
@Override public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) { ISourcePosition position = getPosition(); // something in here is used to build up ruby stack trace... context.setLine(position.getLine()); if (runtime.hasEventHooks()) { ASTInterpreter.callTraceFunction(runtime, context, RubyEvent.LINE); } // TODO: do above but not below for additional newline nodes return nextNode.interpret(runtime, context, self, aBlock); }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { Node body = support.makeNullNil(((Node)yyVals[-1+yyTop])); yyVal = new DefnNode(((ISourcePosition)yyVals[-6+yyTop]), support.symbolID(((ByteList)yyVals[-5+yyTop])), (ArgsNode) yyVals[-2+yyTop], support.getCurrentScope(), body, ((ISourcePosition)yyVals[0+yyTop]).getLine()); support.popCurrentScope(); support.setInDef(((Boolean)yyVals[-3+yyTop]).booleanValue()); lexer.setCurrentArg(((ByteList)yyVals[-4+yyTop])); return yyVal; } };
public InterpretedBlock(IterNode iterNode, Arity arity, int argumentType) { super(iterNode.getScope(), arity, argumentType); this.bodyNode = iterNode.getBodyNode() == null ? NilImplicitNode.NIL : iterNode.getBodyNode(); this.scope = iterNode.getScope(); this.position = iterNode.getPosition(); // precache these this.file = position.getFile(); this.line = position.getLine(); assignerFor(iterNode); }
public Interpreted19Block(IterNode iterNode) { super(iterNode.getScope(), ((ArgsNode)iterNode.getVarNode()).getArity(), -1); // We override that the logic which uses this this.args = (ArgsNode)iterNode.getVarNode(); this.needsSplat = Helpers.needsSplat19(args.getRequiredArgsCount(), args.getRestArg() != -1); this.parameterList = Helpers.encodeParameterList(args).split(";"); this.body = iterNode.getBodyNode() == null ? NilImplicitNode.NIL : iterNode.getBodyNode(); this.position = iterNode.getPosition(); // precache these this.file = position.getFile(); this.line = position.getLine(); }
public Interpreted19Block(LambdaNode lambdaNode) { super(lambdaNode.getScope(), lambdaNode.getArgs().getArity(), -1); // We override that the logic which uses this this.args = lambdaNode.getArgs(); this.needsSplat = Helpers.needsSplat19(args.getRequiredArgsCount(), args.getRestArg() != -1); this.parameterList = Helpers.encodeParameterList(args).split(";"); this.body = lambdaNode.getBody() == null ? NilImplicitNode.NIL : lambdaNode.getBody(); this.position = lambdaNode.getPosition(); // precache these this.file = position.getFile(); this.line = position.getLine(); }
public ByteList shadowing_lvar(ByteList nameBytes) { if (nameBytes.realSize() == 1 && nameBytes.charAt(0) == '_') return nameBytes; RubySymbol name = symbolID(nameBytes); String id = name.idString(); StaticScope current = getCurrentScope(); if (current.exists(id) >= 0) yyerror("duplicated argument name"); if (current.isBlockScope() && warnings.isVerbose() && current.isDefined(id) >= 0 && Options.PARSER_WARN_LOCAL_SHADOWING.load()) { Ruby runtime = getConfiguration().getRuntime(); warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getFile(), lexer.getPosition().getLine(), str(runtime, "shadowing outer local variable - ", ids(runtime, name))); } return nameBytes; }