File tree Expand file tree Collapse file tree 6 files changed +22
-5
lines changed Expand file tree Collapse file tree 6 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ rule initial = parse
3030 | " mutable" {TA_Mutable }
3131 | " mutator" {TA_Mutator }
3232 | " shallow" {TA_Shallow }
33+ | " object_literal" {TA_Object_literal }
3334 | " Version" {TVersion }
3435 | ['a' - 'z''A' - 'Z''$''_' ]['a' - 'z''A' - 'Z''$''_''0' - '9' ]* {
3536 let x = Lexing. lexeme lexbuf in
Original file line number Diff line number Diff line change 2020
2121
2222% token TProvides TRequires TVersion
23- % token TA_Pure TA_Const TA_Mutable TA_Mutator TA_Shallow
23+ % token TA_Pure TA_Const TA_Mutable TA_Mutator TA_Shallow TA_Object_literal
2424% token< string > TIdent TVNum
2525% token TComma TSemi EOF EOL LE LT GE GT EQ LPARENT RPARENT
2626% token< string > TOTHER
@@ -49,6 +49,7 @@ prim_annot:
4949arg_annot:
5050 | TA_Const { `Const }
5151 | TA_Shallow { `Shallow_const }
52+ | TA_Object_literal { `Object_literal }
5253 | TA_Mutable { `Mutable }
5354
5455op:
Original file line number Diff line number Diff line change @@ -230,8 +230,23 @@ let expr_escape st _x e =
230230 | Expr (Block (_ , a )) ->
231231 Array. iter (fun x -> block_escape st x) a
232232 | _ -> block_escape st v
233+ end
234+ | Pv v ,`Object_literal ->
235+ begin match st.defs.(Var. idx v) with
236+ | Expr (Block (_ , a )) ->
237+ Array. iter
238+ (fun x ->
239+ begin match st.defs.(Var. idx x) with
240+ | Expr (Block (_ , [|k; v|])) ->
241+ block_escape st v
242+ | _ ->
243+ block_escape st x
244+ end )
245+ a
246+ | _ ->
247+ block_escape st v
233248 end ;
234- | Pv v , _ -> block_escape st v
249+ | Pv v , `Mutable -> block_escape st v
235250 end ;
236251 loop ax kx in
237252 loop l ka
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ let rec resolve nm = try resolve (Hashtbl.find aliases nm) with Not_found -> nm
2525(* ***)
2626
2727type kind = [ `Pure | `Mutable | `Mutator ]
28- type kind_arg = [`Shallow_const | `Const | `Mutable ]
28+ type kind_arg = [`Shallow_const | `Object_literal | ` Const | `Mutable ]
2929type t = [
3030 | `Requires of Parse_info .t option * string list
3131 | `Provides of Parse_info .t option * string * kind * kind_arg list option
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ val is_pure : string -> bool
2222val exists : string -> bool
2323
2424type kind = [ `Pure | `Mutable | `Mutator ]
25- type kind_arg = [`Shallow_const | `Const | `Mutable ]
25+ type kind_arg = [`Shallow_const | `Object_literal | ` Const | `Mutable ]
2626type t =
2727 [ `Requires of Parse_info .t option * string list
2828 | `Provides of Parse_info .t option * string * kind * kind_arg list option
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ function caml_pure_js_expr (s){
125125 js_print_stderr ( "caml_pure_js_expr: fallback to runtime evaluation" ) ;
126126 return eval ( s . toString ( ) ) ; }
127127
128- //Provides: caml_js_object (shallow )
128+ //Provides: caml_js_object (object_literal )
129129//Requires: MlString
130130function caml_js_object ( a ) {
131131 var o = { } ;
You can’t perform that action at this time.
0 commit comments