435 - starting to allow type definitions

This commit is contained in:
Kartik K. Agaram 2014-12-17 11:01:38 -08:00
parent b93d2cd357
commit a0bb6c0420
2 changed files with 20 additions and 0 deletions

10
mu.arc
View File

@ -1014,6 +1014,16 @@
(assert (is 'make-br-fn _make-br-fn))
(= function*.name (join body function*.name)))
; and-record <type> [ <name:types> ]
and-record
(let (name (_make-br-fn fields)) rest
(assert (is 'make-br-fn _make-br-fn))
(let fields (map tokenize-arg fields)
(= type*.name (obj size len.fields
and-record t
elems (map cdar fields)
fields (map caar fields)))))
; before <label> [ <instructions> ]
;
; multiple before directives => code in order

View File

@ -3319,6 +3319,16 @@
) ; section 100 for string utilities
(reset)
(new-trace "parse-and-record")
(add-code '((and-record foo [
x:string
y:integer
z:boolean
])))
(if (~iso type*!foo (obj size 3 and-record t elems '((string) (integer) (boolean)) fields '(x y z)))
(prn "F - 'add-code' can add new and-records"))
;; unit tests for various helpers
; tokenize-args