1 #! /home/vincent/sixpic/gambc-v4_2_9/bin/gsi-script -:dar
3 (include "pic18-sim.scm")
4 (include "utilities.scm")
6 (include "operators.scm")
10 (include "optimizations.scm")
11 (include "code-generation.scm")
13 ;; TODO have a table that says what types can cast to what other, and what can happen implicitly
14 ;; TODO what casts are going to happen, only between different integer sizes ?
15 ;; TODO have this as an a-list. a type as car, and the list of types it can cast to as cdr
19 ;------------------------------------------------------------------------------
21 (define (read-source filename)
22 (shell-command (string-append "cpp -P " filename " > " filename ".tmp"))
23 ;; (##read-all-as-a-begin-expr-from-path ;; TODO use vectoruzed notation to have info on errors (where in the source)
24 ;; (string-append filename ".tmp")
25 ;; (readtable-start-syntax-set (current-readtable) 'six)
29 (string-append filename ".tmp")
31 (input-port-readtable-set!
33 (readtable-start-syntax-set
34 (input-port-readtable (current-input-port))
39 (define (main filename)
41 (output-port-readtable-set!
43 (readtable-sharing-allowed?-set
44 (output-port-readtable (current-output-port))
47 (let ((source (read-source filename)))
49 (let ((ast (parse source)))
51 (let ((cfg (generate-cfg ast)))
52 (remove-branch-cascades-and-dead-code cfg)
54 (let ((code (code-gen filename cfg)))
55 '(pretty-print code))))))