Project

General

Profile

root / trunk / compiler / ooasCompiler / src / org / momut / ooas / ast / types / QrType.java @ 7

1
/**
2
  *
3
  *                      OOAS Compiler
4
  *
5
  *       Copyright 2015, AIT Austrian Institute of Technology.
6
  * This code is based on the C# Version of the OOAS Compiler, which is
7
  * copyright 2015 by the Institute of Software Technology, Graz University
8
  * of Technology with portions copyright by the AIT Austrian Institute of
9
  * Technology. All rights reserved.
10
  *
11
  * SEE THE "LICENSE" FILE FOR THE TERMS UNDER WHICH THIS FILE IS PROVIDED.
12
  *
13
  * If you modify the file please update the list of contributors below to in-
14
  * clude your name. Please also stick to the coding convention of using TABs
15
  * to do the basic (block-level) indentation and spaces for anything after
16
  * that. (Enable the display of special chars and it should be pretty obvious
17
  * what this means.) Also, remove all trailing whitespace.
18
  *
19
  * Contributors:
20
  *               Willibald Krenn (AIT)
21
  *               Stephan Zimmerer (AIT)
22
  *               Markus Demetz (AIT)
23
  *               Christoph Czurda (AIT)
24
  *
25
  */
26

    
27

    
28
package org.momut.ooas.ast.types;
29

    
30
import java.util.ArrayList;
31

    
32
import org.momut.ooas.ast.IAstVisitor;
33
import org.momut.ooas.ast.identifiers.LandmarkIdentifier;
34
import org.momut.ooas.ast.identifiers.TypeIdentifier;
35
import org.momut.ooas.parser.SymbolTable;
36
import org.momut.ooas.utils.exceptions.SymbolAlreadyDefinedException;
37

    
38
///////////////////////////////////////////////
39
///  Complex Type: QrType
40
///  behaves somewhat similar to an enumerated type..
41
///
42
public final class QrType extends UlyssesType
43
{
44
        private final SymbolTable m_qspaceSymbols;
45
        private final ArrayList<LandmarkIdentifier> m_listOfQspaceSymbols;
46

    
47
        public SymbolTable symbolTable() { return m_qspaceSymbols; }
48
        public ArrayList<LandmarkIdentifier> landmarks() { return m_listOfQspaceSymbols; }
49

    
50
        public QrType(TypeIdentifier anIdentifier)
51
        {
52
                super(TypeKind.QrType, anIdentifier);
53
                m_listOfQspaceSymbols = new ArrayList<LandmarkIdentifier>();
54
                m_qspaceSymbols = new SymbolTable();
55
        }
56

    
57
        public void AddLandmark(LandmarkIdentifier aLandmark)
58
        {
59
                if (m_qspaceSymbols.Defined(aLandmark.tokenText()))
60
                        throw new SymbolAlreadyDefinedException(aLandmark.tokenText());
61

    
62
                m_qspaceSymbols.AddIdentifier(aLandmark);
63
                m_listOfQspaceSymbols.add(aLandmark);
64
        }
65

    
66
        @Override
67
        public void Accept(IAstVisitor visitor)
68
        {
69
                visitor.visit(this);
70
        }
71

    
72
        @Override
73
        public /*override*/ String AnonymousName()
74
        {
75
                StringBuilder result = new StringBuilder();
76
                result.append("qr_");
77
                for (LandmarkIdentifier sym: m_listOfQspaceSymbols)
78
                {
79
                        result.append(sym.tokenText());
80
                        result.append("_");
81
                }
82
                return result.toString();
83
        }
84

    
85
}