@@ -80,6 +80,7 @@ type loc_kind =
80
80
type prim =
81
81
| Primitive of Lambda .primitive * int
82
82
| External of Primitive .description
83
+ | Sys_argv
83
84
| Comparison of comparison * comparison_kind
84
85
| Raise of Lambda .raise_kind
85
86
| Raise_with_backtrace
@@ -349,7 +350,7 @@ let primitives_table =
349
350
" %bswap_native" , Primitive ((Pbbswap (Pnativeint )), 1 );
350
351
" %int_as_pointer" , Primitive (Pint_as_pointer , 1 );
351
352
" %opaque" , Primitive (Popaque , 1 );
352
- " %sys_argv" , External prim_sys_argv ;
353
+ " %sys_argv" , Sys_argv ;
353
354
" %send" , Send ;
354
355
" %sendself" , Send_self ;
355
356
" %sendcache" , Send_cache ;
@@ -645,8 +646,8 @@ let lambda_of_prim prim_name prim loc args arg_exps =
645
646
match prim, args with
646
647
| Primitive (prim , arity ), args when arity = List. length args ->
647
648
Lprim (prim, args, loc)
648
- | External prim , args when prim = prim_sys_argv ->
649
- Lprim (Pccall prim, Lconst (const_int 0 ) :: args , loc)
649
+ | Sys_argv , [] ->
650
+ Lprim (Pccall prim_sys_argv, [ Lconst (const_int 0 )] , loc)
650
651
| External prim , args ->
651
652
Lprim (Pccall prim, args, loc)
652
653
| Comparison (comp , knd ), ([_ ;_ ] as args ) ->
@@ -694,7 +695,7 @@ let lambda_of_prim prim_name prim loc args arg_exps =
694
695
| Send_cache , [obj; meth; cache; pos] ->
695
696
Lsend (Cached , meth, obj, [cache; pos], loc)
696
697
| (Raise _ | Raise_with_backtrace
697
- | Lazy_force | Loc _ | Primitive _ | Comparison _
698
+ | Lazy_force | Loc _ | Primitive _ | Sys_argv | Comparison _
698
699
| Send | Send_self | Send_cache ), _ ->
699
700
raise(Error (to_location loc, Wrong_arity_builtin_primitive prim_name))
700
701
@@ -704,6 +705,7 @@ let check_primitive_arity loc p =
704
705
match prim with
705
706
| Primitive (_ ,arity ) -> arity = p.prim_arity
706
707
| External _ -> true
708
+ | Sys_argv -> p.prim_arity = 0
707
709
| Comparison _ -> p.prim_arity = 2
708
710
| Raise _ -> p.prim_arity = 1
709
711
| Raise_with_backtrace -> p.prim_arity = 2
@@ -778,7 +780,7 @@ let lambda_primitive_needs_event_after = function
778
780
(* Determine if a primitive should be surrounded by an "after" debug event *)
779
781
let primitive_needs_event_after = function
780
782
| Primitive (prim ,_ ) -> lambda_primitive_needs_event_after prim
781
- | External _ -> true
783
+ | External _ | Sys_argv -> true
782
784
| Comparison (comp , knd ) ->
783
785
lambda_primitive_needs_event_after (comparison_primitive comp knd)
784
786
| Lazy_force | Send | Send_self | Send_cache -> true
0 commit comments