Skip to content

Commit

Permalink
Update upstream source from tag 'upstream/4.2.5'
Browse files Browse the repository at this point in the history
Update to upstream version '4.2.5'
with Debian dir 22abfd8d529e52090aaa6e90dad0cecd031a2de8
  • Loading branch information
andyli committed Sep 4, 2022
2 parents b99dc75 + 83f3436 commit 63003f7
Show file tree
Hide file tree
Showing 20 changed files with 225 additions and 59 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ jobs:
env:
ZLIB_VERSION: 1.2.11
MBEDTLS_VERSION: 2.25.0
PCRE_VERSION: 8.44
PCRE_VERSION: 10.39
run: |
set -ex
brew uninstall [email protected] || echo
Expand All @@ -395,9 +395,9 @@ jobs:
curl -L https://github.com/ARMmbed/mbedtls/archive/v$MBEDTLS_VERSION.tar.gz | tar xz
cd mbedtls-$MBEDTLS_VERSION
make && make install
curl -L https://ftp.pcre.org/pub/pcre/pcre-$PCRE_VERSION.tar.gz | tar xz
cd pcre-$PCRE_VERSION
./configure --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
curl -L https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-$PCRE_VERSION.tar.gz | tar xz
cd pcre2-$PCRE_VERSION
./configure --enable-utf8 --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
make && make install

Expand Down
15 changes: 15 additions & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
2021-03-06 4.2.5:

New features:

php : support PHP attributes generation (#9964)

Bugfixes:

all : fixed compiler crash in complex constraints chains (#10445)
all : fixed timers execution order for timers with small time delta (#10567)
js : fixed constructors with rest arguments when compiling for ES3, ES5 (#10490)
php : excluded E_DEPRECATED notices from error reporting (#10502)
php : fixed safe casts to native arrays (#10576)
nullsafety : fixed false error on extern var fields without initialization (#10448)

2021-10-22 4.2.4:

New features:
Expand Down
Empty file modified extra/clean-whitespace
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions extra/github-actions/build-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
env:
ZLIB_VERSION: 1.2.11
MBEDTLS_VERSION: 2.25.0
PCRE_VERSION: 8.44
PCRE_VERSION: 10.39
run: |
set -ex
brew uninstall [email protected] || echo
Expand All @@ -22,9 +22,9 @@
curl -L https://github.com/ARMmbed/mbedtls/archive/v$MBEDTLS_VERSION.tar.gz | tar xz
cd mbedtls-$MBEDTLS_VERSION
make && make install
curl -L https://ftp.pcre.org/pub/pcre/pcre-$PCRE_VERSION.tar.gz | tar xz
cd pcre-$PCRE_VERSION
./configure --enable-utf8 --enable-pcre8 --enable-pcre16 --enable-pcre32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
curl -L https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.39/pcre2-$PCRE_VERSION.tar.gz | tar xz
cd pcre2-$PCRE_VERSION
./configure --enable-utf8 --enable-pcre2-8 --enable-pcre2-16 --enable-pcre2-32 --enable-unicode-properties --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-jit
make && make install
Expand Down
Empty file modified extra/haxelib_src/package.hxml
100644 → 100755
Empty file.
7 changes: 7 additions & 0 deletions src-json/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,13 @@
"targets": ["TAnyField"],
"platforms": ["eval"]
},
{
"name": "PhpAttribute",
"metadata": ":php.attribute",
"doc": "Adds a PHP attribute to the annotated symbol. Meta argument expects a string constant. E.g. `@:php.attribute('\\\\my\\\\Attr(123)')` will be generated as `#[\\my\\Attr(123)]` in the compiled php file.",
"platforms": ["php"],
"links": ["https://www.php.net/manual/en/language.attributes.overview.php"]
},
{
"name": "PhpGlobal",
"metadata": ":phpGlobal",
Expand Down
2 changes: 1 addition & 1 deletion src/core/globals.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type platform =
| Hl
| Eval

let version = 4204
let version = 4205
let version_major = version / 1000
let version_minor = (version mod 1000) / 100
let version_revision = (version mod 100)
Expand Down
2 changes: 1 addition & 1 deletion src/core/tUnification.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module Monomorph = struct
let add_up_constraint m ((t,name) as constr) =
m.tm_up_constraints <- constr :: m.tm_up_constraints;
match t with
| TMono m2 -> m2.tm_down_constraints <- MMono (m2,name) :: m2.tm_down_constraints
| TMono m2 -> m2.tm_down_constraints <- MMono (m,name) :: m2.tm_down_constraints
| _ -> ()

let add_down_constraint m constr =
Expand Down
59 changes: 40 additions & 19 deletions src/generators/genjs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -424,22 +424,35 @@ let is_code_injection_function e =
let var ctx =
if ctx.es_version >= 6 then "let" else "var"

let rec gen_call ctx e el in_value =
let apply,el =
if ctx.es_version < 6 then
match List.rev el with
| [{ eexpr = TUnop (Spread,Ast.Prefix,rest) }] ->
true,[rest]
| { eexpr = TUnop (Spread,Ast.Prefix,rest) } :: args_rev ->
(* [arg1, arg2, ..., argN].concat(rest) *)
let arr = mk (TArrayDecl (List.rev args_rev)) t_dynamic null_pos in
let concat = mk (TField (arr, FDynamic "concat")) t_dynamic null_pos in
true,[mk (TCall (concat, [rest])) t_dynamic null_pos]
| _ ->
false,el
else
(**
Returns `(needs_apply,element_list)` tuple where `needs_apply` indicates if
a call should be generated as `<function>.apply(<this>, element_list)` instead
of `<function>(el)`.
If `add_null_context` is provided then `element_list` will have `null` as the
first expr if needed.
*)
let apply_args ?(add_null_context=false) ctx el =
if ctx.es_version < 6 then
match List.rev el with
| [{ eexpr = TUnop (Spread,Ast.Prefix,rest) }] when not add_null_context ->
true,[rest]
| { eexpr = TUnop (Spread,Ast.Prefix,rest) } :: args_rev ->
(* [arg1, arg2, ..., argN].concat(rest) *)
let args =
if add_null_context then (null t_dynamic null_pos) :: List.rev args_rev
else List.rev args_rev
in
let arr = mk (TArrayDecl args) t_dynamic null_pos in
let concat = mk (TField (arr, FDynamic "concat")) t_dynamic null_pos in
true,[mk (TCall (concat, [rest])) t_dynamic null_pos]
| _ ->
false,el
in
else
false,el

let rec gen_call ctx e el in_value =
let apply,el = apply_args ctx el in
match e.eexpr , el with
| TConst TSuper , params when ctx.es_version < 6 ->
(match ctx.current.cl_super with
Expand Down Expand Up @@ -758,12 +771,20 @@ and gen_expr ctx e =
| TNew ({ cl_path = [],"Array" },_,[]) ->
print ctx "[]"
| TNew (c,_,el) ->
let apply,el = apply_args ~add_null_context:true ctx el in
(match c.cl_constructor with
| Some cf when Meta.has Meta.SelfCall cf.cf_meta -> ()
| _ -> print ctx "new ");
print ctx "%s(" (ctx.type_accessor (TClassDecl c));
concat ctx "," (gen_value ctx) el;
spr ctx ")"
| _ -> print ctx (if apply then "(new" else "new "));
let cls = ctx.type_accessor (TClassDecl c) in
if apply then begin
print ctx "(Function.prototype.bind.apply(%s," cls;
concat ctx "," (gen_value ctx) el;
print ctx ")))"
end else begin
print ctx "%s(" cls;
concat ctx "," (gen_value ctx) el;
spr ctx ")"
end;
| TIf (cond,e,eelse) ->
spr ctx "if";
gen_value ctx cond;
Expand Down
50 changes: 40 additions & 10 deletions src/generators/genphp7.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1416,6 +1416,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
| TAbstract ({ a_path = ["php"],"NativeIndexedArray" }, [param]) -> (self#use_t param) ^ "[]"
| _ -> "array"
)
| (["php"],"NativeArray") -> "array"
| _ when Meta.has Meta.CoreType abstr.a_meta -> "mixed"
| _ -> self#use_t abstr.a_this
(**
Expand Down Expand Up @@ -2072,6 +2073,7 @@ class code_writer (ctx:php_generator_context) hx_type_path php_name =
| "float" -> "'Float'"
| "bool" -> "'Bool'"
| "string" -> "'String'"
| "array" -> "'array'"
| "mixed" -> "'Dynamic'"
| "Enum" -> "'Enum'"
| "Class" -> "'Class'"
Expand Down Expand Up @@ -3100,10 +3102,10 @@ class virtual type_builder ctx (wrapper:type_wrapper) =
writer#write_line ("namespace " ^ (String.concat "\\" namespace) ^ ";\n");
writer#write_use
(**
Generates PHP docblock to output buffer.
Generates PHP docblock and attributes to output buffer.
*)
method private write_doc doc_block =
match doc_block with
method private write_doc doc_block meta =
(match doc_block with
| DocVar (type_name, doc) ->
writer#write_line "/**";
writer#write_line (" * @var " ^ type_name);
Expand All @@ -3122,6 +3124,8 @@ class virtual type_builder ctx (wrapper:type_wrapper) =
)
| DocMethod (args, return, doc) ->
self#write_method_docblock args return doc
);
self#write_attributes meta;
(**
Writes description section of docblocks
*)
Expand Down Expand Up @@ -3297,6 +3301,32 @@ class virtual type_builder ctx (wrapper:type_wrapper) =
end
else
false
(**
Generates PHP attributes to output buffer based on `@:php.attribute` metas.
*)
method private write_attributes meta =
let rec traverse found meta =
match meta with
| [] -> ()
| (m,el,p) :: rest ->
let found =
if m == PhpAttribute then begin
writer#write_indentation;
writer#write "#[";
(match el with
| [EConst (String (s,_)),p] ->
writer#write s
| _ ->
ctx.pgc_common.error ("@:php.attribute meta expects a single string constant as an argument.") p
);
writer#write "]\n";
true
end else
found
in
traverse found rest
in
traverse false meta
(**
Set sourcemap generator
*)
Expand All @@ -3318,7 +3348,7 @@ class enum_builder ctx (enm:tenum) =
E.g. "class SomeClass extends Another implements IFace"
*)
method private write_declaration =
self#write_doc (DocClass (gen_doc_text_opt enm.e_doc));
self#write_doc (DocClass (gen_doc_text_opt enm.e_doc)) enm.e_meta;
writer#write ("class " ^ self#get_name ^ " extends " ^ (writer#use hxenum_type_path))
(**
Writes type body to output buffer.
Expand Down Expand Up @@ -3347,7 +3377,7 @@ class enum_builder ctx (enm:tenum) =
| _ -> fail field.ef_pos __LOC__
in
writer#indent 1;
self#write_doc (DocMethod (args, TEnum (enm, []), (gen_doc_text_opt field.ef_doc)));
self#write_doc (DocMethod (args, TEnum (enm, []), (gen_doc_text_opt field.ef_doc))) field.ef_meta;
writer#write_with_indentation ("static public function " ^ name ^ " (");
write_args writer#write (writer#write_arg true) (fix_tsignature_args args);
writer#write ") {\n";
Expand Down Expand Up @@ -3538,7 +3568,7 @@ class class_builder ctx (cls:tclass) =
E.g. "class SomeClass extends Another implements IFace"
*)
method private write_declaration =
self#write_doc (DocClass (gen_doc_text_opt cls.cl_doc));
self#write_doc (DocClass (gen_doc_text_opt cls.cl_doc)) cls.cl_meta;
if self#is_final then writer#write "final ";
if has_class_flag cls CAbstract then writer#write "abstract ";
writer#write (if (has_class_flag cls CInterface) then "interface " else "class ");
Expand Down Expand Up @@ -3772,7 +3802,7 @@ class class_builder ctx (cls:tclass) =
*)
method private write_var field is_static =
writer#indent 1;
self#write_doc (DocVar (writer#use_t ~for_doc:true field.cf_type, (gen_doc_text_opt field.cf_doc)));
self#write_doc (DocVar (writer#use_t ~for_doc:true field.cf_type, (gen_doc_text_opt field.cf_doc))) field.cf_meta;
writer#write_indentation;
if is_static then writer#write "static ";
let visibility = get_visibility field.cf_meta in
Expand All @@ -3799,7 +3829,7 @@ class class_builder ctx (cls:tclass) =
| Some expr when not (is_constant expr) -> ()
| Some expr ->
writer#indent 1;
self#write_doc (DocVar (writer#use_t field.cf_type, (gen_doc_text_opt field.cf_doc)));
self#write_doc (DocVar (writer#use_t field.cf_type, (gen_doc_text_opt field.cf_doc))) field.cf_meta;
writer#write_with_indentation ("const " ^ (field_name field) ^ " = ");
writer#write_expr expr;
writer#write ";\n"
Expand All @@ -3812,7 +3842,7 @@ class class_builder ctx (cls:tclass) =
writer#indent 1;
let (args, return_type) = get_function_signature field in
List.iter (fun (arg_name, _, _) -> writer#declared_local_var arg_name) args;
self#write_doc (DocMethod (args, return_type, (gen_doc_text_opt field.cf_doc)));
self#write_doc (DocMethod (args, return_type, (gen_doc_text_opt field.cf_doc))) field.cf_meta;
writer#write_indentation;
if self#is_final_field field then writer#write "final ";
if has_class_field_flag field CfAbstract then writer#write "abstract ";
Expand All @@ -3839,7 +3869,7 @@ class class_builder ctx (cls:tclass) =
writer#indent 1;
let (args, return_type) = get_function_signature field in
List.iter (fun (arg_name, _, _) -> writer#declared_local_var arg_name) args;
self#write_doc (DocMethod (args, return_type, (gen_doc_text_opt field.cf_doc)));
self#write_doc (DocMethod (args, return_type, (gen_doc_text_opt field.cf_doc))) field.cf_meta;
writer#write_with_indentation ((get_visibility field.cf_meta) ^ " function " ^ (field_name field));
(match field.cf_expr with
| None -> (* interface *)
Expand Down
3 changes: 2 additions & 1 deletion src/typing/nullSafety.ml
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ let rec validate_safety_meta report (metadata:Ast.metadata) =
Check if specified `field` represents a `var` field which will exist at runtime.
*)
let should_be_initialized field =
match field.cf_kind with
not (has_class_field_flag field CfExtern)
&& match field.cf_kind with
| Var { v_read = AccNormal | AccInline | AccNo } | Var { v_write = AccNormal | AccNo } -> true
| Var _ -> Meta.has Meta.IsVar field.cf_meta
| _ -> false
Expand Down
4 changes: 2 additions & 2 deletions std/php/Boot.hx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Boot {
static function __init__() {
Global.mb_internal_encoding('UTF-8');
if (!Global.defined('HAXE_CUSTOM_ERROR_HANDLER') || !Const.HAXE_CUSTOM_ERROR_HANDLER) {
var previousLevel = Global.error_reporting(Const.E_ALL);
var previousLevel = Global.error_reporting(Const.E_ALL & ~Const.E_DEPRECATED);
var previousHandler = Global.set_error_handler(function(errno:Int, errstr:String, errfile:String, errline:Int) {
if (Global.error_reporting() & errno == 0) {
return false;
Expand Down Expand Up @@ -339,7 +339,7 @@ class Boot {
if (value.is_string()) {
return value;
}
case 'php\\NativeArray':
case 'array':
if (value.is_array()) {
return value;
}
Expand Down
2 changes: 2 additions & 0 deletions std/php/Syntax.hx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ extern class Syntax {
[$arg1, $arg2, $arg3]
```
**/
@:pure
static function arrayDecl<T>(args:Rest<T>):NativeIndexedArray<T>;

/**
Expand All @@ -303,6 +304,7 @@ extern class Syntax {
That means you can't pass an object stored in a variable to this method like `Syntax.assocDecl(someVar)`.
Use `php.Lib.associativeArrayOfObject(someVar)` instead.
**/
@:pure
static function assocDecl<T:{}>(?arg:T):NativeAssocArray<Dynamic>;

/**
Expand Down
Loading

0 comments on commit 63003f7

Please sign in to comment.