mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-19 05:40:38 +01:00
Replace a define in implementation to an attribute for context.
Change-Id: I70b246c37c214d22079efd92c8b88f21206b87c9
This commit is contained in:
@@ -21,6 +21,7 @@ class Context {
|
||||
Expression * expression;
|
||||
};
|
||||
ContextPair * m_pairs;
|
||||
const uint16_t kMaxContextPairs = 10;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MAX_CONTEXT_PAIRS 10
|
||||
|
||||
Context::Context() {
|
||||
size_t size = sizeof(ContextPair)*MAX_CONTEXT_PAIRS;
|
||||
size_t size = sizeof(ContextPair)*this->kMaxContextPairs;
|
||||
m_pairs = (ContextPair *)malloc(size);
|
||||
memset(m_pairs, 0, size);
|
||||
}
|
||||
@@ -15,7 +13,7 @@ Context::~Context() {
|
||||
}
|
||||
|
||||
Expression * Context::operator[](const char * symbol_name) const {
|
||||
for (int16_t i=0; i<MAX_CONTEXT_PAIRS; i++) {
|
||||
for (int16_t i=0; i<this->kMaxContextPairs; i++) {
|
||||
ContextPair p = m_pairs[i];
|
||||
if (p.name != NULL && strcmp(p.name, symbol_name) == 0) {
|
||||
return p.expression;
|
||||
@@ -25,7 +23,7 @@ Expression * Context::operator[](const char * symbol_name) const {
|
||||
}
|
||||
|
||||
void Context::setExpressionForSymbolName(Expression * expression, const char * symbol_name) {
|
||||
for (int16_t i=0; i<MAX_CONTEXT_PAIRS; i++) {
|
||||
for (int16_t i=0; i<this->kMaxContextPairs; i++) {
|
||||
ContextPair * p = &m_pairs[i];
|
||||
if (p->name == NULL) {
|
||||
// FIXME: Should be copied or retained!
|
||||
|
||||
Reference in New Issue
Block a user