aboutsummaryrefslogtreecommitdiffstats
path: root/c_compiler/include/bindings.hpp
diff options
context:
space:
mode:
authorYann Herklotz <ymherklotz@gmail.com>2017-03-27 02:28:29 +0100
committerYann Herklotz <ymherklotz@gmail.com>2017-03-27 02:28:29 +0100
commita7c5f260391da944bd0779e8ac6efb2f0f6b5a6b (patch)
treec64a6d0096a1dc4ee3a0a3fff7649ae1df52dff8 /c_compiler/include/bindings.hpp
parente9657092063e786a52fefcfa4c528bac07472908 (diff)
downloadCompiler-a7c5f260391da944bd0779e8ac6efb2f0f6b5a6b.tar.gz
Compiler-a7c5f260391da944bd0779e8ac6efb2f0f6b5a6b.zip
Working even more
Diffstat (limited to 'c_compiler/include/bindings.hpp')
-rw-r--r--c_compiler/include/bindings.hpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/c_compiler/include/bindings.hpp b/c_compiler/include/bindings.hpp
index 9383d5d..d99d97b 100644
--- a/c_compiler/include/bindings.hpp
+++ b/c_compiler/include/bindings.hpp
@@ -1,15 +1,15 @@
#ifndef BINDINGS_HPP
#define BINDINGS_HPP
-#include <map>
#include <memory>
#include <string>
+#include <unordered_map>
+#include <vector>
class Type;
typedef std::shared_ptr<Type> TypePtr;
-
// struct containing information on the variable declaration
struct DeclarationData
{
@@ -17,21 +17,22 @@ struct DeclarationData
int stack_position;
};
-
// stores bindings for the current scope and where they are in the stack
-class VariableStackBindings
+class Bindings
{
private:
- std::map<std::string, DeclarationData> bindings_;
+ static std::vector<std::string> string_literals;
+
+ std::unordered_map<std::string, DeclarationData> bindings_;
std::string break_label_;
std::string continue_label_;
int stack_counter_;
int expression_stack_;
-
public:
- VariableStackBindings();
+ Bindings();
void insertBinding(const std::string &id, TypePtr type, const int &stack_position);
+ int insertStringLiteral(const std::string &string_literal);
void increaseStackPosition();
void increaseStackPosition(const int &position);
void setStackPosition(const int &stack_counter);
@@ -49,6 +50,9 @@ public:
int stackPosition(const std::string &id) const;
int currentExpressionStackPosition() const;
+ std::pair<std::vector<std::string>::const_iterator, std::vector<std::string>::const_iterator>
+ getStringLiteralIterator() const;
+
bool bindingExists(const std::string &id) const;
};