|
Revision 176, 1.6 kB
(checked in by BCS, 1 year ago)
|
added a bunch more rules
did a compile time performance tweak in backmath.d
improved automation in do.lisp
|
| Line | |
|---|
| 1 |
(load "string_stuff.lisp") |
|---|
| 2 |
(load "rule_sorting.lisp") |
|---|
| 3 |
(load "generate_case.lisp") |
|---|
| 4 |
|
|---|
| 5 |
;;; load rule set |
|---|
| 6 |
(load "meta.lisp") |
|---|
| 7 |
|
|---|
| 8 |
;;;;;;;;;;; set this to true to make backmath emit compile time debuggin info |
|---|
| 9 |
(DEFCONSTANT verbose nil) |
|---|
| 10 |
|
|---|
| 11 |
;; Convert (OP (rules...)) into a text implementation |
|---|
| 12 |
; |
|---|
| 13 |
(defun Code_Single_Op (L) |
|---|
| 14 |
(let |
|---|
| 15 |
( |
|---|
| 16 |
(opis (car L)) |
|---|
| 17 |
(sorted (Sort_By_generality (cadr L))) |
|---|
| 18 |
) |
|---|
| 19 |
(concatenate |
|---|
| 20 |
'string |
|---|
| 21 |
"template TypeOf" (op_name opis) "(T, V)" nl |
|---|
| 22 |
"{" nl |
|---|
| 23 |
(Test_op_and_build opis sorted) |
|---|
| 24 |
" {}" nl |
|---|
| 25 |
" static if(!is(TypeOf" (op_name opis) "))" nl |
|---|
| 26 |
" static assert(false, `unusable types used for " (op_name opis) ": (" (op_symb opis) " ` ~~ T.LispOf ~~ ` `~~ V.LispOf ~~ `)` );" nl |
|---|
| 27 |
(if verbose |
|---|
| 28 |
(concatenate |
|---|
| 29 |
'string |
|---|
| 30 |
" else" nl |
|---|
| 31 |
" pragma(msg, `>> " (op_name opis) ": (" (op_symb opis) " ` ~~ T.LispOf ~~ ` `~~ V.LispOf ~~ `)" |
|---|
| 32 |
" => `" |
|---|
| 33 |
" ~~ TypeOf" (op_name opis) ".LispOf);" nl |
|---|
| 34 |
) |
|---|
| 35 |
"" |
|---|
| 36 |
) |
|---|
| 37 |
"}" nl |
|---|
| 38 |
) |
|---|
| 39 |
) |
|---|
| 40 |
) |
|---|
| 41 |
|
|---|
| 42 |
;; Map and concantinate Code_Single_Op |
|---|
| 43 |
; |
|---|
| 44 |
(defun Code_Ops (L) |
|---|
| 45 |
(if (endp L) |
|---|
| 46 |
"" |
|---|
| 47 |
(concatenate |
|---|
| 48 |
'string |
|---|
| 49 |
(Code_Single_Op (car L)) |
|---|
| 50 |
(Code_Ops (cdr L)) |
|---|
| 51 |
) |
|---|
| 52 |
) |
|---|
| 53 |
) |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
;; Generate code string from sorted rewriet rule list |
|---|
| 57 |
; |
|---|
| 58 |
(defun gen_Code_For_Template (L) |
|---|
| 59 |
(concatenate |
|---|
| 60 |
'string |
|---|
| 61 |
(Code_Ops (sort_Rewrite_By_Top_Op L )) |
|---|
| 62 |
nl |
|---|
| 63 |
) |
|---|
| 64 |
) |
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 |
;;;; generate code and ump to file |
|---|
| 68 |
(with-open-file (s "generated_rules.d" :direction :output :if-exists :supersede) |
|---|
| 69 |
(format s |
|---|
| 70 |
(gen_Code_For_Template |
|---|
| 71 |
Meta_Rules |
|---|
| 72 |
; '( |
|---|
| 73 |
; ((- (-> b x) a) (+> (- a b) x)) |
|---|
| 74 |
; ((- x a) (+> a x)) |
|---|
| 75 |
; ((+ x a) (-> a x)) |
|---|
| 76 |
; ) |
|---|
| 77 |
) |
|---|
| 78 |
) |
|---|
| 79 |
) |
|---|
| 80 |
|
|---|
| 81 |
'(CODE_GEN_DONE) |
|---|