base = Environment(
ENV = os.environ,
CCFLAGS = [],
- LDFLAGS = [])
+ LDFLAGS = [],
+ LIBPATH = ['build/lib'])
# On windows use mingw because VS is not C99 compliant
if platform.system() == 'Windows':
#---------------------------
c_cpp = base.Clone(CCFLAGS = [ '-Wall', '-Werror', '-std=c99' ])
+# C/C++ Environment Minus Standard Lib
+#-------------------------------------
+nostdlib = c_cpp.Clone(LINKFLAGS = [ '-nostdlib' ],
+ LIBS = ['gcc'])
+
# Chicken Scheme Environment
#---------------------------
# Scheme Source Compiler
#readsof.Depends('readsof', 'sof')
# SCLPL Compiler
-SchemeBuildAndTest( 'build/slc',
+SchemeBuildAndTest( 'build/bin/slc',
find_files('source/slc/','*.scm'),
find_files('tests/slc/','*.scm') )
# SCLPL Package Manager
-SchemeBuildAndTest( 'build/slpkg',
+SchemeBuildAndTest( 'build/bin/slpkg',
find_files('source/slpkg/','*.scm'),
find_files('tests/slpkg/','*.scm') )
# SCLPL Assembler
-SchemeBuildAndTest( 'build/slas',
+SchemeBuildAndTest( 'build/bin/slas',
find_files('source/slas/','*.scm'),
find_files('tests/slas/','*.scm') )
# SCLPL Virtual Machine
-c_cpp.Program('build/slvm',
- glob.glob('source/slvm/*.c') +
- glob.glob('source/slvm/platform/C99/*.c'))
+#----------------------
+# Virtual Machine Kernel
+nostdlib.StaticLibrary('build/lib/vmkernel', glob.glob('source/slvm/kernel/*.c'))
+
+# Standard Platform Library (C99)
+c_cpp.StaticLibrary('build/lib/stdpf',
+ glob.glob('source/slvm/platforms/C99/*.c'),
+ CPPPATH = ['source/slvm/kernel'])
+
+# 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'))
char pal_read_char(void);
char pal_peek_char(void);
bool pal_is_eof(void);
+int pal_strcmp(const char* p_str1, const char* p_str2);
+size_t pal_strlen(char* p_str);
+char* pal_strcpy(char* p_dest, const char* p_src);
#endif /* PAL_H */
static bool is_integer(char* p_str, val_t* p_val)
{
- char* end;
- *(p_val) = (val_t)strtol(p_str,&end,0);
- return (end == &(p_str[strlen(p_str)]));
+ //char* end;
+ //*(p_val) = (val_t)strtol(p_str,&end,0);
+ //return (end == &(p_str[pal_strlen(p_str)]));
+ return false;
}
static bool is_float(char* p_str, val_t* p_val)
static bool is_string(char* p_str, val_t* p_val)
{
bool res = false;
- if((p_str[0] == '"') && (p_str[strlen(p_str)-1] == '"'))
+ if((p_str[0] == '"') && (p_str[pal_strlen(p_str)-1] == '"'))
{
/* Cut off the last double quote */
- p_str[strlen(p_str)-1] = '\0';
+ p_str[pal_strlen(p_str)-1] = '\0';
/* And return the string after the first double quote */
*(p_val) = (val_t)(p_str+1);
res = true;
/* If the string starts with a char indicator (backslash) */
if (p_str[0] == '\\')
{
- size_t length = strlen(p_str);
+ size_t length = pal_strlen(p_str);
/* and it only has one character following it */
if(length == 2)
{
while(named_chars[index])
{
/* If we found a match */
- if( 0 == strcmp( (p_str + 1), (named_chars[index] + 2) ) )
+ if( 0 == pal_strcmp( (p_str + 1), (named_chars[index] + 2) ) )
{
/* Return the character value and indicate success */
*(p_val) = named_chars[index][0];
/* Built-in Constants
*****************************************************************************/
-defconst("VERSION", version, 0, NULL, 1);
-defconst("EXECDEF", execdef, 0, &version, (val_t)&docolon);
-defconst("WORDSZ", wordsz, 0, &execdef, sizeof(val_t));
+defconst("VERSION", version, 0, NULL, 1)
+defconst("EXECDEF", execdef, 0, &version, (val_t)&docolon)
+defconst("WORDSZ", wordsz, 0, &execdef, sizeof(val_t))
/* Built-in Variables
*****************************************************************************/
-defvar("state", state, 0, &wordsz, 0);
-defvar("latest", latest, 0, &state, 0);
+defvar("state", state, 0, &wordsz, 0)
+defvar("latest", latest, 0, &state, 0)
/* Word Words
*****************************************************************************/
char* name = (char*)*(ArgStack);
while(curr)
{
- if (!(curr->flags.attr.hidden) && (0 == strcmp(curr->name,name)))
+ if (!(curr->flags.attr.hidden) && (0 == pal_strcmp(curr->name,name)))
{
break;
}
char* name = 0u;
if (*(ArgStack))
{
- size_t namesz = strlen((char*)*(ArgStack));
+ size_t namesz = pal_strlen((char*)*(ArgStack));
name = (char*)pal_allocate( namesz );
- strcpy(name, (char*)*(ArgStack));
+ pal_strcpy(name, (char*)*(ArgStack));
}
/* Create the word entry */
word_t* word = (word_t*)pal_allocate(sizeof(word_t));
defcode("bmove", bytemove, 0, &bytecopy){
}
-/* Main
- *****************************************************************************/
int main(int argc, char** argv)
{
- /* Default Kernel dictionary */
- //static dict_t kernel_dict = { NULL, (word_t*)&bytemove };
+ (void)argc;
+ (void)argv;
/* Compile-time Assertions */
CT_ASSERT(sizeof(val_t) == sizeof(val_t*));
CT_ASSERT(sizeof(val_t) == sizeof(flags_t));
/* Platform specific initialization */
- //_stdin_val = (val_t)stdin;
- //_stdout_val = (val_t)stdout;
- //_stderr_val = (val_t)stderr;
latest_val = (val_t)&bytemove;
/* Start the interpreter */
return 0;
}
+/* Main
+ *****************************************************************************/
+//int main(int argc, char** argv)
+//{
+// /* Compile-time Assertions */
+// CT_ASSERT(sizeof(val_t) == sizeof(val_t*));
+// CT_ASSERT(sizeof(val_t) == sizeof(flags_t));
+//
+// /* Platform specific initialization */
+// latest_val = (val_t)&bytemove;
+//
+// /* Start the interpreter */
+// EXEC(quit);
+// return 0;
+//}
+
/* Input/Output Words
*****************************************************************************/
#if 0
}
#endif
-
* */
void docolon(val_t* code);
+void slvm_init(void);
+
#endif /* SLVM_H */
$Revision$
$HeadURL$
*/
-#include "../../pal.h"
+#include "pal.h"
#include <stdio.h>
#include <stdlib.h>
return feof(stdin);
}
+int pal_strcmp(const char* p_str1, const char* p_str2)
+{
+ return strcmp(p_str1, p_str2);
+}
+
+size_t pal_strlen(char* p_str)
+{
+ return strlen( p_str );
+}
+
+char* pal_strcpy(char* p_dest, const char* p_src)
+{
+ return strcpy(p_dest, p_src);
+}