From 6a4f1a224273118a5429094ddd83420b7d69b28d Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 1 Jun 2018 08:31:47 +0800 Subject: =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lls/lls.c | 16 +++++++++++++++- lls/lls.h | 13 ++++++++++--- llsVM.c | 17 +++++++++++++++++ test/hello.lls | 2 ++ 4 files changed, 44 insertions(+), 4 deletions(-) diff --git a/lls/lls.c b/lls/lls.c index e8f26ea..927382d 100644 --- a/lls/lls.c +++ b/lls/lls.c @@ -24,7 +24,21 @@ typedef struct } value; } lls_Value; +/* Ö¸Á,×î´óÖ§³Ö255¸ö */ enum { - + MOVE = 1, + ADD, }; + +typedef struct +{ + int ins; + void* operant; +} lls_Ins; + + +int lls_bindfunction(lls_Context* C, const char* fname, lls_Func func) +{ + +} diff --git a/lls/lls.h b/lls/lls.h index 5f190a2..7157070 100644 --- a/lls/lls.h +++ b/lls/lls.h @@ -1,16 +1,23 @@ #ifndef __LLS_H #define __LLS_H +typedef int(*lls_Func)(); + +typedef struct +{ + const char* name; + lls_Func func; +} lls_FuncMap; + typedef struct { int top; + lls_FuncMap* funcMap; } lls_Context; lls_Context* lls_newcontext(); -typedef int (*lls_Function)(); - -int lls_bindfunction(lls_Context* C, const char* fname, lls_Function func); +int lls_bindfunction(lls_Context* C, const char* fname, lls_Func func); int lls_bindvariable(lls_Context* C, const char* vname, void* variable); int lls_bindset(); diff --git a/llsVM.c b/llsVM.c index e69de29..2102d60 100644 --- a/llsVM.c +++ b/llsVM.c @@ -0,0 +1,17 @@ +#include "lls/lls.h" + +int l_print() +{ + + return 0; +} + +const char* source = "print(\"hello, world\")"; + +int main(int args, char* argv[]) +{ + lls_Context* C = lls_newcontext(); + lls_bindfunction(C, "print", l_print); + lls_executesource(C, source, strlen(source)); + return 0; +} \ No newline at end of file diff --git a/test/hello.lls b/test/hello.lls index 86e6a6b..05c8183 100644 --- a/test/hello.lls +++ b/test/hello.lls @@ -100,6 +100,8 @@ func test() arr = {1, 2, 2, 3, 5, 2}; /* 字符串拼接 */ str = "hello " + "world"; + f = {}; + } func main() -- cgit v1.1-26-g67d0