]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
commit new type constructors
authorMike D. Lowis <mike@mdlowis.com>
Sun, 24 Mar 2013 21:54:34 +0000 (17:54 -0400)
committerMike D. Lowis <mike@mdlowis.com>
Sun, 24 Mar 2013 21:54:34 +0000 (17:54 -0400)
source/runtime/types/types.c [new file with mode: 0644]
source/runtime/types/types.h [new file with mode: 0644]

diff --git a/source/runtime/types/types.c b/source/runtime/types/types.c
new file mode 100644 (file)
index 0000000..fa08d49
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+    @file types.c
+    @brief See header for details
+    $Revision$
+    $HeadURL$
+*/
+#include "types.h"
+
+var_t new_num(double val)
+{
+    /* Allocate the space */
+    num_t* number = (num_t*)gc_allocate( sizeof(num_t) );
+    /* Populate header info */
+    /* Populate data */
+    number->data = val;
+    /* return the object */
+    return (var_t)number;
+}
+
+var_t new_cell(var_t first, var_t rest)
+{
+    /* Allocate the space */
+    cell_t* cell = (cell_t*)gc_allocate( sizeof(cell_t) );
+    /* Populate header info */
+    /* Populate data */
+    cell->first = first;
+    cell->rest = rest;
+    /* return the object */
+    return (var_t)cell;
+}
+
+var_t new_char(uint32_t val)
+{
+    /* Allocate the space */
+    char_t* character = (char_t*)gc_allocate( sizeof(char_t) );
+    /* Populate header info */
+    /* Populate data */
+    character->data = val;
+    /* return the object */
+    return (var_t)character;
+}
+
diff --git a/source/runtime/types/types.h b/source/runtime/types/types.h
new file mode 100644 (file)
index 0000000..ba2b703
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+    @file types.h
+    @brief TODO: Describe this file
+    $Revision$
+    $HeadURL$
+*/
+#ifndef TYPES_H
+#define TYPES_H
+
+#include <stdbool.h>
+#include <stdint.h>
+
+typedef struct {
+    long info;
+} header_t;
+
+typedef struct {
+    header_t header;
+    long data[1];
+} object_t;
+
+typedef const object_t* var_t;
+
+typedef struct {
+    header_t header;
+    double data;
+} num_t;
+
+var_t new_num(double val);
+
+typedef struct {
+    header_t header;
+    var_t first;
+    var_t rest;
+} cell_t;
+
+var_t new_cell(var_t first, var_t rest);
+
+typedef struct {
+    header_t header;
+    uint32_t data;
+} char_t;
+
+var_t new_char(uint32_t val);
+
+//extern var_t True;
+//extern var_t False;
+
+#endif /* TYPES_H */