]> git.mdlowis.com Git - proto/sclpl.git/commitdiff
Started to add a return stack rather than using the C stack
authorMichael D. Lowis <mike@mdlowis.com>
Fri, 9 May 2014 20:44:55 +0000 (16:44 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Fri, 9 May 2014 20:44:55 +0000 (16:44 -0400)
SConstruct
source/slvm/extensions/core/core.c
source/slvm/kernel/pal.h
source/slvm/kernel/slvm.h
source/slvm/platforms/C99/pal.c

index c4097347005ca9bdf2c0f601ea0f5323b250d44b..e5c6d5d73b9fef01c0beb0c87f32d8a76b421599 100644 (file)
@@ -121,11 +121,11 @@ c_cpp.StaticLibrary('build/lib/stdpf',
 # VM Executable Using Standard Platform
 c_cpp.Program('build/bin/slvm', [], LIBS = ['vmkernel', 'stdpf'])
 
-#nostdlib.Program('build/bin/slvm',
-#                 glob.glob('source/slvm/*.c'),
-#                 LIBPATH  = ['build/lib'],
-#                 LIBS     = ['gcc', 'stdpf'])
-
-# VM Extensions
-#c_cpp.SharedLibrary('build/lib/ioext', glob.glob('source/slvm/ext/io/*.c'))
+# Build all VM Extensions
+for ext in glob.glob('source/slvm/extensions/*/'):
+    name = os.path.basename(ext.strip('\\/'))
+    c_cpp.StaticLibrary('build/lib/'+name+'ext',
+                        glob.glob(ext + '/*.c'),
+                        CPPPATH = ['source/slvm/kernel'],
+                        LIBS = ['stdpf'])
 
index b3d303ba2d30c1ea59994838f35f51384b9e61c2..ee202e9a5756d168c68f35ed5f3295b1b4f61a12 100644 (file)
@@ -2,8 +2,10 @@
 #include "pal.h"
 #include <stdlib.h>
 
-#if 0
-defcode("if", _if, 1, &bytemove){
+extern word_t zbranch, comma, here, swap, dup, wcode, nrot, rot, sub, wordsz,
+              mul, add, store, branch;
+
+defcode("if", _if, 1, NULL){
     /* Compile branch instruction */
     ArgStack++;
     *(ArgStack) = (val_t)&zbranch;
@@ -59,14 +61,12 @@ defcode("else", _else, 1, &_then){
     EXEC(_then);
     EXEC(swap);
 }
-#endif
 
 dict_t* core_init(dict_t* p_prev)
 {
     dict_t* p_dict = (dict_t*)pal_allocate(sizeof(dict_t));
     p_dict->name    = "core";
     p_dict->p_prev  = p_prev;
-    p_dict->p_words = (word_t*)NULL;
-    //p_dict->p_words = (word_t*)&_fpeekc;
+    p_dict->p_words = (word_t*)&_else;
     return p_dict;
 }
index 634c2dccdf9548d6ffb320dfd532de688acd90e8..8217d92233ba9edc0760b0b387b5e8516c17086e 100644 (file)
@@ -12,6 +12,7 @@
 #include <string.h>
 
 extern val_t* ArgStack;
+extern val_t* RetStack;
 extern val_t* CodePtr;
 
 dict_t* pal_init(dict_t* p_prev_dict);
index dab6db16ea57f2d7999c5d487aaf2b1e56c7ebde..421bf9bb91f38c53c8caded0e55bb57aeb10eb12 100644 (file)
@@ -91,8 +91,8 @@ typedef struct dict_t {
 #define EXEC(word) (word).codeword((word).code)
 
 /** The maximum number of entries that can be on the argument stack */
-#ifndef ARG_STACK_SIZE
-#define ARG_STACK_SIZE 32
+#ifndef STACK_SIZE
+#define STACK_SIZE 32
 #endif
 
 /**
index b6f76d29e794802f8db666d2ae85965022071773..cf586605ede0672a2840104ba10f686eb2166745 100644 (file)
@@ -8,9 +8,12 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-static val_t Stack[ARG_STACK_SIZE];
+static val_t AStack[STACK_SIZE];
+static val_t RStack[STACK_SIZE];
 static bool Line_Read = true;
-val_t* ArgStack = Stack - 1;
+
+val_t* ArgStack = AStack - 1;
+val_t* RetStack = RStack - 1;
 val_t* CodePtr = 0;
 
 defcode("allocate", mem_alloc, 1, NULL){