@Override public String caseAOperationType(AOperationType type) throws AnalysisException { List<PType> parameters = type.getParameters(); String params = parameters.isEmpty() ? "()" : Utils.listToString(parameters, " * "); return "(" + params + " ==> " + type.getResult() + ")"; }
@Override public STypeIR caseAOperationType(AOperationType node, IRInfo question) throws AnalysisException { return question.getTypeAssistant().consMethodType(node, node.getParameters(), node.getResult(), question); }
@Override public Boolean caseAOperationType(AOperationType type, AAccessSpecifierAccessSpecifier accessSpecifier) throws AnalysisException { for (PType t : type.getParameters()) { if (t.apply(this, accessSpecifier))// (PTypeAssistantTC.narrowerThan(t, accessSpecifier)) { return true; } } return type.getResult().apply(this, accessSpecifier); // PTypeAssistantTC.narrowerThan(type.getResult(),accessSpecifier); }
@Override public Boolean caseAOperationType(AOperationType type, Object other) throws AnalysisException { other = af.createPTypeAssistant().deBracket(other); if (!(other instanceof AOperationType)) { return false; } AOperationType oother = (AOperationType) other; return type.getResult().apply(this, oother.getResult()) && af.createPTypeAssistant().equals(type.getParameters(), oother.getParameters()); }
@Override public Integer caseAOperationType(AOperationType type) throws AnalysisException { AOperationType otype = type; return af.createPTypeAssistant().hashCode(otype.getParameters()) + af.createPTypeAssistant().hashCode(otype.getResult()); }
@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; }
@Override public void caseAOperationType(AOperationType type) throws AnalysisException { if (!type.getResolved()) { return; } else { type.setResolved(false); } for (PType ot : type.getParameters()) { ot.apply(THIS); } type.getResult().apply(THIS); }
private TypeCompatibilityObligation(AExplicitOperationDefinition def, PType actualResult, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(def, POType.TYPE_COMP, ctxt, def.getLocation(), assistantFactory); this.assistantFactory = assistantFactory; AVariableExp result = AstFactory.newAVariableExp(new LexNameToken(def.getName().getModule(), "RESULT", def.getLocation())); stitch = oneType(false, result, ((AOperationType) def.getType()).getResult().clone(), actualResult.clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
public ParameterPatternObligation(AImplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.OPERATION_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAImplicitOperationDefinitionAssistant().getListParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
public ParameterPatternObligation(AExplicitOperationDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { super(def, POType.OPERATION_PATTERNS, ctxt, def.getLocation(), af); this.assistantFactory = af; stitch = generate(def.getPredef(), cloneListPatternList(assistantFactory.createAExplicitOperationDefinitionAssistant().getParamPatternList(def)), cloneListType(((AOperationType) def.getType()).getParameters()), ((AOperationType) def.getType()).getResult().clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
private TypeCompatibilityObligation(AImplicitOperationDefinition def, PType actualResult, IPOContextStack ctxt, IPogAssistantFactory assistantFactory) throws AnalysisException { super(def, POType.TYPE_COMP, ctxt, def.getLocation(), assistantFactory); this.assistantFactory = assistantFactory; PExp result = null; if (def.getResult().getPattern() instanceof AIdentifierPattern) { AIdentifierPattern ip = (AIdentifierPattern) def.getResult().getPattern(); result = AstFactory.newAVariableExp(ip.getName()); } else { ATuplePattern tp = (ATuplePattern) def.getResult().getPattern(); List<PExp> args = new ArrayList<PExp>(); for (PPattern p : tp.getPlist()) { AIdentifierPattern ip = (AIdentifierPattern) p; args.add(AstFactory.newAVariableExp(ip.getName())); } result = AstFactory.newATupleExp(def.getLocation(), args); } stitch = oneType(false, result, ((AOperationType) def.getType()).getResult().clone(), actualResult.clone()); valuetree.setPredicate(ctxt.getPredWithContext(stitch)); }
plist.addAll((List<PPattern>) d.getParameterPatterns().clone()); if (!(((AOperationType) d.getType()).getResult() instanceof AVoidType))
@SuppressWarnings("unchecked") public AFunctionType getPostType(AOperationType type, AStateDefinition state, SClassDefinition classname, boolean isStatic) { PTypeList params = new PTypeList(); params.addAll((LinkedList<PType>) type.getParameters().clone()); if (!(type.getResult() instanceof AVoidType)) { params.add(type.getResult().clone()); } if (state != null) { params.add(AstFactory.newAUnresolvedType(state.getName())); params.add(AstFactory.newAUnresolvedType(state.getName())); } else if (classname != null) { AMapMapType map = AstFactory.newAMapMapType(type.getLocation(), AstFactory.newASeqSeqType(type.getLocation(), AstFactory.newACharBasicType(type.getLocation())), AstFactory.newAUnknownType(type.getLocation())); params.add(map); if (!isStatic) { params.add(AstFactory.newAUnresolvedType(classname.getName())); } } return AstFactory.newAFunctionType(type.getLocation(), false, params, AstFactory.newABooleanBasicType(type.getLocation())); }