本文整理汇总了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;未经允许,请勿转载。 |
请发表评论