-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from GlowingScrewdriver/c-lisp
More features for C-Lisp
- Loading branch information
Showing
18 changed files
with
587 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
45 | ||
285 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
(c-lisp | ||
(define ((print int) (n int))) | ||
|
||
(define ((arr_sum int) (a (ptr int)) (n int)) | ||
(declare (i int)) | ||
(declare (sum int)) | ||
(set sum 0) | ||
|
||
(for ((set i 0) | ||
(lt i n) | ||
(set i (add i 1))) | ||
(set sum (add sum (load (ptradd a i))))) | ||
(ret sum)) | ||
|
||
(define ((main void)) | ||
(declare (arr1 (ptr int))) | ||
(declare (arr2 (ptr int))) | ||
(declare (i int)) | ||
|
||
(set arr1 (alloc int 10)) | ||
(set arr2 (alloc int 10)) | ||
|
||
(for ((set i 0) | ||
(lt i 10) | ||
(set i (add i 1))) | ||
(declare (arr_i (ptr int))) | ||
(set arr_i (ptradd arr1 i)) | ||
(store arr_i i) | ||
(set arr_i (ptradd arr2 i)) | ||
(store arr_i (mul i i))) | ||
|
||
(call print (call arr_sum arr1 10)) | ||
(call print (call arr_sum arr2 10)) | ||
(ret))) |
Oops, something went wrong.