summaryrefslogtreecommitdiffstats
path: root/Sencha-lang/Elements
diff options
context:
space:
mode:
Diffstat (limited to 'Sencha-lang/Elements')
-rw-r--r--Sencha-lang/Elements/SenchaArray.cpp30
-rw-r--r--Sencha-lang/Elements/SenchaArray.h10
2 files changed, 28 insertions, 12 deletions
diff --git a/Sencha-lang/Elements/SenchaArray.cpp b/Sencha-lang/Elements/SenchaArray.cpp
index 3d48b11..1bd004d 100644
--- a/Sencha-lang/Elements/SenchaArray.cpp
+++ b/Sencha-lang/Elements/SenchaArray.cpp
@@ -7,9 +7,14 @@
#include "SenchaArray.h"
-SenchaArray::SenchaArray() {
+
+
+SenchaArray::SenchaArray(std::string name, Context * context) {
// TODO Auto-generated constructor stub
max_index = 0;
+ this->context = context;
+ this->name = name;
+ context->add(name, SenchaObject());
}
SenchaArray::~SenchaArray() {
@@ -17,32 +22,43 @@ SenchaArray::~SenchaArray() {
}
-SenchaArray::SenchaArray(std::string text)
+SenchaArray::SenchaArray(std::string name, Context * context, std::string text)
{
+ max_index = 0;
+ this->context = context;
+ this->name = name;
for(unsigned int i = 0; i < text.size(); i++)
{
SenchaObject temp;
std::string letter_string = text.substr(i, 1) ;
temp.text = letter_string;
temp.type = SenchaObject::string_literal;
- objects.push_back(temp);
+ context->add("_" + name+ "_" + to_string(i), temp);
+ //objects.push_back(temp);
}
- max_index = objects.size();
+ max_index = text.size();
+ //context->add(name, SenchaObject(text));
}
SenchaObject SenchaArray::get(IndexNumber index)
{
- return objects[index];
+ SenchaObject result = context->get("_" + name +"_" +to_string(index));
+ result.name = "_" + name + "_" + to_string(index);
+ return result;
+ //return objects[index];
}
SenchaArray::IndexNumber SenchaArray::add(SenchaObject value)
{
- objects.push_back(value);
+ context->add("_" + name+ "_" + to_string(max_index), value);
+ max_index++;
+ //objects.push_back(value);
max_index = objects.size();
return max_index;
}
void SenchaArray::set(IndexNumber index, SenchaObject value)
{
- objects[index] = value;
+ //objects[index] = value;
+ context->add("_" + name +"_" +to_string(index), value);
}
diff --git a/Sencha-lang/Elements/SenchaArray.h b/Sencha-lang/Elements/SenchaArray.h
index 09c581b..43c97a2 100644
--- a/Sencha-lang/Elements/SenchaArray.h
+++ b/Sencha-lang/Elements/SenchaArray.h
@@ -7,16 +7,16 @@
#ifndef SENCHAARRAY_H_
#define SENCHAARRAY_H_
-#include <vector>
#include "SenchaObject.h"
#include "Element.h"
+#include "../Context.h"
class SenchaArray: public Element {
public:
- SenchaArray();
- SenchaArray(std::string);
-
- std::vector<SenchaObject> objects;
+ SenchaArray(std::string name, Context * context);
+ SenchaArray(std::string name, Context * context, std::string);
+ Context * context;
+ std::string name;
typedef int IndexNumber;
IndexNumber add(SenchaObject value);