From 4d5b6935a6a27ad9f839b26ea67dbf125179fdaa Mon Sep 17 00:00:00 2001 From: pavelyakov Date: Sun, 22 Mar 2020 11:50:49 +0000 Subject: [PATCH] Lisp: upd new function. git-svn-id: svn://kolibrios.org@7745 a494cfbc-eb01-0410-851d-a64ba20cac60 --- programs/cmm/lisp/lisp.c | 2 +- programs/cmm/lisp/stdcall.h | 68 +++++++++++++++++++++++++++++++++++-- 2 files changed, 66 insertions(+), 4 deletions(-) diff --git a/programs/cmm/lisp/lisp.c b/programs/cmm/lisp/lisp.c index 8e1cec97b6..8e383db3dc 100644 --- a/programs/cmm/lisp/lisp.c +++ b/programs/cmm/lisp/lisp.c @@ -230,7 +230,7 @@ void main() } } - IF(initConsole) con_exit stdcall (0); + IF(initConsole) con_exit stdcall (1); ExitProcess(); } diff --git a/programs/cmm/lisp/stdcall.h b/programs/cmm/lisp/stdcall.h index 1aef6dfead..f3bf2a2a9b 100644 --- a/programs/cmm/lisp/stdcall.h +++ b/programs/cmm/lisp/stdcall.h @@ -1,9 +1,30 @@ /* Lisp functions */ -:dword std_exit() + +:dword std_sleep(dword count, args) { - con_exit stdcall (1); - ExitProcess(); + dword ret = 0; + dword arg = 0; + dword val = 0; + WHILE(count) + { + arg = DSDWORD[args]; + REPEAT1: + IF (DSDWORD[arg+4] == TSym) + { + arg = std_get(1, args); + goto REPEAT1; + } + IF (DSDWORD[arg+4] == TInt) + { + EAX = 5; + EBX = DSDWORD[arg]; + $int 0x40 + } + args+=4; + count--; + } + RETURN ret; } :dword std_set(dword count, args) @@ -62,6 +83,12 @@ RETURN ret; } +:dword std_exit(dword count, args) +{ + IF(initConsole) con_exit stdcall (1); + ExitProcess(); +} + :dword std_sub(dword count, args) { dword ret = 0; @@ -80,6 +107,38 @@ RETURN ret; } +:dword std_type(dword count, args) +{ + dword ret = 0; + dword arg = 0; + dword val = 0; + ret = malloc(TLen); + DSDWORD[ret] = "nil"; + DSDWORD[ret+4] = TStr; + WHILE(count) + { + arg = DSDWORD[args]; + REPEAT1: + IF (DSDWORD[arg+4] == TSym) + { + arg = std_get(1, args); + goto REPEAT1; + } + switch (DSDWORD[arg+4]) + { + case TStr: + DSDWORD[ret] = "string"; + break; + case TInt: + DSDWORD[ret] = "integer"; + break; + } + args+=4; + count--; + } + RETURN ret; +} + /* Console functions */ :dword std_print(dword count, args) { @@ -218,6 +277,9 @@ void Init() /* Lisp functions */ functions.set("set", #std_set); functions.set("get", #std_get); + functions.set("type", #std_type); + functions.set("sleep", #std_sleep); + variables.init(100); }