Project

General

Profile

root / trunk / compiler / cppAst / ast / expressions / Quantifier.hpp @ 9

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

    
23

    
24

    
25

    
26
#pragma once
27

    
28
#include <ast/expressions/UnaryOperator.hpp>
29
#include <ast/IScope.hpp>
30
#include <ast/SymbolTable.hpp>
31
#include <base/Exceptions.hpp>
32
#include <string>
33
#include <ast/identifiers/Identifier.hpp>
34

    
35
namespace Ast {
36

    
37
class Quantifier
38
        : public UnaryOperator
39
        , public IScope
40
{
41
protected:
42
        SymbolTable* m_symbols;
43
        IScope* m_parentScope;
44

    
45
        Quantifier(ExpressionKind kind):
46
                UnaryOperator(kind),
47
                m_symbols (nullptr),
48
                m_parentScope (nullptr)
49
        {}
50
        Quantifier(const Quantifier &toCopy):
51
                UnaryOperator(toCopy),
52
                m_symbols (toCopy.m_symbols),
53
                m_parentScope (toCopy.m_parentScope)
54
        {}
55
public:
56
        ~Quantifier() override {}
57

    
58
        void init(std::int32_t line, std::int32_t pos,
59
                        Type* typeRef,IdentifierList* callTargetsIdentifierListRef, SymbolTable* symbTabRef,
60
                        Expression* child, SymbolTable* symTabRef, IScope* scopeRef)
61
        {
62
                UnaryOperator::init(line,pos,typeRef,callTargetsIdentifierListRef, symbTabRef,child);
63
                m_symbols = symTabRef;
64
                m_parentScope = scopeRef;
65
        }
66

    
67
        SymbolTable* symbols() {return m_symbols;};
68
        Identifier* resolveIdentifier(const std::string& aName) const override { return m_symbols->get(aName); };
69
        IScope* getParentScope() const override {return m_parentScope;};
70
        std::string getScopeName() const override {return "";}
71
        void setParentScope(IScope* parentScope) override {m_parentScope = parentScope;};
72
        void addIdentifier(Identifier* anIdentifier, void* ) override {m_symbols->addIdentifier(anIdentifier);};
73
};
74
}