List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getInvDef() != null && !_visitedNodes.contains(node.getInvDef())) node.getInvDef().apply(this, question); if(node.getEqDef() != null && !_visitedNodes.contains(node.getEqDef())) node.getEqDef().apply(this, question); if(node.getOrdDef() != null && !_visitedNodes.contains(node.getOrdDef())) node.getOrdDef().apply(this, question); if(node.getName() != null ) node.getName().apply(this, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question);
@Override public PType caseANamedInvariantType(ANamedInvariantType type, Newquestion question) throws AnalysisException { if (type.getResolved()) { return type; } else { type.setResolved(true); } try { type.setType(af.createPTypeAssistant().typeResolve(type.getType(), question.root, question.rootVisitor, question.question)); return type; } catch (TypeCheckException e) { af.createPTypeAssistant().unResolve(type); throw e; } }
/** * Creates a new complete constructor {@code ANamedInvariantType} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param name_ the {@link ILexNameToken} <b>graph</a> node for the {@code name} child of this {@link ANamedInvariantType} node. * <i>The parent of this {@code name } will not be changed by adding it to this node.</i> * @param type_ the {@link PType} <b>graph</a> node for the {@code type} child of this {@link ANamedInvariantType} node. * <i>The parent of this {@code type } will not be changed by adding it to this node.</i> */ public ANamedInvariantType(ILexLocation location_, Boolean resolved_, List<? extends PDefinition> definitions_, Boolean inNarrower_, Boolean opaque_, AExplicitFunctionDefinition invDef_, AExplicitFunctionDefinition eqDef_, AExplicitFunctionDefinition ordDef_, ILexNameToken name_, PType type_) { super(location_,resolved_,definitions_,inNarrower_,opaque_,invDef_,eqDef_,ordDef_); this.setName(name_); this.setType(type_); }
@Override public void caseANamedInvariantType(ANamedInvariantType type) throws AnalysisException { if (!type.getResolved()) { return; } else { type.setResolved(false); } // PTypeAssistantTC.unResolve(type.getType()); type.getType().apply(THIS); }
@Override public AOperationType defaultSInvariantType(SInvariantType type) throws AnalysisException { if (type instanceof ANamedInvariantType) { return ((ANamedInvariantType) type).getType().apply(THIS); } else { return null; } }
@Override public String caseANamedInvariantType(ANamedInvariantType type) throws AnalysisException { return type.getName().toString(); }
@Override public SDeclIR caseANamedInvariantType(ANamedInvariantType node, IRInfo question) throws AnalysisException { PType type = node.getType(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); ATypeNameIR typeName = new ATypeNameIR(); typeName.setDefiningClass(node.getName().getModule()); typeName.setName(node.getName().getName()); ANamedTypeDeclIR namedTypeDecl = new ANamedTypeDeclIR(); namedTypeDecl.setName(typeName); namedTypeDecl.setType(typeCg); return namedTypeDecl; }
@Override public Boolean caseANamedInvariantType(ANamedInvariantType node, ILexLocation q) throws AnalysisException { if (node.getOpaque() && !q.getModule().equals(node.getLocation().getModule())) return false; if (node.getOrdDef() != null) return true; return node.getType().apply(this, q); }
@Override public Boolean caseANamedInvariantType(ANamedInvariantType node, ILexLocation q) throws AnalysisException { if (node.getOpaque() && !q.getModule().equals(node.getLocation().getModule())) return false; if (node.getEqDef() != null) return true; return node.getType().apply(this, q); }
throws AnalysisException if (type.getInNarrower()) type.setInNarrower(true); boolean result = false; if (type.getDefinitions().size() > 0) for (PDefinition d : type.getDefinitions()) } else if (type.getType().getDefinitions().size() == 0) result = type.apply(this, accessSpecifier) for (PDefinition d : type.getType().getDefinitions()) type.setInNarrower(false); return result;
@Override public LexNameSet caseANamedInvariantType(ANamedInvariantType node, FreeVarInfo info) throws AnalysisException { if (info.env.findType(node.getName(), node.getLocation().getModule()) == null) { // Invariant values covered in TCTypeDefinition return new LexNameSet(node.getName().getExplicit(true)); } else { return new LexNameSet(); } }
public static ANamedInvariantType newANamedInvariantType( ILexNameToken typeName, PType type) { ANamedInvariantType result = new ANamedInvariantType(); initType(result, typeName.getLocation()); initInvariantType(result); result.setName(typeName); result.setType(type); return result; }
@Override public void caseANamedInvariantType(ANamedInvariantType node, TypeCheckInfo question) throws AnalysisException if (node.getEqDef() != null) TypeChecker.warning(5021, "Multiple union members define eq clauses, " + equality, node.getLocation());
@Override public SSetType defaultSInvariantType(SInvariantType type) throws AnalysisException { if (type instanceof ANamedInvariantType) { return ((ANamedInvariantType) type).getType().apply(THIS); } else { return null; } }
@Override public Integer caseANamedInvariantType(ANamedInvariantType type) throws AnalysisException { return type.getName().apply(THIS); }
@Override public STypeIR caseANamedInvariantType(ANamedInvariantType node, IRInfo question) throws AnalysisException { PType type = node.getType(); STypeIR underlyingType = type.apply(question.getTypeVisitor(), question); // TODO: Morten initially requested some way of knowing whether a type originates // from a named invariant type. With the NamedInvTypeInfo being introduced, using // IR tags for this is redundant. Check if the IR tagging can be removed. underlyingType.setTag(new IRNamedTypeInvariantTag(node.getName().getName())); ATypeNameIR typeName = new ATypeNameIR(); typeName.setDefiningClass(node.getName().getModule()); typeName.setName(node.getName().getName()); ANamedTypeDeclIR typeDecl = new ANamedTypeDeclIR(); typeDecl.setName(typeName); if (underlyingType != null) { typeDecl.setType(underlyingType.clone()); } underlyingType.setNamedInvType(typeDecl); return underlyingType; }