本文整理汇总了Java中org.codehaus.groovy.ast.expr.Expression.putNodeMetaData方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.putNodeMetaData方法的具体用法?Java Expression.putNodeMetaData怎么用?Java Expression.putNodeMetaData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.expr.Expression
的用法示例。
在下文中一共展示了Expression.putNodeMetaData方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkSuperCallFromClosure
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
private void checkSuperCallFromClosure(Expression call, MethodNode directCallTarget) {
if (call instanceof MethodCallExpression && typeCheckingContext.getEnclosingClosure() != null) {
Expression objectExpression = ((MethodCallExpression)call).getObjectExpression();
if (objectExpression instanceof VariableExpression) {
VariableExpression var = (VariableExpression) objectExpression;
if (var.isSuperExpression()) {
ClassNode current = typeCheckingContext.getEnclosingClassNode();
LinkedList<MethodNode> list = current.getNodeMetaData(StaticTypesMarker.SUPER_MOP_METHOD_REQUIRED);
if (list == null) {
list = new LinkedList<MethodNode>();
current.putNodeMetaData(StaticTypesMarker.SUPER_MOP_METHOD_REQUIRED, list);
}
list.add(directCallTarget);
call.putNodeMetaData(StaticTypesMarker.SUPER_MOP_METHOD_REQUIRED, current);
}
}
}
}
示例2: visitParExpression
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
@Override
public Expression visitParExpression(ParExpressionContext ctx) {
Expression expression = this.visitExpressionInPar(ctx.expressionInPar());
Integer insideParenLevel = expression.getNodeMetaData(INSIDE_PARENTHESES_LEVEL);
if (null != insideParenLevel) {
insideParenLevel++;
} else {
insideParenLevel = 1;
}
expression.putNodeMetaData(INSIDE_PARENTHESES_LEVEL, insideParenLevel);
return configureAST(expression, ctx);
}
示例3: addPrivateFieldOrMethodAccess
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static void addPrivateFieldOrMethodAccess(Expression source, ClassNode cn, StaticTypesMarker type, ASTNode accessedMember) {
Set<ASTNode> set = (Set<ASTNode>) cn.getNodeMetaData(type);
if (set==null) {
set = new LinkedHashSet<ASTNode>();
cn.putNodeMetaData(type, set);
}
set.add(accessedMember);
source.putNodeMetaData(type, accessedMember);
}
示例4: findMethodOrFail
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
@Override
protected MethodNode findMethodOrFail(final Expression expr, final ClassNode receiver, final String name, final ClassNode... args) {
MethodNode methodNode = super.findMethodOrFail(expr, receiver, name, args);
if (expr instanceof BinaryExpression && methodNode!=null) {
expr.putNodeMetaData(BINARY_EXP_TARGET, new Object[] {methodNode, name});
}
return methodNode;
}
示例5: storeTargetMethod
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
protected void storeTargetMethod(final Expression call, final MethodNode directMethodCallCandidate) {
call.putNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET, directMethodCallCandidate);
checkOrMarkPrivateAccess(call, directMethodCallCandidate);
checkSuperCallFromClosure(call, directMethodCallCandidate);
extension.onMethodSelection(call, directMethodCallCandidate);
}
示例6: storeType
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
protected void storeType(Expression exp, ClassNode cn) {
if (exp instanceof VariableExpression && ((VariableExpression) exp).isClosureSharedVariable() && isPrimitiveType(cn)) {
cn = getWrapper(cn);
} else if (exp instanceof MethodCallExpression && ((MethodCallExpression) exp).isSafe() && isPrimitiveType(cn)) {
cn = getWrapper(cn);
} else if (exp instanceof PropertyExpression && ((PropertyExpression) exp).isSafe() && isPrimitiveType(cn)) {
cn = getWrapper(cn);
}
if (cn == UNKNOWN_PARAMETER_TYPE) {
// this can happen for example when "null" is used in an assignment or a method parameter.
// In that case, instead of storing the virtual type, we must "reset" type information
// by determining the declaration type of the expression
storeType(exp, getOriginalDeclarationType(exp));
return;
}
ClassNode oldValue = (ClassNode) exp.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, cn);
if (oldValue != null) {
// this may happen when a variable declaration type is wider than the subsequent assignment values
// for example :
// def o = 1 // first, an int
// o = 'String' // then a string
// o = new Object() // and eventually an object !
// in that case, the INFERRED_TYPE corresponds to the current inferred type, while
// DECLARATION_INFERRED_TYPE is the type which should be used for the initial type declaration
ClassNode oldDIT = (ClassNode) exp.getNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE);
if (oldDIT != null) {
exp.putNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE, cn==null?oldDIT : lowestUpperBound(oldDIT, cn));
} else {
exp.putNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE, cn==null?null : lowestUpperBound(oldValue, cn));
}
}
if (exp instanceof VariableExpression) {
VariableExpression var = (VariableExpression) exp;
final Variable accessedVariable = var.getAccessedVariable();
if (accessedVariable != null && accessedVariable != exp && accessedVariable instanceof VariableExpression) {
storeType((Expression) accessedVariable, cn);
}
if (accessedVariable instanceof Parameter) {
((Parameter) accessedVariable).putNodeMetaData(StaticTypesMarker.INFERRED_TYPE, cn);
}
if (var.isClosureSharedVariable() && cn!=null) {
List<ClassNode> assignedTypes = typeCheckingContext.closureSharedVariablesAssignmentTypes.get(var);
if (assignedTypes == null) {
assignedTypes = new LinkedList<ClassNode>();
typeCheckingContext.closureSharedVariablesAssignmentTypes.put(var, assignedTypes);
}
assignedTypes.add(cn);
}
if (!typeCheckingContext.temporaryIfBranchTypeInformation.empty()) {
List<ClassNode> temporaryTypesForExpression = getTemporaryTypesForExpression(exp);
if (temporaryTypesForExpression != null && !temporaryTypesForExpression.isEmpty()) {
// a type inference has been made on a variable whose type was defined in an instanceof block
// we erase available information with the new type
temporaryTypesForExpression.clear();
}
}
}
}
示例7: putSetterInfo
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
private static void putSetterInfo(Expression exp, SetterInfo info) {
exp.putNodeMetaData(SetterInfo.class, info);
}
示例8: assignToArray
import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
@Override
protected void assignToArray(Expression parent, Expression receiver, Expression index, Expression rhsValueLoader, boolean safe) {
ClassNode current = getController().getClassNode();
ClassNode arrayType = getController().getTypeChooser().resolveType(receiver, current);
ClassNode arrayComponentType = arrayType.getComponentType();
int operationType = getOperandType(arrayComponentType);
BinaryExpressionWriter bew = binExpWriter[operationType];
if (bew.arraySet(true) && arrayType.isArray() && !safe) {
super.assignToArray(parent, receiver, index, rhsValueLoader, safe);
} else {
/******
/ This code path is needed because ACG creates array access expressions
*******/
WriterController controller = getController();
StaticTypeCheckingVisitor visitor = new StaticCompilationVisitor(controller.getSourceUnit(), controller.getClassNode());
// let's replace this assignment to a subscript operator with a
// method call
// e.g. x[5] = 10
// -> (x, [], 5), =, 10
// -> methodCall(x, "putAt", [5, 10])
ArgumentListExpression ae = new ArgumentListExpression(index, rhsValueLoader);
if (rhsValueLoader instanceof VariableSlotLoader && parent instanceof BinaryExpression) {
// GROOVY-6061
rhsValueLoader.putNodeMetaData(StaticTypesMarker.INFERRED_TYPE,
controller.getTypeChooser().resolveType(parent, controller.getClassNode()));
}
MethodCallExpression mce = new MethodCallExpression(
receiver,
"putAt",
ae
);
mce.setSafe(safe);
mce.setSourcePosition(parent);
visitor.visitMethodCallExpression(mce);
OperandStack operandStack = controller.getOperandStack();
int height = operandStack.getStackLength();
mce.visit(controller.getAcg());
operandStack.pop();
operandStack.remove(operandStack.getStackLength()-height);
// return value of assignment
rhsValueLoader.visit(controller.getAcg());
}
}