about summary refs log tree commit diff
path: root/src/variable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/variable.c b/src/variable.c
index 38ea2e3..b764c28 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -30,3 +30,29 @@ struct CCLVariable *ccl_variable_getany(struct CCL *ccl, struct CCLFrame *frame,
 
     return NULL;
 }
+
+struct CCLVariable *ccl_variable_set(struct CCLVariable *vars, char name, CCLNum value)
+{
+    struct CCLVariable *toset;
+    struct CCLVariable var = (struct CCLVariable)
+    {
+        .next = NULL,
+        .name = name,
+        .value = value,
+    };
+
+    if (vars->name == '_')
+    {
+        toset = vars;
+        var.prev = NULL;
+    } else
+    {
+        for (toset = vars; toset->next != NULL; toset = toset->next);
+        toset->next = (struct CCLVariable *)malloc(sizeof(*toset->next));
+        var.prev = toset;
+        toset = toset->next;
+    }
+
+    *toset = var;
+    return toset;
+}