Skip to content

Commit a860258

Browse files
committed
snapshot
1 parent d68cd16 commit a860258

File tree

7 files changed

+236
-299
lines changed

7 files changed

+236
-299
lines changed

lib/4.06.1/bsb.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5281,8 +5281,8 @@ let fn_method = "fn_method"
52815281
let fn_mk = "fn_mk"
52825282
(*let js_fn_runmethod = "js_fn_runmethod"*)
52835283

5284-
let bs_deriving = "bs.deriving"
5285-
let bs_deriving_dot = "bs.deriving."
5284+
5285+
52865286

52875287

52885288
(** nodejs *)

lib/4.06.1/bsb_helper.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,8 @@ let fn_method = "fn_method"
12581258
let fn_mk = "fn_mk"
12591259
(*let js_fn_runmethod = "js_fn_runmethod"*)
12601260

1261-
let bs_deriving = "bs.deriving"
1262-
let bs_deriving_dot = "bs.deriving."
1261+
1262+
12631263

12641264

12651265
(** nodejs *)

lib/4.06.1/unstable/all_ounit_tests.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6048,8 +6048,8 @@ let fn_method = "fn_method"
60486048
let fn_mk = "fn_mk"
60496049
(*let js_fn_runmethod = "js_fn_runmethod"*)
60506050

6051-
let bs_deriving = "bs.deriving"
6052-
let bs_deriving_dot = "bs.deriving."
6051+
6052+
60536053

60546054

60556055
(** nodejs *)

lib/4.06.1/unstable/bspack.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10827,8 +10827,8 @@ let fn_method = "fn_method"
1082710827
let fn_mk = "fn_mk"
1082810828
(*let js_fn_runmethod = "js_fn_runmethod"*)
1082910829

10830-
let bs_deriving = "bs.deriving"
10831-
let bs_deriving_dot = "bs.deriving."
10830+
10831+
1083210832

1083310833

1083410834
(** nodejs *)

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 76 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -69536,8 +69536,8 @@ let fn_method = "fn_method"
6953669536
let fn_mk = "fn_mk"
6953769537
(*let js_fn_runmethod = "js_fn_runmethod"*)
6953869538

69539-
let bs_deriving = "bs.deriving"
69540-
let bs_deriving_dot = "bs.deriving."
69539+
69540+
6954169541

6954269542

6954369543
(** nodejs *)
@@ -400907,21 +400907,21 @@ let external_needs_to_be_encoded (attrs : t)=
400907400907
(fun {txt} ->
400908400908
Ext_string.starts_with txt "bs." || txt = Literals.gentype_import)
400909400909

400910+
let is_inline : attr -> bool =
400911+
(fun
400912+
(({txt;},_) as attr) ->
400913+
let b = txt = "bs.inline" || txt = "inline" in
400914+
(if b then
400915+
Bs_ast_invariant.mark_used_bs_attribute attr);
400916+
b
400917+
) (* still needs to be marked, since we are going to drop it right now *)
400918+
400910400919
let has_inline_in_stru (attrs : t) : bool =
400911-
Ext_list.exists attrs (fun
400912-
({txt;},_) ->
400913-
if txt = "bs.inline" then
400914-
true
400915-
else false)
400920+
Ext_list.exists attrs is_inline
400916400921

400917400922
let has_inline_payload_in_sig (attrs : t) =
400918-
Ext_list.find_first attrs
400919-
(fun
400920-
({txt},_) ->
400921-
if txt = "bs.inline" then
400922-
true
400923-
else false
400924-
)
400923+
Ext_list.find_first attrs is_inline
400924+
400925400925

400926400926
type derive_attr = {
400927400927
bs_deriving : Ast_payload.action list option
@@ -403063,12 +403063,6 @@ val gen_signature:
403063403063
Ast_signature.t
403064403064

403065403065

403066-
val gen_expression :
403067-
string Asttypes.loc ->
403068-
Parsetree.core_type ->
403069-
Parsetree.expression
403070-
403071-
403072403066

403073403067
val gen_structure_signature :
403074403068
Location.t ->
@@ -403145,15 +403139,7 @@ let gen_signature
403145403139
(Ast_payload.table_dispatch !derive_table action).signature_gen
403146403140
tdcls explict_nonrec)
403147403141

403148-
(** used for cases like [%sexp] *)
403149-
let gen_expression ({Asttypes.txt ; loc}) typ =
403150-
let txt = Ext_string.tail_from txt (String.length Literals.bs_deriving_dot) in
403151-
match (Ast_payload.table_dispatch !derive_table
403152-
({txt ; loc}, None)).expression_gen with
403153-
| None ->
403154-
Bs_syntaxerr.err loc (Unregistered txt)
403155403142

403156-
| Some f -> f typ
403157403143

403158403144
open Ast_helper
403159403145
let gen_structure_signature
@@ -406838,7 +406824,7 @@ open Ast_helper
406838406824

406839406825

406840406826
let handle_extension record_as_js_object e (self : Bs_ast_mapper.mapper)
406841-
(({txt ; loc} as lid , payload) : Parsetree.extension) =
406827+
(({txt ; loc} , payload) : Parsetree.extension) =
406842406828
begin match txt with
406843406829
| "bs.raw" | "raw" ->
406844406830
Ast_exp_handle_external.handle_raw ~kind:Raw_exp loc payload
@@ -406951,10 +406937,6 @@ let handle_extension record_as_js_object e (self : Bs_ast_mapper.mapper)
406951406937
| _ -> Location.raise_errorf ~loc "Expect an expression here"
406952406938
end
406953406939
| _ ->
406954-
match payload with
406955-
| PTyp typ when Ext_string.starts_with txt Literals.bs_deriving_dot ->
406956-
self.expr self (Ast_derive.gen_expression lid typ)
406957-
| _ ->
406958406940
e (* For an unknown extension, we don't really need to process further*)
406959406941
(* Exp.extension ~loc ~attrs:e.pexp_attributes (
406960406942
self.extension self extension) *)
@@ -408022,7 +408004,7 @@ let signature_item_mapper (self : mapper) (sigi : Parsetree.signature_item) =
408022408004
(match
408023408005
Ast_attributes.has_inline_payload_in_sig
408024408006
pval_attributes with
408025-
| Some ({loc},PStr [{pstr_desc = Pstr_eval ({pexp_desc },_)}]) ->
408007+
| Some (_,PStr [{pstr_desc = Pstr_eval ({pexp_desc },_)}]) ->
408026408008
begin match pexp_desc with
408027408009
| Pexp_constant (
408028408010
Pconst_string
@@ -408074,12 +408056,11 @@ let signature_item_mapper (self : mapper) (sigi : Parsetree.signature_item) =
408074408056
pval_attributes = []
408075408057
}}
408076408058
| _ ->
408077-
Location.raise_errorf ~loc "invalid payload in bs.inline"
408059+
default_mapper.signature_item self sigi
408078408060
end
408079-
| Some ({loc}, _) ->
408080-
Location.raise_errorf ~loc "invalid payload in bs.inline"
408061+
| Some _
408081408062
| None ->
408082-
default_mapper.signature_item self sigi
408063+
default_mapper.signature_item self sigi
408083408064
)
408084408065
| _ -> default_mapper.signature_item self sigi
408085408066

@@ -408105,65 +408086,63 @@ let structure_item_mapper (self : mapper) (str : Parsetree.structure_item) =
408105408086
let pvb_expr = self.expr self pvb_expr in
408106408087
let pvb_attributes = self.attributes self pvb_attributes in
408107408088
let has_inline_property = Ast_attributes.has_inline_in_stru pvb_attributes in
408108-
if has_inline_property then
408109-
begin match pvb_expr.pexp_desc with
408110-
| Pexp_constant(
408111-
Pconst_string
408112-
(s,dec))
408113-
->
408114-
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408115-
{str with pstr_desc = Pstr_primitive {
408116-
pval_name = pval_name ;
408117-
pval_type = Ast_literal.type_string ();
408118-
pval_loc = pvb_loc;
408119-
pval_attributes = [];
408120-
pval_prim = External_ffi_types.inline_string_primitive s dec
408121-
} }
408122-
| Pexp_constant(Pconst_integer (s,None))
408123-
->
408124-
let s = Int32.of_string s in
408125-
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408126-
{str with pstr_desc = Pstr_primitive {
408127-
pval_name = pval_name ;
408128-
pval_type = Ast_literal.type_int ();
408129-
pval_loc = pvb_loc;
408130-
pval_attributes = [];
408131-
pval_prim = External_ffi_types.inline_int_primitive s
408132-
} }
408133-
| Pexp_constant(Pconst_integer (s, Some 'L'))
408134-
->
408135-
let s = Int64.of_string s in
408136-
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408137-
{str with pstr_desc = Pstr_primitive {
408138-
pval_name = pval_name ;
408139-
pval_type = Ast_literal.type_int64;
408140-
pval_loc = pvb_loc;
408141-
pval_attributes = [];
408142-
pval_prim = External_ffi_types.inline_int64_primitive s
408143-
} }
408144-
| Pexp_constant(Pconst_float (s, None))
408145-
->
408146-
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408147-
{str with pstr_desc = Pstr_primitive {
408148-
pval_name = pval_name ;
408149-
pval_type = Ast_literal.type_float;
408150-
pval_loc = pvb_loc;
408151-
pval_attributes = [];
408152-
pval_prim = External_ffi_types.inline_float_primitive s
408153-
} }
408154-
| Pexp_construct ({txt = Lident ("true" | "false" as txt) },None) ->
408155-
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408156-
{str with pstr_desc = Pstr_primitive {
408157-
pval_name = pval_name ;
408158-
pval_type = Ast_literal.type_bool ();
408159-
pval_loc = pvb_loc;
408160-
pval_attributes = [];
408161-
pval_prim = External_ffi_types.inline_bool_primitive (txt = "true")
408162-
} }
408163-
| _ -> Location.raise_errorf ~loc:pvb_loc "invalid payload in bs.inline"
408164-
end
408165-
else
408166-
{ str with pstr_desc = Pstr_value(Nonrecursive, [{pvb_pat ; pvb_expr; pvb_attributes; pvb_loc}])}
408089+
begin match has_inline_property, pvb_expr.pexp_desc with
408090+
| true, Pexp_constant(
408091+
Pconst_string
408092+
(s,dec))
408093+
->
408094+
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408095+
{str with pstr_desc = Pstr_primitive {
408096+
pval_name = pval_name ;
408097+
pval_type = Ast_literal.type_string ();
408098+
pval_loc = pvb_loc;
408099+
pval_attributes = [];
408100+
pval_prim = External_ffi_types.inline_string_primitive s dec
408101+
} }
408102+
| true, Pexp_constant(Pconst_integer (s,None))
408103+
->
408104+
let s = Int32.of_string s in
408105+
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408106+
{str with pstr_desc = Pstr_primitive {
408107+
pval_name = pval_name ;
408108+
pval_type = Ast_literal.type_int ();
408109+
pval_loc = pvb_loc;
408110+
pval_attributes = [];
408111+
pval_prim = External_ffi_types.inline_int_primitive s
408112+
} }
408113+
| true, Pexp_constant(Pconst_integer (s, Some 'L'))
408114+
->
408115+
let s = Int64.of_string s in
408116+
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408117+
{str with pstr_desc = Pstr_primitive {
408118+
pval_name = pval_name ;
408119+
pval_type = Ast_literal.type_int64;
408120+
pval_loc = pvb_loc;
408121+
pval_attributes = [];
408122+
pval_prim = External_ffi_types.inline_int64_primitive s
408123+
} }
408124+
| true, Pexp_constant(Pconst_float (s, None))
408125+
->
408126+
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408127+
{str with pstr_desc = Pstr_primitive {
408128+
pval_name = pval_name ;
408129+
pval_type = Ast_literal.type_float;
408130+
pval_loc = pvb_loc;
408131+
pval_attributes = [];
408132+
pval_prim = External_ffi_types.inline_float_primitive s
408133+
} }
408134+
| true, Pexp_construct ({txt = Lident ("true" | "false" as txt) },None) ->
408135+
Bs_ast_invariant.warn_discarded_unused_attributes pvb_attributes;
408136+
{str with pstr_desc = Pstr_primitive {
408137+
pval_name = pval_name ;
408138+
pval_type = Ast_literal.type_bool ();
408139+
pval_loc = pvb_loc;
408140+
pval_attributes = [];
408141+
pval_prim = External_ffi_types.inline_bool_primitive (txt = "true")
408142+
} }
408143+
| _ ->
408144+
{ str with pstr_desc = Pstr_value(Nonrecursive, [{pvb_pat ; pvb_expr; pvb_attributes; pvb_loc}])}
408145+
end
408167408146
| Pstr_attribute({txt = "bs.config" },_) -> str
408168408147
| _ -> default_mapper.structure_item self str
408169408148

0 commit comments

Comments
 (0)