summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/aplwc_internal.h13
-rw-r--r--src/lib/eval.c4
-rw-r--r--src/lib/main.c13
-rw-r--r--src/lib/memory.c16
4 files changed, 41 insertions, 5 deletions
diff --git a/src/lib/aplwc_internal.h b/src/lib/aplwc_internal.h
index 833a351..4ad30f8 100644
--- a/src/lib/aplwc_internal.h
+++ b/src/lib/aplwc_internal.h
@@ -53,8 +53,17 @@ struct token_list {
struct token tokens[1];
};
+enum value_tag {
+ VALUE_NUMBER
+};
+
+struct aplwc_value {
+ struct aplwc *aplwc;
+ enum value_tag tag;
+};
+
/* eval.c */
-void eval_line(struct aplwc_line *);
+struct aplwc_value *eval_line(struct aplwc_line *);
/* memory.c */
struct memory memory_init(uint8_t *, size_t);
@@ -62,10 +71,12 @@ struct aplwc *memory_alloc_aplwc(struct memory *);
struct aplwc_line *memory_alloc_aplwc_line(struct memory *);
struct string *memory_alloc_string(struct memory *, size_t);
struct token_list *memory_alloc_token_list(struct memory *, size_t);
+struct aplwc_value *memory_alloc_aplwc_value(struct memory *);
void memory_free_aplwc(struct memory *, struct aplwc *);
void memory_free_aplwc_line(struct memory *, struct aplwc_line *);
void memory_free_string(struct memory *, struct string *);
void memory_free_token_list(struct memory *, struct token_list *);
+void memory_free_aplwc_value(struct memory *, struct aplwc_value *);
/* string.c */
struct string *chars_to_string(struct aplwc *, const char *);
diff --git a/src/lib/eval.c b/src/lib/eval.c
index 89bdf59..07bbedd 100644
--- a/src/lib/eval.c
+++ b/src/lib/eval.c
@@ -1,7 +1,9 @@
#include "aplwc_internal.h"
-void
+struct aplwc_value *
eval_line(struct aplwc_line *line)
{
+ assert(line->aplwc->last_error == APLWC_OK);
line->aplwc->last_error = APLWC_NOT_YET_IMPLEMENTED;
+ return NULL;
}
diff --git a/src/lib/main.c b/src/lib/main.c
index 9335bf0..7456958 100644
--- a/src/lib/main.c
+++ b/src/lib/main.c
@@ -99,10 +99,17 @@ aplwc_free_line(struct aplwc_line *line)
memory_free_aplwc_line(&line->aplwc->memory, line);
}
-enum aplwc_rc
+struct aplwc_value *
aplwc_eval(struct aplwc_line *line)
{
line->aplwc->last_error = APLWC_OK;
- eval_line(line);
- return line->aplwc->last_error;
+ return eval_line(line);
+}
+
+void
+aplwc_free_value(struct aplwc_value *value)
+{
+ if(value == NULL)
+ return;
+ memory_free_aplwc_value(&value->aplwc->memory, value);
}
diff --git a/src/lib/memory.c b/src/lib/memory.c
index 41ac90d..f34ff43 100644
--- a/src/lib/memory.c
+++ b/src/lib/memory.c
@@ -102,3 +102,19 @@ memory_free_token_list(struct memory *m, struct token_list *p)
UNUSED_PARAMETER(m);
UNUSED_PARAMETER(p);
}
+
+struct aplwc_value *
+memory_alloc_aplwc_value(struct memory *m)
+{
+ struct aplwc_value *p;
+
+ p = alloc(m, sizeof(struct aplwc_value), alignof(struct aplwc_value));
+ return p;
+}
+
+void
+memory_free_aplwc_value(struct memory *m, struct aplwc_value *p)
+{
+ UNUSED_PARAMETER(m);
+ UNUSED_PARAMETER(p);
+}