• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ReturnNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中jdk.nashorn.internal.ir.ReturnNode的典型用法代码示例。如果您正苦于以下问题:Java ReturnNode类的具体用法?Java ReturnNode怎么用?Java ReturnNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ReturnNode类属于jdk.nashorn.internal.ir包,在下文中一共展示了ReturnNode类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: enterReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    enterDefault(returnNode);

    type("ReturnStatement");
    comma();

    final Node arg = returnNode.getExpression();
    property("argument");
    if (arg != null) {
        arg.accept(this);
    } else {
        nullValue();
    }

    return leave();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:JSONWriter.java


示例2: enterReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    if(!reachable) {
        return false;
    }

    final Expression returnExpr = returnNode.getExpression();
    final Type returnExprType;
    if(returnExpr != null) {
        returnExpr.accept(this);
        returnExprType = getType(returnExpr);
    } else {
        returnExprType = Type.UNDEFINED;
    }
    returnType = Type.widestReturnType(returnType, returnExprType);
    doesNotContinueSequentially();
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:LocalVariableTypesCalculator.java


示例3: enterReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    if(!method.isReachable()) {
        return false;
    }
    enterStatement(returnNode);

    method.registerReturn();

    final Type returnType = lc.getCurrentFunction().getReturnType();

    final Expression expression = returnNode.getExpression();
    if (expression != null) {
        loadExpressionUnbounded(expression);
    } else {
        method.loadUndefined(returnType);
    }

    method._return(returnType);

    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:CodeGenerator.java


示例4: enterReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    if(!reachable) {
        return false;
    }

    final Expression returnExpr = returnNode.getExpression();
    final Type returnExprType;
    if(returnExpr != null) {
        returnExprType = visitExpressionOnEmptyStack(returnExpr).type;
    } else {
        assertTypeStackIsEmpty();
        returnExprType = Type.UNDEFINED;
    }
    returnType = Type.widestReturnType(returnType, returnExprType);
    doesNotContinueSequentially();
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:LocalVariableTypesCalculator.java


示例5: enterReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    if(!method.isReachable()) {
        return false;
    }
    enterStatement(returnNode);

    final Type returnType = lc.getCurrentFunction().getReturnType();

    final Expression expression = returnNode.getExpression();
    if (expression != null) {
        loadExpressionUnbounded(expression);
    } else {
        method.loadUndefined(returnType);
    }

    method._return(returnType);

    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:CodeGenerator.java


示例6: leaveReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
    final Expression expr = returnNode.getExpression();
    final Type returnType;

    if (expr != null) {
        //we can't do parameter specialization if we return something that hasn't been typed yet
        final Symbol symbol = expr.getSymbol();
        if (expr.getType().isUnknown() && symbol.isParam()) {
            symbol.setType(Type.OBJECT);
        }

        returnType = widestReturnType(returnTypes.pop(), symbol.getSymbolType());
    } else {
        returnType = Type.OBJECT; //undefined
    }
    LOG.info("Returntype is now ", returnType);
    returnTypes.push(returnType);

    end(returnNode);

    return returnNode;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:24,代码来源:Attr.java


示例7: leaveBlock

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public Node leaveBlock(final Block block) {
    //now we have committed the entire statement list to the block, but we need to truncate
    //whatever is after the last terminal. block append won't append past it


    if (lc.isFunctionBody()) {
        final FunctionNode currentFunction = lc.getCurrentFunction();
        final boolean isProgram = currentFunction.isProgram();
        final Statement last = lc.getLastStatement();
        final ReturnNode returnNode = new ReturnNode(
            last == null ? currentFunction.getLineNumber() : last.getLineNumber(), //TODO?
            currentFunction.getToken(),
            currentFunction.getFinish(),
            isProgram ?
                compilerConstant(RETURN) :
                LiteralNode.newInstance(block, ScriptRuntime.UNDEFINED));

        returnNode.accept(this);
    }

    return block;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:24,代码来源:Lower.java


示例8: enterReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public boolean enterReturnNode(final ReturnNode returnNode) {
    lineNumber(returnNode);

    method.registerReturn();

    final Type returnType = lc.getCurrentFunction().getReturnType();

    final Expression expression = returnNode.getExpression();
    if (expression != null) {
        load(expression);
    } else {
        method.loadUndefined(returnType);
    }

    method._return(returnType);

    return false;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:20,代码来源:CodeGenerator.java


示例9: leaveReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
    final Expression expr = returnNode.getExpression();
    final Type returnType;

    if (expr != null) {
        //we can't do parameter specialization if we return something that hasn't been typed yet
        final Symbol symbol = expr.getSymbol();
        if (expr.getType().isUnknown() && symbol.isParam()) {
            symbol.setType(Type.OBJECT);
        }

        returnType = Type.widest(returnTypes.pop(), symbol.getSymbolType());
    } else {
        returnType = Type.OBJECT; //undefined
    }
    LOG.info("Returntype is now ", returnType);
    returnTypes.push(returnType);

    end(returnNode);

    return returnNode;
}
 
开发者ID:wro4j,项目名称:nashorn-backport,代码行数:24,代码来源:Attr.java


示例10: returnStatement

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
/**
 * ReturnStatement :
 *      return Expression? ; // [no LineTerminator here]
 *
 * See 12.9
 *
 * Parse RETURN statement.
 */
private void returnStatement() {
    // check for return outside function
    if (lc.getCurrentFunction().getKind() == FunctionNode.Kind.SCRIPT) {
        throw error(AbstractParser.message("invalid.return"));
    }

    // Capture RETURN token.
    final int  returnLine  = line;
    final long returnToken = token;
    // RETURN tested in caller.
    nextOrEOL();

    Expression expression = null;

    // SEMICOLON or expression.
    switch (type) {
    case RBRACE:
    case SEMICOLON:
    case EOL:
    case EOF:
        break;

    default:
        expression = expression();
        break;
    }

    endOfLine();

    // Construct and add RETURN node.
    appendStatement(new ReturnNode(returnLine, returnToken, finish, expression));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:41,代码来源:Parser.java


示例11: yieldStatement

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
/**
 * YieldStatement :
 *      yield Expression? ; // [no LineTerminator here]
 *
 * JavaScript 1.8
 *
 * Parse YIELD statement.
 */
private void yieldStatement() {
    // Capture YIELD token.
    final int  yieldLine  = line;
    final long yieldToken = token;
    // YIELD tested in caller.
    nextOrEOL();

    Expression expression = null;

    // SEMICOLON or expression.
    switch (type) {
    case RBRACE:
    case SEMICOLON:
    case EOL:
    case EOF:
        break;

    default:
        expression = expression();
        break;
    }

    endOfLine();

    // Construct and add YIELD node.
    appendStatement(new ReturnNode(yieldLine, yieldToken, finish, expression));
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:Parser.java


示例12: leaveReturnNode

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
@Override
public Node leaveReturnNode(final ReturnNode returnNode) {
    if(inSplitNode()) {
        appendStatement(new SetSplitState(RETURN_STATE, returnNode.getLineNumber()));
        getCurrentSplitState().hasReturn = true;
    }
    appendStatement(returnNode);
    return returnNode;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:SplitIntoFunctions.java


示例13: createSyntheticReturn

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
private void createSyntheticReturn(final Block body) {
    final FunctionNode functionNode = lc.getCurrentFunction();
    final long token = functionNode.getToken();
    final int finish = functionNode.getFinish();
    final List<Statement> statements = body.getStatements();
    final int lineNumber = statements.isEmpty() ? functionNode.getLineNumber() : statements.get(statements.size() - 1).getLineNumber();
    final IdentNode returnExpr;
    if(functionNode.isProgram()) {
        returnExpr = new IdentNode(token, finish, RETURN.symbolName()).setSymbol(getCompilerConstantSymbol(functionNode, RETURN));
    } else {
        returnExpr = null;
    }
    syntheticReturn = new ReturnNode(lineNumber, token, finish, returnExpr);
    syntheticReturn.accept(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:LocalVariableTypesCalculator.java


示例14: returnStatement

import jdk.nashorn.internal.ir.ReturnNode; //导入依赖的package包/类
/**
 * ReturnStatement :
 *      return Expression? ; // [no LineTerminator here]
 *
 * See 12.9
 *
 * Parse RETURN statement.
 */
private void returnStatement() {
    // check for return outside function
    if (lc.getCurrentFunction().getKind() == FunctionNode.Kind.SCRIPT || lc.getCurrentFunction().getKind() == FunctionNode.Kind.MODULE) {
        throw error(AbstractParser.message("invalid.return"));
    }

    // Capture RETURN token.
    final int  returnLine  = line;
    final long returnToken = token;
    // RETURN tested in caller.
    nextOrEOL();

    Expression expression = null;

    // SEMICOLON or expression.
    switch (type) {
    case RBRACE:
    case SEMICOLON:
    case EOL:
    case EOF:
        break;

    default:
        expression = expression();
        break;
    }

    endOfLine();

    // Construct and add RETURN node.
    appendStatement(new ReturnNode(returnLine, returnToken, finish, expression));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:Parser.java



注:本文中的jdk.nashorn.internal.ir.ReturnNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LIElement类代码示例发布时间:2022-05-22
下一篇:
Java IgniteBiPredicate类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap