@@ -37,11 +37,13 @@ heavy::ExternBuiltinSyntax cond_expand;
3737heavy::ExternBuiltinSyntax define;
3838heavy::ExternBuiltinSyntax define_syntax;
3939heavy::ExternBuiltinSyntax syntax_rules;
40+ heavy::ExternBuiltinSyntax ir_macro_transformer;
4041heavy::ExternBuiltinSyntax if_;
4142heavy::ExternBuiltinSyntax lambda;
4243heavy::ExternBuiltinSyntax quasiquote;
4344heavy::ExternBuiltinSyntax quote;
4445heavy::ExternBuiltinSyntax set;
46+ heavy::ExternBuiltinSyntax syntax_error;
4547
4648
4749heavy::ExternFunction add;
@@ -158,6 +160,10 @@ mlir::Value syntax_rules(OpGen& OG, Pair* P) {
158160 SpecInput->Car , SpecInput->Cdr );
159161}
160162
163+ mlir::Value ir_macro_transformer (OpGen& OG, Pair* P) {
164+ llvm_unreachable (" TODO" );
165+ }
166+
161167mlir::Value lambda (OpGen& OG, Pair* P) {
162168 Pair* P2 = dyn_cast<Pair>(P->Cdr );
163169 Value Formals = P2->Car ;
@@ -203,6 +209,17 @@ mlir::Value set(OpGen& OG, Pair* P) {
203209 return OG.createSet (P->getSourceLocation (), S, Expr);
204210}
205211
212+ mlir::Value syntax_error (OpGen& OG, Pair* P) {
213+ heavy::SourceLocation Loc = P->getSourceLocation ();
214+ Pair* P2 = dyn_cast<Pair>(P->Cdr );
215+ if (!P2)
216+ return OG.SetError (" invalid syntax-error... syntax" , P);
217+ llvm::SmallVector<mlir::Value, 8 > Args;
218+ for (auto [Loc, V] : WithSource (P2))
219+ Args.push_back (OG.createLiteral (Loc, V));
220+ return OG.createSyntaxError (Loc, Args);
221+ }
222+
206223namespace {
207224 void import_helper (Context& C, ValueRefs Args) {
208225 if (Pair* P = dyn_cast<Pair>(Args[0 ])) {
@@ -869,6 +886,8 @@ void HEAVY_BASE_INIT(heavy::Context& Context) {
869886 HEAVY_BASE_VAR (define) = heavy::base::define;
870887 HEAVY_BASE_VAR (define_syntax) = heavy::base::define_syntax;
871888 HEAVY_BASE_VAR (syntax_rules) = heavy::base::syntax_rules;
889+ HEAVY_BASE_VAR (ir_macro_transformer)
890+ = heavy::base::ir_macro_transformer;
872891 HEAVY_BASE_VAR (if_) = heavy::base::if_;
873892 HEAVY_BASE_VAR (lambda) = heavy::base::lambda;
874893 HEAVY_BASE_VAR (quasiquote) = heavy::base::quasiquote;
@@ -952,6 +971,8 @@ void HEAVY_BASE_LOAD_MODULE(heavy::Context& Context) {
952971 {" quote" , HEAVY_BASE_VAR (quote)},
953972 {" set!" , HEAVY_BASE_VAR (set)},
954973 {" syntax-rules" , HEAVY_BASE_VAR (syntax_rules)},
974+ {" ir-macro-transformer" ,
975+ HEAVY_BASE_VAR (ir_macro_transformer)},
955976 {" begin" , HEAVY_BASE_VAR (begin)},
956977 {" cond-expand" , HEAVY_BASE_VAR (cond_expand)},
957978 {" define-library" ,HEAVY_BASE_VAR (define_library)},
0 commit comments