diff options
| author | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-10-30 00:34:36 +0530 |
|---|---|---|
| committer | Shagun Agrawal <agrawalshagun07@gmail.com> | 2024-10-30 00:34:36 +0530 |
| commit | a94b482b001d99ecffdb31067319773cbde4501e (patch) | |
| tree | 65e53f128b7e63f1e8392e447d113d9dc827e7b4 /src/cljcc/tacky.clj | |
| parent | 40da421300b14e4766718984e0787550aadb9319 (diff) | |
Add emission for functions
Able to execute "hello, world" program.
Some segmentation faults in specific test steps.
Executables not exiting on their own.
Diffstat (limited to 'src/cljcc/tacky.clj')
| -rw-r--r-- | src/cljcc/tacky.clj | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cljcc/tacky.clj b/src/cljcc/tacky.clj index 5451f78..1b339d9 100644 --- a/src/cljcc/tacky.clj +++ b/src/cljcc/tacky.clj @@ -4,7 +4,8 @@ [cljcc.lexer :as l] [cljcc.util :as u] [cljcc.parser :as p] - [cljcc.analyzer :as a])) + [cljcc.analyzer :as a] + [cljcc.symbols :as symbols])) (defn- variable ([] @@ -379,8 +380,9 @@ (dissoc :body) (assoc :instructions instructions)))) -(defn tacky-generate [{ast :block}] - (let [defined? (fn [x] (seq (:body x)))] +(defn tacky-generate [{ast :block symbols :decl-name->symbol}] + (let [_ (symbols/reset-symbols symbols) + defined? (fn [x] (or (= (:identifier x) "main") (seq (:body x))))] (->> ast (filter defined?) (map function-definition->tacky-function)))) |
