root / trunk / compiler / ooasCompiler / src / org / momut / ooas / ast / expressions / Quantifier.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.expressions; |
29 |
|
30 |
import org.momut.ooas.ast.IScope; |
31 |
import org.momut.ooas.ast.identifiers.Identifier; |
32 |
import org.momut.ooas.parser.SymbolTable; |
33 |
|
34 |
///////////////////////////////////////////////
|
35 |
/// Quantifier
|
36 |
///
|
37 |
public abstract class Quantifier extends UnaryOperator implements IScope |
38 |
{ |
39 |
private final SymbolTable m_symbols; |
40 |
private IScope m_parentScope;
|
41 |
|
42 |
public SymbolTable symbols() { return m_symbols; } |
43 |
|
44 |
|
45 |
public Quantifier(ExpressionKind aKind, Expression child, int line, int pos) |
46 |
{ |
47 |
super (aKind, child, line, pos);
|
48 |
m_symbols = new SymbolTable();
|
49 |
} |
50 |
|
51 |
public Quantifier(Quantifier toCopy)
|
52 |
{ |
53 |
super (toCopy);
|
54 |
m_symbols = new SymbolTable(toCopy.m_symbols);
|
55 |
m_parentScope = toCopy.m_parentScope; |
56 |
} |
57 |
|
58 |
|
59 |
@Override
|
60 |
public Identifier ResolveIdentifier(String aName) |
61 |
{ |
62 |
if (m_symbols.Defined(aName))
|
63 |
return m_symbols.Get(aName);
|
64 |
else
|
65 |
return null; |
66 |
} |
67 |
|
68 |
@Override
|
69 |
public IScope GetParentScope()
|
70 |
{ |
71 |
return m_parentScope;
|
72 |
} |
73 |
|
74 |
@Override
|
75 |
public void SetParentScope(IScope parentScope) |
76 |
{ |
77 |
m_parentScope = parentScope; |
78 |
} |
79 |
|
80 |
@Override
|
81 |
public void AddIdentifier(Identifier anIdentifier, Object tag) |
82 |
{ |
83 |
m_symbols.AddIdentifier(anIdentifier); |
84 |
} |
85 |
|
86 |
|
87 |
} |