Project

General

Profile

root / trunk / compiler / ooasCompiler / src / org / momut / ooas / ast / identifiers / AttributeIdentifier.java @ 9

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
  *               Stefan Tiran (AIT)
25
  *
26
  */
27

    
28

    
29
package org.momut.ooas.ast.identifiers;
30

    
31
import org.antlr.runtime.Token;
32
import org.momut.ooas.ast.IAstVisitor;
33
import org.momut.ooas.ast.IScope;
34
import org.momut.ooas.ast.expressions.Expression;
35
import org.momut.ooas.ast.types.Type;
36
import org.momut.ooas.utils.exceptions.ArgumentException;
37

    
38
public final class AttributeIdentifier extends ValueReferenceIdentifier
39
{
40
        private Expression m_initializer;
41
        private final boolean m_isStatic;
42
        private final boolean m_isObservable;    // used for qualitative values
43
        private final boolean m_isControllable;  // used for qualitative values
44

    
45
        public Expression initializer() { return m_initializer; }
46
        public boolean isStatic() { return m_isStatic; }
47
        public boolean isObservable() { return m_isObservable; }
48
        public boolean isControllable() { return m_isControllable; }
49

    
50
        public AttributeIdentifier(Token aToken,
51
                        Type aType,
52
                        IScope aDefiningScope,
53
                        Expression anInitializer,
54
                        boolean isStatic,
55
                        boolean isObservable,
56
                        boolean isControllable)
57
        {
58
                super(aToken, aType, IdentifierKind.AttributeIdentifier, aDefiningScope);
59
                m_initializer = anInitializer;
60
                m_isStatic = isStatic;
61
                m_isControllable = isControllable;
62
                m_isObservable = isObservable;
63
        }
64

    
65
        public AttributeIdentifier(String name,
66
                        Type aType,
67
                        IScope aDefiningScope,
68
                        Expression anInitializer,
69
                        boolean isStatic,
70
                        boolean isObservable,
71
                        boolean isControllable)
72
        {
73
                super(name, aType, IdentifierKind.AttributeIdentifier, aDefiningScope);
74
                m_initializer = anInitializer;
75
                m_isStatic = isStatic;
76
                m_isControllable = isControllable;
77
                m_isObservable = isObservable;
78
        }
79

    
80
        public AttributeIdentifier(AttributeIdentifier toCopy)
81
        {
82
                super(toCopy);
83
                m_initializer = toCopy.initializer();
84
                m_isStatic = toCopy.m_isStatic;
85
                m_isControllable = toCopy.m_isControllable;
86
                m_isObservable = toCopy.m_isObservable;
87
        }
88

    
89

    
90
        @Override
91
        public /*override*/ Identifier Clone()
92
        {
93
                return new AttributeIdentifier(this);
94
        }
95

    
96
        @Override
97
        public /*override*/ void Accept(IAstVisitor visitor)
98
        {
99
                visitor.visit(this);
100
        }
101

    
102
        public void SetInitializer(Expression newExpr)
103
        {
104
                if (newExpr == null)
105
                        throw new ArgumentException();
106
                m_initializer = newExpr;
107
        }
108
}