@@ -30,6 +30,11 @@ static uint8_t flisp_system_image[] = {
30
30
extern fltype_t * iostreamtype ;
31
31
static fltype_t * jvtype = NULL ;
32
32
33
+ static value_t true_sym ;
34
+ static value_t false_sym ;
35
+ static value_t fl_error_sym ;
36
+ static value_t fl_null_sym ;
37
+
33
38
static jl_value_t * scm_to_julia (value_t e , int expronly );
34
39
static value_t julia_to_scm (jl_value_t * v );
35
40
@@ -75,7 +80,7 @@ value_t fl_invoke_julia_macro(value_t *args, uint32_t nargs)
75
80
JL_GC_POP ();
76
81
value_t opaque = cvalue (jvtype , sizeof (void * ));
77
82
* (jl_value_t * * )cv_data ((cvalue_t * )ptr (opaque )) = jl_exception_in_transit ;
78
- return fl_list2 (symbol ( "error" ) , opaque );
83
+ return fl_list2 (fl_error_sym , opaque );
79
84
}
80
85
// protect result from GC, otherwise it could be freed during future
81
86
// macro expansions, since it will be referenced only from scheme and
@@ -109,9 +114,6 @@ static builtinspec_t julia_flisp_ast_ext[] = {
109
114
{ NULL , NULL }
110
115
};
111
116
112
- static value_t true_sym ;
113
- static value_t false_sym ;
114
-
115
117
DLLEXPORT void jl_init_frontend (void )
116
118
{
117
119
fl_init (2 * 512 * 1024 );
@@ -132,6 +134,8 @@ DLLEXPORT void jl_init_frontend(void)
132
134
assign_global_builtins (julia_flisp_ast_ext );
133
135
true_sym = symbol ("true" );
134
136
false_sym = symbol ("false" );
137
+ fl_error_sym = symbol ("error" );
138
+ fl_null_sym = symbol ("null" );
135
139
}
136
140
137
141
DLLEXPORT void jl_lisp_prompt (void )
@@ -374,7 +378,7 @@ static value_t julia_to_scm(jl_value_t *v)
374
378
temp = julia_to_scm_ (v );
375
379
}
376
380
FL_CATCH_EXTERN {
377
- temp = fl_list2 (symbol ( "error" ) , cvalue_static_cstring ("expression too large" ));
381
+ temp = fl_list2 (fl_error_sym , cvalue_static_cstring ("expression too large" ));
378
382
}
379
383
return temp ;
380
384
}
@@ -414,7 +418,7 @@ static value_t julia_to_scm_(jl_value_t *v)
414
418
return FL_F ;
415
419
}
416
420
if (v == jl_nothing ) {
417
- return fl_cons (symbol ( "null" ) , FL_NIL );
421
+ return fl_cons (fl_null_sym , FL_NIL );
418
422
}
419
423
if (jl_is_expr (v )) {
420
424
jl_expr_t * ex = (jl_expr_t * )v ;
@@ -514,9 +518,12 @@ jl_value_t *jl_parse_next(void)
514
518
if (isfixnum (a )) {
515
519
jl_lineno = numval (a );
516
520
//jl_printf(JL_STDERR, " on line %d\n", jl_lineno);
517
- return scm_to_julia ( cdr_ (c ), 0 );
521
+ c = cdr_ (c );
518
522
}
519
523
}
524
+ // for error, get most recent line number
525
+ if (iscons (c ) && car_ (c ) == fl_error_sym )
526
+ jl_lineno = numval (fl_applyn (0 , symbol_value (symbol ("jl-parser-current-lineno" ))));
520
527
return scm_to_julia (c ,0 );
521
528
}
522
529
0 commit comments