diff --git a/build.sh b/build.sh index 42de6eb..624541a 100755 --- a/build.sh +++ b/build.sh @@ -6,7 +6,6 @@ echo "" echo "----------------------" echo " compiling libslime " echo "----------------------" -echo "" time clang++ --std=c++17 \ src/libslime.cpp -c -o libslime.o \ @@ -16,7 +15,6 @@ echo "" echo "----------------------" echo " compiling fullslime " echo "----------------------" -echo "" # time g++ -fpermissive src/main.cpp -g -o ./bin/slime --std=c++17 || exit 1 time clang++ -D_DEBUG -D_DONT_BREAK_ON_ERRORS \ @@ -26,10 +24,20 @@ time clang++ -D_DEBUG -D_DONT_BREAK_ON_ERRORS \ # src/main.cpp -g -o ./bin/slime --std=c++17 \ # -I3rd/ || exit 1 -echo "" pushd ./bin > /dev/null -# time valgrind --track-origins=yes --leak-check=full --show-leak-kinds=all ./slime --run-tests -time ./slime --run-tests + +echo "" +echo "----------------------" +echo " generating docs " +echo "----------------------" +time valgrind -q ./slime dd || exit 1 + +echo "" +echo "----------------------" +echo " running tests " +echo "----------------------" + +time valgrind -q --track-origins=yes --leak-check=full --show-leak-kinds=all ./slime --run-tests popd > /dev/null popd > /dev/null diff --git a/integration/emacs/slime-mode.el b/integration/emacs/slime-mode.el index 5250aac..c2329a8 100644 --- a/integration/emacs/slime-mode.el +++ b/integration/emacs/slime-mode.el @@ -1,42 +1,120 @@ (require 'cl-lib) (require 'company) +;; "= . args" +;; "> . args" +;; ">= . args" +;; "< . args" +;; "<= . args" +;; "+ . args" +;; "- . args" +;; "* . args" +;; "/ . args" +;; "** a b" +;; "% a b" +;; "get-random-between a b" +;; "assert test" +;; "define-syntax form (:doc \"\") . body" +;; "define definee (:doc \"\") . body" +;; "mutate target source" +;; "vector-length v" +;; "vector-ref vec idx" +;; "vector-set! vec idx val" +;; "set! sym val" +;; "set-car! target source" +;; "set-cdr! target source" +;; "if test then_part else_part" +;; "quote datum" +;; "quasiquote expr" +;; "and . args" +;; "or . args" +;; "not test" +;; "lambda args . body" +;; "apply fun args" +;; "eval expr" +;; "begin . args" +;; "list . args" +;; "pair car cdr" +;; "first seq" +;; "rest seq" +;; "set-type! node new_type" +;; "delete-type! n" +;; "type n" +;; "mem-reset" +;; "info n" +;; "show n" +;; "addr-of var" +;; "generate-docs file_name" +;; "print (:sep \" \") (:end \"\\n\") . things" +;; "read (:prompt \">\"" +;; "exit (:code 0)" +;; "break" +;; "memstat" +;; "mytry try_part catch_part" +;; "load file" +;; "import f" +;; "copy obj" +;; "error type message" +;; "symbol->keyword sym" +;; "string->symbol str" +;; "symbol->string sym" +;; "concat-strings . strings" (defconst slime-built-ins - '("=" ">" ">=" "<" "<=" "+" "-" "*" "/" "**" "%" - "assert" "define" "define-syntax" "mutate" "if" - "quote" "quasiquote" "unquote" "unquote-splicing" "and" "or" "not" "while" "let" - "lambda" "special-lambda" "eval" "begin" "list" "pair" - "first" "rest" "set-type" "delete-type" "type" "info" - "show" "addr-of" "generate-docs" "print" "read" "exit" "break" "memstat" "try" - "load" "import" "copy" "error" "symbol->keyword" "string->symbol" + '("=" ">" ">=" "<" "<=" "+" "-" "*" "/" "**" "%" "get-random-between" + "assert" "define" "define-syntax" "mutate" "if" "vector-length" + "vector-ref" "vector-set!" "set!" "set-car!" "set-cdr!" + "quote" "quasiquote" "unquote" "unquote-splicing" "and" "or" "not" "let" + "lambda" "apply" "eval" "begin" "list" "pair" "create-hash-map" + "hash-map-get" "hash-map-set!" "hash-map-delete!" "vector" + "first" "rest" "set-type!" "delete-type!" "type" "info" "mem-reset" + "show" "addr-of" "generate-docs" "print" "read" "exit" "break" "memstat" + "mytry" "load" "import" "copy" "error" "symbol->keyword" "string->symbol" "symbol->string" "concat-strings")) - -(defun my-slime-eldoc-function () - (let ((symbol (symbol-name (car (read (thing-at-point 'sexp)))))) - (if (member symbol slime-built-ins) - (sample-meta symbol) - (concat symbol " ?")))) - -(defun sample-meta (s) +(defun get-args (s) (cond - ((string= s "=") "(= :rest )") - ((string= s ">") "(> :rest )") - ((string= s ">=") "(>= :rest )") - ((string= s "<") "(< :rest )") - ((string= s "<=") "(<= :rest )") - ((string= s "+") "(+ :rest )") - ((string= s "-") "(- :rest )") - ((string= s "*") "(* :rest )") - ((string= s "/") "(/ :rest )") - ((string= s "**") "(** )") - ((string= s "assert") "(assert )") - ((string= s "define") "(define [doc-string] )") - ((string= s "define-syntax") "(define-syntax [doc-string] )") + ((string= s "=") ". objects") + ((string= s ">") ". objects") + ((string= s ">=") ". objects") + ((string= s "<") ". objects") + ((string= s "<=") ". objects") + ((string= s "+") ". objects") + ((string= s "-") ". objects") + ((string= s "*") ". objects") + ((string= s "/") ". objects") + ((string= s "**") "a b") + ((string= s "%") "a b") + ((string= s "get-random-between") "a b") + ((string= s "assert") "test") + ((string= s "define") "definee (:doc \"\") . body") + ((string= s "define-syntax") "form (:doc \"\") . body") ((string= s "mutate") "(mutate )") ((string= s "if") "(if )") - (t ""))) + (t '()))) + +(defun sample-meta (s) + (message "%s%s%s%s" + (propertize "(" 'face '(:foreground "orange")) + (propertize s 'face '(:foreground "#859900")) + (let ((args (get-args s))) + (if args + (concat " " args) + "")) + (propertize ")" 'face '(:foreground "orange")) + )) + + + +(defun my-slime-eldoc-function () + (let ((sexp-text (thing-at-point 'sexp))) + (when sexp-text + (let* ((sexp (read sexp-text)) + (symbol (if (listp sexp) + (symbol-name (car sexp)) + (symbol-name sexp)))) + (when (member symbol slime-built-ins) + (sample-meta symbol)))))) (add-to-list 'auto-mode-alist '("\\.slime\\'" . slime-mode)) @@ -124,7 +202,7 @@ (setq-local electric-quote-string t)) (setq imenu-case-fold-search nil) (add-function :before-until (local 'eldoc-documentation-function) - #'elisp-eldoc-documentation-function) + #'my-slime-eldoc-function) (add-hook 'xref-backend-functions #'elisp--xref-backend nil t) (setq-local project-vc-external-roots-function #'elisp-load-path-roots) (add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local) @@ -160,7 +238,7 @@ (add-hook 'slime-mode-hook (lambda () - ;; (set (make-local-variable 'eldoc-documentation-function) 'my-slime-eldoc-function) + (set (make-local-variable 'eldoc-documentation-function) 'my-slime-eldoc-function) (set (make-local-variable 'company-backends) '(company-sample-backend)))) (provide 'slime-mode) diff --git a/src/main.cpp b/src/main.cpp index 4acb1c1..d95e2cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,19 +14,21 @@ int main(int argc, char* argv[]) { if (argc > 1) { if (Slime::string_equal(argv[1], "--run-tests")) { int res = Slime::run_all_tests(); - Slime::built_in_load(Slime::Memory::create_string("generate-docs.slime")); - if_debug { - Slime::Memory::free_everything(); - } return res ? 0 : 1; } - - Slime::interprete_file(argv[1]); - if (Slime::Globals::error) { - Slime::log_error(); - return 1; + if (Slime::string_equal(argv[1], "--generate-docs")) { + Slime::Memory::init(4096 * 256* 100); + if (Slime::Globals::error) return 1; + Slime::built_in_load(Slime::Memory::create_string("generate-docs.slime")); + Slime::Memory::free_everything(); + } else { + Slime::interprete_file(argv[1]); } } else { Slime::interprete_stdin(); + return 0; } + + if (Slime::Globals::error) return 1; + } diff --git a/src/testing.cpp b/src/testing.cpp index 7cd4772..a0eb534 100644 --- a/src/testing.cpp +++ b/src/testing.cpp @@ -603,6 +603,9 @@ namespace Slime { bool result = true; try Memory::init(409600); + if_debug { + Slime::Memory::free_everything(); + } push_environment(Memory::create_child_environment( get_current_environment()));