@Override public PTypeList createNewReturnValue(Object node) throws AnalysisException { return new PTypeList(); }
@Override public PTypeList createNewReturnValue(INode node) throws AnalysisException { return new PTypeList(); }
public PTypeList getComposeTypes(PType type) { try { return type.apply(af.getComposeTypeCollector()); } catch (AnalysisException e) { return new PTypeList(); } }
public PTypeList getBaseTypes() { PTypeList basetypes = new PTypeList(); if (superobjects.isEmpty()) { basetypes.add(type); } else { for (ObjectValue sup : superobjects) { basetypes.addAll(sup.getBaseTypes()); } } return basetypes; }
@Override public PTypeList caseAProductType(AProductType node) throws AnalysisException { PTypeList list = new PTypeList(); for (PType ptype : node.getTypes()) { list.addAll(ptype.apply(THIS)); } return list; }
@Override public PTypeList caseAUnionType(AUnionType node) throws AnalysisException { PTypeList list = new PTypeList(); for (PType ptype : node.getTypes()) { list.addAll(ptype.apply(THIS)); } return list; }
@Override public PTypeList caseARecordInvariantType(ARecordInvariantType node) throws AnalysisException { if (node.getComposed()) { PTypeList types = new PTypeList(node); for (AFieldField f : node.getFields()) { types.addAll(f.getType().apply(THIS)); } return types; } else { return new PTypeList(); } } }
@Override public AOperationType caseAUnknownType(AUnknownType type) throws AnalysisException { return AstFactory.newAOperationType(type.getLocation(), new PTypeList(), AstFactory.newAUnknownType(type.getLocation())); }
public AExplicitFunctionDefinition getInvDefinition(AStateDefinition d) { ILexLocation loc = d.getInvPattern().getLocation(); List<PPattern> params = new Vector<PPattern>(); params.add(d.getInvPattern().clone()); List<List<PPattern>> parameters = new Vector<List<PPattern>>(); parameters.add(params); PTypeList ptypes = new PTypeList(); ptypes.add(AstFactory.newAUnresolvedType(d.getName())); AFunctionType ftype = AstFactory.newAFunctionType(loc, false, ptypes, AstFactory.newABooleanBasicType(loc)); return AstFactory.newAExplicitFunctionDefinition(d.getName().getInvName(loc), NameScope.GLOBAL, null, ftype, parameters, d.getInvExpression(), null, null, true, null); }
@Override public PType caseAMultiBindListDefinition(AMultiBindListDefinition node) throws AnalysisException { PTypeList types = new PTypeList(); for (PDefinition definition : node.getDefs()) { types.add(definition.getType()); } AUnionType result = AstFactory.newAUnionType(node.getLocation(), types); return result; }
public AExplicitFunctionDefinition getInitDefinition(AStateDefinition d) { ILexLocation loc = d.getInitPattern().getLocation(); List<PPattern> params = new Vector<PPattern>(); params.add(d.getInitPattern().clone()); List<List<PPattern>> parameters = new Vector<List<PPattern>>(); parameters.add(params); PTypeList ptypes = new PTypeList(); ptypes.add(AstFactory.newAUnresolvedType(d.getName())); AFunctionType ftype = AstFactory.newAFunctionType(loc, false, ptypes, AstFactory.newABooleanBasicType(loc)); PExp body = AstFactory.newAStateInitExp(d); AExplicitFunctionDefinition def = AstFactory.newAExplicitFunctionDefinition(d.getName().getInitName(loc), NameScope.GLOBAL, null, ftype, parameters, body, null, null, false, null); return def; }
@Override public PTypeList caseAMapMapType(AMapMapType node) throws AnalysisException { PTypeList list = new PTypeList(); list.addAll(node.getFrom().apply(THIS)); list.addAll(node.getTo().apply(THIS)); return list; }
@Override public PTypeList caseAInMapMapType(AInMapMapType node) throws AnalysisException { PTypeList list = new PTypeList(); list.addAll(node.getFrom().apply(THIS)); list.addAll(node.getTo().apply(THIS)); return list; }
@Override public PTypeList caseAFunctionType(AFunctionType node) throws AnalysisException { PTypeList list = new PTypeList(); for (PType ptype : node.getParameters()) { list.addAll(ptype.apply(THIS)); } list.addAll(node.getResult().apply(THIS)); return list; }
@Override public PType caseATuplePattern(ATuplePattern pattern) throws AnalysisException { PTypeList list = new PTypeList(); for (PPattern p : pattern.getPlist()) { list.add(af.createPPatternAssistant().getPossibleType(p)); } return list.getType(pattern.getLocation()); }
@Override public PTypeList caseAOperationType(AOperationType node) throws AnalysisException { PTypeList list = new PTypeList(); for (PType ptype : node.getParameters()) { list.addAll(ptype.apply(THIS)); } list.addAll(node.getResult().apply(THIS)); return list; }
@SuppressWarnings("unchecked") public AFunctionType getPostType(AFunctionType t) { List<PType> params = new PTypeList(); params.addAll((List<PType>) t.getParameters().clone()); params.add(t.getResult().clone()); AFunctionType type = AstFactory.newAFunctionType(t.getLocation(), false, params, AstFactory.newABooleanBasicType(t.getLocation())); type.setDefinitions((List<? extends PDefinition>) t.getDefinitions().clone()); type.setInstantiated(null); return type; }
@Override public PType caseAUnionType(AUnionType type, Newquestion question) throws AnalysisException { // return AUnionTypeAssistantTC.polymorph(type, question.pname, question.actualType); PTypeSet polytypes = new PTypeSet(af); for (PType ptype : ((AUnionType) type).getTypes()) { polytypes.add(af.createPTypeAssistant().polymorph(ptype, question.pname, question.actualType)); } // TODO: Types in unionType should be a SET PTypeList result = new PTypeList(); result.addAll(polytypes); return AstFactory.newAUnionType(type.getLocation(), result); }
@SuppressWarnings("unchecked") public AFunctionType getPreType(AOperationType type, AStateDefinition state, SClassDefinition classname, boolean isStatic) { if (state != null) { PTypeList params = new PTypeList(); params.addAll((LinkedList<PType>) type.getParameters().clone()); params.add(AstFactory.newAUnresolvedType(state.getName())); return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); } else if (classname != null && !isStatic) { PTypeList params = new PTypeList(); params.addAll((Collection<? extends PType>) type.getParameters().clone()); params.add(AstFactory.newAUnresolvedType(classname.getName())); return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); } else { return AstFactory.newAFunctionType(type.getLocation(), false, (List<PType>) type.getParameters().clone(), AstFactory.newABooleanBasicType(type.getLocation())); } }
private PTypeList getPTypes(ATypeDefinition typedef) { PTypeList ptypes = new PTypeList(); if (typedef.getInvType() instanceof ARecordInvariantType) { // Records are inv_R: R +> bool AUnresolvedType uType= AstFactory.newAUnresolvedType(typedef.getName().clone()); ptypes.add(uType.clone()); ptypes.add(uType.clone()); } else { // Named types are inv_T: x +> bool, for T = x ANamedInvariantType nt = (ANamedInvariantType) typedef.getInvType(); ptypes.add(nt.getType().clone()); ptypes.add(nt.getType().clone()); } return ptypes; }