Compare commits

..

No commits in common. "d3066748b2e65868d1aa0e835700f7fb9b7a7706" and "31d2f7336bdba8574d9ff7bd9cfd1bf29e8b71bd" have entirely different histories.

3 changed files with 824 additions and 797 deletions

View File

@ -1,4 +1,10 @@
(fn dbg (msg) (do
(if is_phi_compiler (do
(call println "dbg: %" msg)
))
))
(fn Emitter (ast filename) (do
(let output ())
@ -35,6 +41,12 @@
(call define_builtin ident builtin_id)
))
(let is_phi_compiler_sym_id (call define_let "is_phi_compiler" 0))
(call emit (call format
"let _is_phi_compiler% = { type: \"bool\", value: true };\n"
is_phi_compiler_sym_id
))
(call discover_syms ast)
(call emit_exprs ast)
(return (call strings_join output))
@ -87,6 +99,7 @@
(let sym (call get_sym value))
(if (== sym null) (do
(call print_syms)
(call panic "undefined symbol '%' on line %" value line)
))
@ -229,8 +242,6 @@
))
(call emit "))")
) (if (== id "list") (do
(call emit_list_literal (call slice s 1))
) (if (== id "=") (do
(call emit_assign_expr s line "=")
) (if (== id "+=") (do
@ -276,7 +287,7 @@
(call emit ")")
) (do
(call emit_list_literal s)
)))))))))))))))))))))))))
))))))))))))))))))))))))
))
(fn emit_list_literal (s) (do
@ -794,8 +805,8 @@
(let (emit) emitter)
(let js_code (call emit))
(call println "=== js ===")
(call println js_code)
// (call println "=== js ===")
// (call println js_code)
(if (not silent) (call println "writing file '%'..." output_filename))
(call write_text_file output_filename js_code)

7
program.phi Normal file
View File

@ -0,0 +1,7 @@
(fn hello () (do
(call println "hello world")
(call println "hello world")
(return null)
))
(call hello)

1593
stage2.js

File diff suppressed because it is too large Load Diff