Skip to content

Commit

Permalink
Clean indentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
takagi committed Dec 5, 2017
1 parent 6f328d1 commit f696263
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
13 changes: 6 additions & 7 deletions src/lang/compiler/compile-statement.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@
(defun func-env-add-macrolet-bindings (func-env bindings)
(flet ((aux (func-env0 binding)
(let ((symbol (macrolet-binding-symbol binding))
(arguments (macrolet-binding-arguments binding))
(body (macrolet-binding-body binding)))
(arguments (macrolet-binding-arguments binding))
(body (macrolet-binding-body binding)))
(function-environment-add-macro symbol arguments body
func-env0))))
func-env0))))
(reduce #'aux bindings :initial-value func-env)))

(defun compile-macrolet-statements (statements var-env func-env)
Expand All @@ -162,11 +162,10 @@
(defun compile-macrolet (form var-env func-env)
(let ((bindings (macrolet-bindings form))
(statements (macrolet-statements form)))
(let ((func-env1 (func-env-add-macrolet-bindings func-env
bindings)))
(let ((func-env1 (func-env-add-macrolet-bindings func-env bindings)))
(let ((statements1 (compile-macrolet-statements statements
var-env
func-env1)))
var-env
func-env1)))
(let ((statements2 (indent 2 statements1)))
(format nil "{~%~A}~%" statements2))))))

Expand Down
8 changes: 4 additions & 4 deletions src/lang/syntax.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@
:symbol-macrolet-binding-p
:symbol-macrolet-binding-symbol
:symbol-macrolet-binding-expansion
;; Macrolet statement
;; Macrolet statement
:macrolet-p
:macrolet-bindings
:macrolet-statements
;; Macrolet statement - binding
:macrolet-binding-p
:macrolet-binding-symbol
:macrolet-binding-arguments
:macrolet-binding-arguments
:macrolet-binding-body
;; Do statement
:do-p
Expand Down Expand Up @@ -510,8 +510,8 @@
(cl-pattern:match object
((name bindings . _)
(and (cl-cuda-symbol-p name)
(alexandria:proper-list-p bindings)
(mapcar #'cl-cuda-symbol-p bindings)))
(alexandria:proper-list-p bindings)
(mapcar #'cl-cuda-symbol-p bindings)))
(_ nil)))

(defun macrolet-binding-symbol (binding)
Expand Down
6 changes: 3 additions & 3 deletions t/lang/compiler/compile-statement.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
:compile-if
:compile-let
:compile-symbol-macrolet
:compile-macrolet
:compile-macrolet
:compile-do
:compile-with-shared-memory
:compile-set
Expand Down Expand Up @@ -125,14 +125,14 @@
(let ((var-env (empty-variable-environment))
(func-env (empty-function-environment)))
(let ((lisp-code '(macrolet ((square (x) `(* ,x ,x)))
(return (square 2))))
(return (square 2))))
(c-code (unlines "{"
" return (2 * 2);"
"}")))
(is (compile-macrolet lisp-code var-env func-env) c-code
"basic case 1"))
(let ((lisp-code '(macrolet ((optimized-square (x) (* x x)))
(return (optimized-square 2))))
(return (optimized-square 2))))
(c-code (unlines "{"
" return 4;"
"}")))
Expand Down
6 changes: 3 additions & 3 deletions t/lang/syntax.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@
(diag "Macrolet statement")

(ok (macrolet-p '(macrolet ((x () 'expanded-x))
(return)))
(return)))
"basic case 1")
(ok (macrolet-p '(macrolet ((x () 'expanded-x))
(do-something)
(return)))
(do-something)
(return)))
"basic case 2")
(ok (macrolet-p '(macrolet ((x () 'expanded-x))))
"basic case 3")
Expand Down

0 comments on commit f696263

Please sign in to comment.