Package com.oracle.truffle.api.source

Examples of com.oracle.truffle.api.source.SourceSection


        }
    }

    @Override
    public RubyNode visitArgsPushNode(org.jruby.ast.ArgsPushNode node) {
        final SourceSection sourceSection = translate(node.getPosition());

        return ArrayNodesFactory.PushOneNodeFactory.create(context, sourceSection, new RubyNode[]{
                KernelNodesFactory.DupNodeFactory.create(context, sourceSection, new RubyNode[]{
                        node.getFirstNode().accept(this)
                }),
View Full Code Here


        return new BignumLiteralNode(context, translate(node.getPosition()), node.getValue());
    }

    @Override
    public RubyNode visitBlockNode(org.jruby.ast.BlockNode node) {
        final SourceSection sourceSection = translate(node.getPosition());

        final List<RubyNode> translatedChildren = new ArrayList<>();

        for (org.jruby.ast.Node child : node.childNodes()) {
            if (child.getPosition() == InvalidSourcePosition.INSTANCE) {
View Full Code Here

        }
    }

    @Override
    public RubyNode visitBreakNode(org.jruby.ast.BreakNode node) {
        final SourceSection sourceSection = translate(node.getPosition());

        RubyNode resultNode;

        if (node.getValueNode() == null) {
            parentSourceSection = sourceSection;
View Full Code Here

    /**
     * See translateDummyAssignment to understand what this is for.
     */
    public RubyNode visitCallNodeExtraArgument(CallNode node, RubyNode extraArgument, boolean ignoreVisibility) {
        final SourceSection sourceSection = translate(node.getPosition());

        final RubyNode receiverTranslated = node.getReceiverNode().accept(this);

        org.jruby.ast.Node args = node.getArgsNode();
        org.jruby.ast.Node block = node.getIterNode();
View Full Code Here

        return new ArgumentsAndBlockTranslation(blockTranslated, argumentsTranslatedArray, isSplatted);
    }

    @Override
    public RubyNode visitCaseNode(org.jruby.ast.CaseNode node) {
        final SourceSection sourceSection = translate(node.getPosition());

        RubyNode elseNode;

        if (node.getElseNode() != null) {
            elseNode = node.getElseNode().accept(this);
View Full Code Here

    }

    public void warn(String message) {
        CompilerDirectives.transferToInterpreter();

        final SourceSection sourceSection = RubyCallStack.getTopMostUserCallNode().getEncapsulatingSourceSection();
        context.getRuntime().getWarnings().warn(IRubyWarnings.ID.TRUFFLE, sourceSection.getSource().getName(), sourceSection.getStartLine(), message);
    }
View Full Code Here

    }

    private static String formatInLine(List<Activation> activations, RubyException exception) {
        final StringBuilder builder = new StringBuilder();

        final SourceSection sourceSection = activations.get(0).getCallNode().getEncapsulatingSourceSection();
        final SourceSection reportedSourceSection;
        final String reportedName;

        if (sourceSection instanceof CoreSourceSection) {
            reportedSourceSection = nextUserSourceSection(activations, 1);
            reportedName = ((CoreSourceSection) sourceSection).getMethodName();
        } else {
            reportedSourceSection = sourceSection;
            reportedName = reportedSourceSection.getIdentifier();
        }

        if (reportedSourceSection == null) {
            throw new IllegalStateException("Call node has no encapsulating source section");
        }

        if (reportedSourceSection.getSource() == null) {
            throw new IllegalStateException("Call node source section " + reportedSourceSection + " has no source");
        }

        builder.append(reportedSourceSection.getSource().getName());
        builder.append(":");
        builder.append(reportedSourceSection.getStartLine());
        builder.append(":in `");
        builder.append(reportedName);
        builder.append("'");

        if (exception != null) {
View Full Code Here

    private static String formatFromLine(List<Activation> activations, int n) {
        return "\tfrom " + formatCallerLine(activations, n);
    }

    public static String formatCallerLine(List<Activation> activations, int n) {
        final SourceSection sourceSection = activations.get(n).getCallNode().getEncapsulatingSourceSection();
        final SourceSection reportedSourceSection;
        final String reportedName;

        if (sourceSection instanceof CoreSourceSection) {
            reportedSourceSection = activations.get(n + 1).getCallNode().getEncapsulatingSourceSection();
            reportedName = ((CoreSourceSection) sourceSection).getMethodName();
        } else {
            reportedSourceSection = sourceSection;
            reportedName = sourceSection.getIdentifier();
        }

        final StringBuilder builder = new StringBuilder();
        if (reportedSourceSection instanceof NullSourceSection) {
            builder.append("NullSourceSection");
        } else {
            builder.append(reportedSourceSection.getSource().getName());
            builder.append(":");
            builder.append(reportedSourceSection.getStartLine());
        }
        builder.append(":in `");
        builder.append(reportedName);
        builder.append("'");
View Full Code Here

        return builder.toString();
    }

    private static SourceSection nextUserSourceSection(List<Activation> activations, int n) {
        while (true) {
            SourceSection sourceSection = activations.get(n).getCallNode().getEncapsulatingSourceSection();

            if (!(sourceSection instanceof CoreSourceSection)) {
                return sourceSection;
            }
View Full Code Here

    public static String formatBasicLine(Activation activation) {
        final StringBuilder builder = new StringBuilder();
        builder.append("    at ");

        final SourceSection sourceSection = activation.getCallNode().getEncapsulatingSourceSection();

        if (sourceSection instanceof CoreSourceSection) {
            final CoreSourceSection coreSourceSection = (CoreSourceSection) sourceSection;
            builder.append(coreSourceSection.getClassName());
            builder.append("#");
            builder.append(coreSourceSection.getMethodName());
        } else {
            builder.append(sourceSection.getSource().getName());
            builder.append(":");
            builder.append(sourceSection.getStartLine());
            builder.append(":in '");
            builder.append(sourceSection.getIdentifier());
            builder.append("'");
        }

        return builder.toString();
    }
View Full Code Here

TOP

Related Classes of com.oracle.truffle.api.source.SourceSection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.