@Override
 public PExp caseAUnionPattern(AUnionPattern pattern) throws AnalysisException {
   LexToken op = new LexKeywordToken(VDMToken.UNION, pattern.getLocation());
   return AstFactory.newASetUnionBinaryExp(
       af.createPPatternAssistant().getMatchingExpression(pattern.getLeft()),
       op,
       af.createPPatternAssistant().getMatchingExpression(pattern.getRight()));
 }
 @Override
 public PExp caseAConcatenationPattern(AConcatenationPattern pattern) throws AnalysisException {
   LexToken op = new LexKeywordToken(VDMToken.CONCATENATE, pattern.getLocation());
   PExp le = af.createPPatternAssistant().getMatchingExpression(pattern.getLeft());
   PExp re = af.createPPatternAssistant().getMatchingExpression(pattern.getRight());
   return AstFactory.newASeqConcatBinaryExp(le, op, re);
 }
Exemplo n.º 3
0
  @Override
  public List<PDefinition> defaultSClassDefinition(SClassDefinition node) throws AnalysisException {
    List<PDefinition> all = new Vector<PDefinition>();

    all.addAll(node.getAllInheritedDefinitions());
    all.addAll(af.createPDefinitionListAssistant().singleDefinitions(node.getDefinitions()));

    return all;
  }
  @Override
  public PExp caseAObjectPattern(AObjectPattern pattern) throws AnalysisException {
    List<PExp> list = new LinkedList<PExp>();

    for (ANamePatternPair npp : pattern.getFields()) {
      list.add(af.createPPatternAssistant().getMatchingExpression(npp.getPattern()));
    }

    ILexNameToken tpName = pattern.getClassname();
    return AstFactory.newANewExp(pattern.getLocation(), tpName, list);
  }
  @Override
  public PExp caseARecordPattern(ARecordPattern pattern) throws AnalysisException {
    List<PExp> list = new LinkedList<PExp>();

    for (PPattern p : pattern.getPlist()) {
      list.add(af.createPPatternAssistant().getMatchingExpression(p));
    }

    ILexNameToken tpName = pattern.getTypename();
    return AstFactory.newAMkTypeExp(tpName.clone(), list);
  }
Exemplo n.º 6
0
  @Override
  public SSeqType caseAUnionType(AUnionType type) throws AnalysisException {
    // return AUnionTypeAssistantTC.getSeq(type);
    if (!type.getSeqDone()) {
      type.setSeqDone(true); // Mark early to avoid recursion.
      // type.setSeqType(PTypeAssistantTC.getSeq(AstFactory.newAUnknownType(type.getLocation())));
      type.setSeqType(
          af.createPTypeAssistant().getSeq(AstFactory.newAUnknownType(type.getLocation())));
      PTypeSet set = new PTypeSet(af);

      for (PType t : type.getTypes()) {
        if (af.createPTypeAssistant().isSeq(t)) {
          set.add(t.apply(THIS).getSeqof());
        }
      }

      type.setSeqType(
          set.isEmpty()
              ? null
              : AstFactory.newASeqSeqType(type.getLocation(), set.getType(type.getLocation())));
    }

    return type.getSeqType();
  }
Exemplo n.º 7
0
  public void run(
      String moduleName, String traceName, Interpreter interpreter, TraceXmlWrapper store)
      throws Exception {
    this.interpreter = interpreter;

    List<PDefinition> definitions = null;

    if (interpreter instanceof ModuleInterpreter) {
      for (AModuleModules module : ((ModuleInterpreter) interpreter).modules) {
        if (module.getName().getName().equals(moduleName)) {
          definitions = module.getDefs();
        }
      }
    } else {
      for (SClassDefinition classDefinition : ((ClassInterpreter) interpreter).getClasses()) {
        if (classDefinition.getName().getName().equals(moduleName)) {
          definitions =
              assistantFactory.createPDefinitionAssistant().getDefinitions(classDefinition);
        }
      }
    }

    processTraces(definitions, moduleName, traceName, store);
  }
 @Override
 public PExp caseATuplePattern(ATuplePattern pattern) throws AnalysisException {
   return AstFactory.newATupleExp(
       pattern.getLocation(),
       af.createPPatternListAssistant().getMatchingExpressionList(pattern.getPlist()));
 }