public String hackResultName(AFuncDeclIR func) throws AnalysisException { SourceNode x = func.getSourceNode(); if (x.getVdmNode() instanceof AImplicitFunctionDefinition) { AImplicitFunctionDefinition iFunc = (AImplicitFunctionDefinition) x.getVdmNode(); return iFunc.getResult().getPattern().toString(); } throw new AnalysisException("Expected AFuncDeclIR in implicit function source. Got: " + x.getVdmNode().getClass().toString()); }
public static org.overture.ast.node.INode getVdmNode(PIR irNode) { if (irNode != null && irNode.getSourceNode() != null) { return irNode.getSourceNode().getVdmNode(); } else { return null; } }
public PType getVdmType(STypeIR type) { SourceNode source = type.getSourceNode(); if (source != null) { org.overture.ast.node.INode vdmNode = source.getVdmNode(); if (vdmNode != null) { if (vdmNode instanceof PType) { return (PType) vdmNode; } } } log.error("Could not get VDM type of " + type); return new AUnknownType(); }
private String getInitName(AMethodDeclIR node) { if (node.getSourceNode() != null && node.getSourceNode().getVdmNode() != null) { INode vdmNode = node.getSourceNode().getVdmNode(); if (vdmNode instanceof AExplicitOperationDefinition) { AExplicitOperationDefinition op = (AExplicitOperationDefinition) vdmNode; return getObjectInitializerCall(op); } } return null; } }
public AVarDeclIR consLocalVarDecl(STypeIR type, SPatternIR pattern, SExpIR exp) { return consLocalVarDecl(exp.getSourceNode() != null ? exp.getSourceNode().getVdmNode() : null, type, pattern, exp); }
private boolean handleUnaryExp(SUnaryExpIR exp) throws AnalysisException { STypeIR type = exp.getExp().getType(); if (type instanceof AUnionTypeIR) { org.overture.ast.node.INode vdmNode = type.getSourceNode().getVdmNode(); if (vdmNode instanceof PType) { return true; } } return false; }
public boolean compatible(IRInfo info, STypeIR left, STypeIR right) { SourceNode leftSource = left.getSourceNode(); SourceNode rightSource = right.getSourceNode(); if (leftSource == null || rightSource == null) { return false; } org.overture.ast.node.INode leftType = leftSource.getVdmNode(); org.overture.ast.node.INode rightType = rightSource.getVdmNode(); if (!(leftType instanceof PType) || !(rightType instanceof PType)) { return false; } TypeComparator typeComparator = info.getTcFactory().getTypeComparator(); if (!typeComparator.compatible((PType) leftType, (PType) rightType)) { return false; } return true; }
public INode getVdmNode(IrNodeInfo info) { if (info == null) { return null; } if (info.getNode() == null || !(info.getNode() instanceof PIR)) { return null; } SourceNode sourceNode = ((PIR) info.getNode()).getSourceNode(); if (sourceNode == null) { return null; } return sourceNode.getVdmNode(); }
/** * Given an IR status this method determines if it represents a test case or not. * * @param status * The IR status. * @return True if the <code>status</code> represents a test case - false otherwise. */ protected boolean isTestCase(IRStatus<? extends PIR> status) { return getInfo().getDeclAssistant().isTestCase(status.getIrNode().getSourceNode().getVdmNode()); }
private String getInitName(APlainCallStmIR node) { if (node.getSourceNode() != null && node.getSourceNode().getVdmNode() != null) { INode vdmNode = node.getSourceNode().getVdmNode(); if (vdmNode instanceof ACallStm) { ACallStm c = (ACallStm) vdmNode; PDefinition rootDef = c.getRootdef(); while (rootDef instanceof AInheritedDefinition) { rootDef = ((AInheritedDefinition) rootDef).getSuperdef(); } if (rootDef instanceof AExplicitOperationDefinition) { AExplicitOperationDefinition op = (AExplicitOperationDefinition) rootDef; if (op.getIsConstructor()) { return getObjectInitializerCall(op); } } } } return null; }
INode vdmNode = sourceNode.getVdmNode();
public SSeqTypeIR getSeqTypeCloned(STypeIR typeCg) throws AnalysisException { if (typeCg instanceof SSeqTypeIR) { SSeqTypeIR seqTypeCg = (SSeqTypeIR) typeCg; return seqTypeCg.clone(); } else { SourceNode sourceNode = typeCg.getSourceNode(); if (sourceNode != null && sourceNode.getVdmNode() instanceof PType) { PType vdmType = (PType) sourceNode.getVdmNode(); SSeqType seqType = info.getTcFactory().createPTypeAssistant().getSeq(vdmType); try { typeCg = seqType.apply(info.getTypeVisitor(), info); return (SSeqTypeIR) typeCg; } catch (org.overture.ast.analysis.AnalysisException e) { } } throw new AnalysisException("Exptected sequence type. Got: " + typeCg); } }
public <T extends STypeIR> T searchType(SExpIR exp, TypeFinder<T> typeFinder) { if (exp == null || exp.getType() == null) { return null; } SourceNode sourceNode = exp.getType().getSourceNode(); if (sourceNode == null) { return null; } org.overture.ast.node.INode vdmTypeNode = sourceNode.getVdmNode(); if (vdmTypeNode instanceof PType) { try { PType vdmType = (PType) vdmTypeNode; return typeFinder.findType(vdmType); } catch (org.overture.ast.analysis.AnalysisException e) { } } return null; }
private String findNumberDereferenceCall(STypeIR type) { if (type == null || type.parent() instanceof AHistoryExpIR) { return ""; } final String DOUBLE_VALUE = ".doubleValue()"; final String LONG_VALUE = ".longValue()"; if (info.getAssistantManager().getTypeAssistant().isInt(type)) { return LONG_VALUE; } else if (info.getAssistantManager().getTypeAssistant().isRealOrRat(type)) { return DOUBLE_VALUE; } else { PTypeAssistantTC typeAssistant = info.getTcFactory().createPTypeAssistant(); SourceNode sourceNode = type.getSourceNode(); if (sourceNode != null && !(sourceNode.getVdmNode() instanceof PType)) { PType vdmType = (PType) sourceNode.getVdmNode(); if (typeAssistant.isNumeric(vdmType)) { return DOUBLE_VALUE; } } return ""; } }
if (source != null) org.overture.ast.node.INode vdmNode = source.getVdmNode();
recClass.setDependencies(imports); extraClasses.add(new IRStatus<PIR>(recClass.getSourceNode().getVdmNode(), recClass.getName(), recClass, new HashSet<VdmNodeInfo>()));
@Override public void inAElemsUnaryExpIR(AElemsUnaryExpIR node) throws AnalysisException { if (handleUnaryExp(node)) { SExpIR exp = node.getExp(); PType vdmType = (PType) exp.getType().getSourceNode().getVdmNode(); SSeqType seqType = transAssistant.getInfo().getTcFactory().createPTypeAssistant().getSeq(vdmType); try { STypeIR typeCg = seqType.apply(transAssistant.getInfo().getTypeVisitor(), transAssistant.getInfo()); if (typeCg instanceof SSeqTypeIR) { correctTypes(exp, typeCg); } } catch (org.overture.ast.analysis.AnalysisException e) { } } }
@Override public void inAMapDomainUnaryExpIR(AMapDomainUnaryExpIR node) throws AnalysisException { if (handleUnaryExp(node)) { SExpIR exp = node.getExp(); PType vdmType = (PType) exp.getType().getSourceNode().getVdmNode(); SMapType mapType = transAssistant.getInfo().getTcFactory().createPTypeAssistant().getMap(vdmType); try { STypeIR typeCg = mapType.apply(transAssistant.getInfo().getTypeVisitor(), transAssistant.getInfo()); if (typeCg instanceof SMapTypeIR) { correctTypes(exp, typeCg); } } catch (org.overture.ast.analysis.AnalysisException e) { } } }
if (sourceNode != null) INode vdmNode = sourceNode.getVdmNode();
AVarDeclIR objDecl = transAssistant.getInfo().getDeclAssistant().consLocalVarDecl(node.getSourceNode().getVdmNode(), objType.clone(), id, objExp.clone());