things from laptop
This commit is contained in:
@@ -6,7 +6,6 @@ echo ""
|
|||||||
echo "----------------------"
|
echo "----------------------"
|
||||||
echo " compiling libslime "
|
echo " compiling libslime "
|
||||||
echo "----------------------"
|
echo "----------------------"
|
||||||
echo ""
|
|
||||||
|
|
||||||
time clang++ --std=c++17 \
|
time clang++ --std=c++17 \
|
||||||
src/libslime.cpp -c -o libslime.o \
|
src/libslime.cpp -c -o libslime.o \
|
||||||
@@ -16,7 +15,6 @@ echo ""
|
|||||||
echo "----------------------"
|
echo "----------------------"
|
||||||
echo " compiling fullslime "
|
echo " compiling fullslime "
|
||||||
echo "----------------------"
|
echo "----------------------"
|
||||||
echo ""
|
|
||||||
|
|
||||||
# time g++ -fpermissive src/main.cpp -g -o ./bin/slime --std=c++17 || exit 1
|
# time g++ -fpermissive src/main.cpp -g -o ./bin/slime --std=c++17 || exit 1
|
||||||
time clang++ -D_DEBUG -D_DONT_BREAK_ON_ERRORS \
|
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 \
|
# src/main.cpp -g -o ./bin/slime --std=c++17 \
|
||||||
# -I3rd/ || exit 1
|
# -I3rd/ || exit 1
|
||||||
|
|
||||||
echo ""
|
|
||||||
pushd ./bin > /dev/null
|
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
|
||||||
popd > /dev/null
|
popd > /dev/null
|
||||||
|
|||||||
+110
-32
@@ -1,42 +1,120 @@
|
|||||||
(require 'cl-lib)
|
(require 'cl-lib)
|
||||||
(require 'company)
|
(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
|
(defconst slime-built-ins
|
||||||
'("=" ">" ">=" "<" "<=" "+" "-" "*" "/" "**" "%"
|
'("=" ">" ">=" "<" "<=" "+" "-" "*" "/" "**" "%" "get-random-between"
|
||||||
"assert" "define" "define-syntax" "mutate" "if"
|
"assert" "define" "define-syntax" "mutate" "if" "vector-length"
|
||||||
"quote" "quasiquote" "unquote" "unquote-splicing" "and" "or" "not" "while" "let"
|
"vector-ref" "vector-set!" "set!" "set-car!" "set-cdr!"
|
||||||
"lambda" "special-lambda" "eval" "begin" "list" "pair"
|
"quote" "quasiquote" "unquote" "unquote-splicing" "and" "or" "not" "let"
|
||||||
"first" "rest" "set-type" "delete-type" "type" "info"
|
"lambda" "apply" "eval" "begin" "list" "pair" "create-hash-map"
|
||||||
"show" "addr-of" "generate-docs" "print" "read" "exit" "break" "memstat" "try"
|
"hash-map-get" "hash-map-set!" "hash-map-delete!" "vector"
|
||||||
"load" "import" "copy" "error" "symbol->keyword" "string->symbol"
|
"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"))
|
"symbol->string" "concat-strings"))
|
||||||
|
|
||||||
|
(defun get-args (s)
|
||||||
|
(cond
|
||||||
|
((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 <expression> <expression>)")
|
||||||
|
((string= s "if") "(if <test> <consequence> <alternative>)")
|
||||||
|
(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 ()
|
(defun my-slime-eldoc-function ()
|
||||||
(let ((symbol (symbol-name (car (read (thing-at-point 'sexp))))))
|
(let ((sexp-text (thing-at-point 'sexp)))
|
||||||
(if (member symbol slime-built-ins)
|
(when sexp-text
|
||||||
(sample-meta symbol)
|
(let* ((sexp (read sexp-text))
|
||||||
(concat symbol " ?"))))
|
(symbol (if (listp sexp)
|
||||||
|
(symbol-name (car sexp))
|
||||||
(defun sample-meta (s)
|
(symbol-name sexp))))
|
||||||
(cond
|
(when (member symbol slime-built-ins)
|
||||||
((string= s "=") "(= :rest <objects>)")
|
(sample-meta symbol))))))
|
||||||
((string= s ">") "(> :rest <numbers>)")
|
|
||||||
((string= s ">=") "(>= :rest <numbers>)")
|
|
||||||
((string= s "<") "(< :rest <numbers>)")
|
|
||||||
((string= s "<=") "(<= :rest <numbers>)")
|
|
||||||
((string= s "+") "(+ :rest <numbers>)")
|
|
||||||
((string= s "-") "(- :rest <numbers>)")
|
|
||||||
((string= s "*") "(* :rest <numbers>)")
|
|
||||||
((string= s "/") "(/ :rest <numbers>)")
|
|
||||||
((string= s "**") "(** <number> <exponent>)")
|
|
||||||
((string= s "assert") "(assert <condition>)")
|
|
||||||
((string= s "define") "(define <name-or-lambda-list> [doc-string] <expression-or-bodx>)")
|
|
||||||
((string= s "define-syntax") "(define-syntax <name-and-lambda-list> [doc-string] <bodx>)")
|
|
||||||
((string= s "mutate") "(mutate <expression> <expression>)")
|
|
||||||
((string= s "if") "(if <test> <consequence> <alternative>)")
|
|
||||||
(t "")))
|
|
||||||
|
|
||||||
|
|
||||||
(add-to-list 'auto-mode-alist '("\\.slime\\'" . slime-mode))
|
(add-to-list 'auto-mode-alist '("\\.slime\\'" . slime-mode))
|
||||||
@@ -124,7 +202,7 @@
|
|||||||
(setq-local electric-quote-string t))
|
(setq-local electric-quote-string t))
|
||||||
(setq imenu-case-fold-search nil)
|
(setq imenu-case-fold-search nil)
|
||||||
(add-function :before-until (local 'eldoc-documentation-function)
|
(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)
|
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
|
||||||
(setq-local project-vc-external-roots-function #'elisp-load-path-roots)
|
(setq-local project-vc-external-roots-function #'elisp-load-path-roots)
|
||||||
(add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local)
|
(add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local)
|
||||||
@@ -160,7 +238,7 @@
|
|||||||
|
|
||||||
(add-hook 'slime-mode-hook
|
(add-hook 'slime-mode-hook
|
||||||
(lambda ()
|
(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))))
|
(set (make-local-variable 'company-backends) '(company-sample-backend))))
|
||||||
|
|
||||||
(provide 'slime-mode)
|
(provide 'slime-mode)
|
||||||
|
|||||||
+10
-8
@@ -14,19 +14,21 @@ int main(int argc, char* argv[]) {
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
if (Slime::string_equal(argv[1], "--run-tests")) {
|
if (Slime::string_equal(argv[1], "--run-tests")) {
|
||||||
int res = Slime::run_all_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;
|
return res ? 0 : 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]);
|
Slime::interprete_file(argv[1]);
|
||||||
if (Slime::Globals::error) {
|
|
||||||
Slime::log_error();
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Slime::interprete_stdin();
|
Slime::interprete_stdin();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Slime::Globals::error) return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -603,6 +603,9 @@ namespace Slime {
|
|||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
try Memory::init(409600);
|
try Memory::init(409600);
|
||||||
|
if_debug {
|
||||||
|
Slime::Memory::free_everything();
|
||||||
|
}
|
||||||
|
|
||||||
push_environment(Memory::create_child_environment(
|
push_environment(Memory::create_child_environment(
|
||||||
get_current_environment()));
|
get_current_environment()));
|
||||||
|
|||||||
Reference in New Issue
Block a user