@Override public PType caseAObjectPattern(AObjectPattern pattern) throws AnalysisException { return pattern.getType(); }
public static AObjectPattern newAObjectPattern(ILexNameToken classname, List<ANamePatternPair> list) { AObjectPattern result = new AObjectPattern(); initPattern(result, classname.getLocation()); result.setFields(list); result.setClassname(classname); result.setType(AstFactory.getAUnresolvedType(classname)); return result; }
/** * Returns a deep clone of this {@link AObjectPattern} node. * @return a deep clone of this {@link AObjectPattern} node */ public AObjectPattern clone() { return new AObjectPattern( _location, cloneList(_definitions), _resolved, cloneNode(_classname), cloneList(_fields), _type ); }
/** * Creates a new complete constructor {@code AObjectPattern} 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 classname_ the {@link ILexNameToken} node for the {@code classname} child of this {@link AObjectPattern} node * @param fields_ the {@link NodeList} node for the {@code fields} child of this {@link AObjectPattern} node * @param type_ the {@link PType} <b>graph</a> node for the {@code type} child of this {@link AObjectPattern} node. * <i>The parent of this {@code type } will not be changed by adding it to this node.</i> */ public AObjectPattern(ILexLocation location_, List<? extends PDefinition> definitions_, Boolean resolved_, ILexNameToken classname_, List<? extends ANamePatternPair> fields_, PType type_) { super(location_,definitions_,resolved_); this.setClassname(classname_); this.setFields(fields_); this.setType(type_); }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getClassname() != null ) node.getClassname().apply(this); List<ANamePatternPair> copy = new ArrayList<ANamePatternPair>(node.getFields()); for( ANamePatternPair e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this);
VdmRuntimeError.patternFail(e, pattern.getLocation()); if (!question.ctxt.assistantFactory.getTypeComparator().isSubType(objval.getType(), pattern.getType())) VdmRuntimeError.patternFail(4114, "Object type does not match pattern", pattern.getLocation()); int psize = pattern.getFields().size(); int[] counts = new int[psize]; int i = 0; for (ANamePatternPair npp : pattern.getFields()) VdmRuntimeError.patternFail(4114, "Object type does not match pattern", pattern.getLocation()); List<NameValuePairList> finalResults = new Vector<NameValuePairList>(); if (pattern.getFields().isEmpty()) VdmRuntimeError.patternFail(4116, "Values do not match record pattern", pattern.getLocation()); VdmRuntimeError.patternFail(4116, "Values do not match record pattern", pattern.getLocation());
@Override public void caseAObjectPattern(AObjectPattern pattern, NewQuestion question) throws AnalysisException { if (pattern.getResolved()) { return; } else { pattern.setResolved(true); } try { af.createPPatternListAssistant().typeResolvePairs(pattern.getFields(), question.rootVisitor, question.question); pattern.setType(af.createPTypeAssistant().typeResolve(pattern.getType(), null, question.rootVisitor, question.question)); } catch (TypeCheckException e) { af.createPPatternAssistant().unResolve(pattern); throw e; } }
@Override public Boolean caseAObjectPattern(AObjectPattern pattern) throws AnalysisException { LinkedList<PPattern> list = new LinkedList<PPattern>(); for (ANamePatternPair npp: pattern.getFields()) { list.add(npp.getPattern()); } return isConstrained(list); }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getClassname() != null ) node.getClassname().apply(this, question); List<ANamePatternPair> copy = new ArrayList<ANamePatternPair>(node.getFields()); for( ANamePatternPair e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this, question);
if (!typeAssistant.isClass(pattern.getType(), question.env)) TypeCheckerErrors.report(3331, "obj_ expression is not an object type", pattern.getLocation(), pattern); TypeCheckerErrors.detail("Type", pattern.getType()); AClassType cls = typeAssistant.getClassType(pattern.getType(), question.env); for (ANamePatternPair npp: pattern.getFields()) TypeCheckerErrors.report(3332, "Object pattern cannot be used from a function", pattern.getLocation(), pattern); return pattern.getType();
@Override public Boolean caseAObjectPattern(AObjectPattern node) throws AnalysisException { LinkedList<PPattern> list = new LinkedList<PPattern>(); for (ANamePatternPair npp: node.getFields()) { list.add(npp.getPattern()); } return alwaysMatches(list); }
/** * Creates a deep clone of this {@link AObjectPattern} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link AObjectPattern} node */ public AObjectPattern clone(Map<INode,INode> oldToNewMap) { AObjectPattern node = new AObjectPattern( _location, cloneList(_definitions, oldToNewMap), _resolved, cloneNode(_classname, oldToNewMap), cloneList(_fields, oldToNewMap), _type ); oldToNewMap.put(this, node); return node; }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getClassname() != null ) node.getClassname().apply(this); List<ANamePatternPair> copy = new ArrayList<ANamePatternPair>(node.getFields()); for( ANamePatternPair e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) node.getType().apply(this);
AClassType pattype = typeAssistant.getClassType(pattern.getType(), null); AClassType exptype = typeAssistant.getClassType(question.ptype, null); TypeCheckerErrors.report(3333, "Matching expression is not a compatible object type", pattern.getLocation(), question.ptype); TypeCheckerErrors.detail2("Pattern type", pattype, "Expression type", exptype); return defs; PDefinitionAssistantTC definitionAssistant = af.createPDefinitionAssistant(); for (ANamePatternPair npp: pattern.getFields())
@Override public List<AIdentifierPattern> caseAObjectPattern(AObjectPattern pattern) throws AnalysisException { List<AIdentifierPattern> list = new Vector<AIdentifierPattern>(); for (ANamePatternPair npp : pattern.getFields()) { list.addAll(npp.getPattern().apply(THIS)); } return list; }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getClassname() != null ) mergeReturns(retVal,node.getClassname().apply(this)); List<ANamePatternPair> copy = new ArrayList<ANamePatternPair>(node.getFields()); for( ANamePatternPair e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this));
@Override public Boolean caseAObjectPattern(AObjectPattern pattern) throws AnalysisException { LinkedList<PPattern> list = new LinkedList<PPattern>(); for (ANamePatternPair npp: pattern.getFields()) { list.add(npp.getPattern()); } return af.createPPatternListAssistant().isSimple(list); }
List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefinitions()); for( PDefinition e : copy) if(node.getClassname() != null ) mergeReturns(retVal,node.getClassname().apply(this, question)); List<ANamePatternPair> copy = new ArrayList<ANamePatternPair>(node.getFields()); for( ANamePatternPair e : copy) if(node.getType() != null && !_visitedNodes.contains(node.getType())) mergeReturns(retVal,node.getType().apply(this, question));
@Override public LexNameList caseAObjectPattern(AObjectPattern pattern) throws AnalysisException { LexNameList list = new LexNameList(); for (ANamePatternPair npp : pattern.getFields()) { list.addAll(af.createPPatternAssistant().getAllVariableNames(npp.getPattern())); } return list; }