/** * Returns the inferred return type of a closure or a method, if stored on the AST node. This method * doesn't perform any type inference by itself. * * @param exp a {@link ClosureExpression} or {@link MethodNode} * @return the inferred type, as stored on node metadata. */ protected ClassNode getInferredReturnType(final ASTNode exp) { return (ClassNode) exp.getNodeMetaData(StaticTypesMarker.INFERRED_RETURN_TYPE); }
private static StatementMeta addMeta(ASTNode node) { StatementMeta metaOld = node.getNodeMetaData(StatementMeta.class); StatementMeta meta = metaOld; if (meta==null) meta = new StatementMeta(); meta.optimize = true; if (metaOld==null) node.setNodeMetaData(StatementMeta.class, meta); return meta; }
@Override public ClassNode resolveType(final Expression exp, final ClassNode current) { ASTNode target = exp instanceof VariableExpression ? getTarget((VariableExpression) exp) : exp; ClassNode inferredType = target.getNodeMetaData(StaticTypesMarker.DECLARATION_INFERRED_TYPE); if (inferredType == null) { inferredType = target.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE); if (inferredType == null && target instanceof VariableExpression && ((VariableExpression) target).getAccessedVariable() instanceof Parameter) { target = (Parameter) ((VariableExpression) target).getAccessedVariable(); inferredType = ((Parameter) target).getOriginType(); } } if (inferredType != null) { if (ClassHelper.VOID_TYPE == inferredType) { // we are in a case of a type inference failure, probably because code was generated // it is better to avoid using this inferredType = super.resolveType(exp, current); } return inferredType; } if (target instanceof VariableExpression && ((VariableExpression) target).isThisExpression()) { // AsmClassGenerator may create "this" expressions that the type checker knows nothing about return current; } return super.resolveType(exp, current); }
Variable variable = findTargetVariable((VariableExpression) objectExpression); if (variable instanceof ASTNode) { Object data = ((ASTNode) variable).getNodeMetaData(StaticTypesMarker.CLOSURE_ARGUMENTS); if (data != null) { Parameter[] parameters = (Parameter[]) data;
protected ClassNode getType(final ASTNode exp) { ClassNode cn = exp.getNodeMetaData(StaticTypesMarker.INFERRED_TYPE); if (cn != null) { return cn; MethodNode target = (MethodNode) exp.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET); if (target != null) { return getType(target);
private void markClosureReplaced(ASTNode someNode) { if (someNode.getNodeMetaData(CLOSURE_REPLACED) == null) someNode.setNodeMetaData(CLOSURE_REPLACED, Boolean.TRUE); }
private void markProcessed(ASTNode someNode) { if (someNode.getNodeMetaData(PROCESSED) == null) someNode.setNodeMetaData(PROCESSED, Boolean.TRUE); }
private static StatementMeta addMeta(ASTNode node) { StatementMeta metaOld = (StatementMeta) node.getNodeMetaData(StatementMeta.class); StatementMeta meta = metaOld; if (meta==null) meta = new StatementMeta(); meta.optimize = true; if (metaOld==null) node.setNodeMetaData(StatementMeta.class, meta); return meta; }
private boolean fixLineNumbers(ASTNode node){ if(node.getNodeMetaData(LINE_NUMBERS_FIXED) != null) { return false;
private boolean fixLineNumbers(ASTNode node){ if(node.getNodeMetaData(LINE_NUMBERS_FIXED) != null) { return false;