Skip to content

Commit ef6fe96

Browse files
committed
Merge branch 'development' into cpp_typed_funcs
2 parents d9e0cfa + 98b4326 commit ef6fe96

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1301
-309
lines changed

.github/workflows/main.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105

106106

107107
linux-build:
108-
runs-on: ubuntu-20.04
108+
runs-on: ubuntu-22.04
109109
env:
110110
PLATFORM: linux64
111111
OPAMYES: 1
@@ -123,7 +123,7 @@ jobs:
123123
uses: actions/cache@v4
124124
with:
125125
path: ~/.opam/
126-
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}
126+
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}-1
127127

128128
- name: Install Neko from S3
129129
run: |
@@ -148,10 +148,10 @@ jobs:
148148
- name: Install dependencies
149149
run: |
150150
set -ex
151-
sudo add-apt-repository ppa:avsm/ppa -y # provides OPAM 2
152-
sudo add-apt-repository ppa:haxe/ocaml -y # provides newer version of mbedtls
153151
sudo apt-get update -qqy
154-
sudo apt-get install -qqy ocaml-nox opam libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
152+
sudo apt-get install -qqy darcs bubblewrap ocaml-nox libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
153+
curl -sSL https://github.com/ocaml/opam/releases/download/2.3.0/opam-2.3.0-x86_64-linux -o $RUNNER_TEMP/opam
154+
sudo install $RUNNER_TEMP/opam /usr/local/bin/opam
155155
156156
- name: Install OCaml libraries
157157
if: steps.cache-opam.outputs.cache-hit != 'true'
@@ -213,7 +213,7 @@ jobs:
213213

214214
linux-test:
215215
needs: linux-build
216-
runs-on: ubuntu-20.04
216+
runs-on: ubuntu-22.04
217217
env:
218218
PLATFORM: linux64
219219
TEST: ${{matrix.target}}
@@ -300,7 +300,7 @@ jobs:
300300

301301
test-docgen:
302302
needs: linux-build
303-
runs-on: ubuntu-20.04
303+
runs-on: ubuntu-22.04
304304
env:
305305
PLATFORM: linux64
306306
HXCPP_COMPILE_CACHE: ~/hxcache
@@ -854,7 +854,7 @@ jobs:
854854
deploy:
855855
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
856856
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
857-
runs-on: ubuntu-20.04
857+
runs-on: ubuntu-22.04
858858
steps:
859859
# this is only needed for to get `COMMIT_DATE`...
860860
# maybe https://github.community/t/expose-commit-timestamp-in-the-github-context-data/16460/3
@@ -924,7 +924,7 @@ jobs:
924924
deploy_apidoc:
925925
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
926926
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
927-
runs-on: ubuntu-20.04
927+
runs-on: ubuntu-22.04
928928
steps:
929929
- name: Install dependencies
930930
run: |

Makefile

+2-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ NEKO_VERSION_TAG=v$(shell echo "$(NEKO_VERSION)" | sed "s/\./-/g")
6666
all: haxe tools
6767

6868
haxe:
69-
dune build --profile release src/haxe.exe
70-
cp -f _build/default/src/haxe.exe ./"$(HAXE_OUTPUT)"
69+
dune build --profile release
7170

7271
plugin: haxe
7372
$(DUNE_COMMAND) build --profile release plugins/$(PLUGIN)/$(PLUGIN).cmxs
@@ -234,7 +233,7 @@ package_installer_mac: $(INSTALLER_TMP_DIR)/neko-osx.tar.gz package_unix
234233
clean: clean_haxe clean_tools clean_package
235234

236235
clean_haxe:
237-
rm -f -r _build $(HAXE_OUTPUT) $(PREBUILD_OUTPUT)
236+
dune clean
238237

239238
clean_tools:
240239
rm -f $(HAXE_OUTPUT) $(PREBUILD_OUTPUT) $(HAXELIB_OUTPUT)

WinSetup.ps1

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Usage:
2+
# - install Git
3+
# - install Neko
4+
# - checkout haxe git
5+
# - run from command "powershell -noexit -ExecutionPolicy Bypass -File .\WinSetup.ps1"
6+
17
function Cmd-Path($file) {
28
try { Split-Path -Parent (Get-Command "$file.exe" -ErrorAction Stop).Source } catch { "" }
39
}

dune

+7
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
(dirs src libs)
22
(data_only_dirs src-json)
3+
4+
(rule
5+
(action
6+
(copy src/haxe.exe haxe%{ext_exe}))
7+
(mode
8+
(promote (until-clean)))
9+
(alias default))

extra/github-actions/workflows/main.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
@import build-windows.yml
2525

2626
linux-build:
27-
runs-on: ubuntu-20.04
27+
runs-on: ubuntu-22.04
2828
env:
2929
PLATFORM: linux64
3030
OPAMYES: 1
@@ -42,17 +42,17 @@ jobs:
4242
uses: actions/cache@v4
4343
with:
4444
path: ~/.opam/
45-
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}
45+
key: ${{ runner.os }}-${{ matrix.ocaml }}-${{ hashFiles('./haxe.opam', './libs/') }}-1
4646

4747
@import install-neko-unix.yml
4848

4949
- name: Install dependencies
5050
run: |
5151
set -ex
52-
sudo add-apt-repository ppa:avsm/ppa -y # provides OPAM 2
53-
sudo add-apt-repository ppa:haxe/ocaml -y # provides newer version of mbedtls
5452
sudo apt-get update -qqy
55-
sudo apt-get install -qqy ocaml-nox opam libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
53+
sudo apt-get install -qqy darcs bubblewrap ocaml-nox libpcre2-dev zlib1g-dev libgtk2.0-dev libmbedtls-dev ninja-build
54+
curl -sSL https://github.com/ocaml/opam/releases/download/2.3.0/opam-2.3.0-x86_64-linux -o $RUNNER_TEMP/opam
55+
sudo install $RUNNER_TEMP/opam /usr/local/bin/opam
5656
5757
- name: Install OCaml libraries
5858
if: steps.cache-opam.outputs.cache-hit != 'true'
@@ -114,7 +114,7 @@ jobs:
114114

115115
linux-test:
116116
needs: linux-build
117-
runs-on: ubuntu-20.04
117+
runs-on: ubuntu-22.04
118118
env:
119119
PLATFORM: linux64
120120
TEST: ${{matrix.target}}
@@ -183,7 +183,7 @@ jobs:
183183

184184
test-docgen:
185185
needs: linux-build
186-
runs-on: ubuntu-20.04
186+
runs-on: ubuntu-22.04
187187
env:
188188
PLATFORM: linux64
189189
HXCPP_COMPILE_CACHE: ~/hxcache
@@ -478,7 +478,7 @@ jobs:
478478
deploy:
479479
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
480480
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
481-
runs-on: ubuntu-20.04
481+
runs-on: ubuntu-22.04
482482
steps:
483483
# this is only needed for to get `COMMIT_DATE`...
484484
# maybe https://github.community/t/expose-commit-timestamp-in-the-github-context-data/16460/3
@@ -548,7 +548,7 @@ jobs:
548548
deploy_apidoc:
549549
if: success() && github.repository_owner == 'HaxeFoundation' && github.event_name != 'pull_request'
550550
needs: [linux-test, linux-arm64-test, mac-test, windows64-test]
551-
runs-on: ubuntu-20.04
551+
runs-on: ubuntu-22.04
552552
steps:
553553
- name: Install dependencies
554554
run: |

src-json/define.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@
554554
{
555555
"name": "NoDeprecationWarnings",
556556
"define": "no-deprecation-warnings",
557-
"doc": "Do not warn if fields annotated with `@:deprecated` are used."
557+
"doc": "Do not warn if fields annotated with `@:deprecated` are used.",
558+
"deprecated": "Use -w to configure warnings. See https://haxe.org/manual/cr-warnings.html for more information."
558559
},
559560
{
560561
"name": "NoFlashOverride",
@@ -791,7 +792,8 @@
791792
{
792793
"name": "WarnVarShadowing",
793794
"define": "warn-var-shadowing",
794-
"doc": "Warn about shadowing variable declarations."
795+
"doc": "Warn about shadowing variable declarations.",
796+
"deprecated": "Use -w to configure warnings. See https://haxe.org/manual/cr-warnings.html for more information."
795797
},
796798
{
797799
"name": "NoTre",

src-json/warning.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
{
7777
"name": "WVarShadow",
7878
"doc": "A local variable hides another by using the same name",
79-
"parent": "WTyper"
79+
"parent": "WTyper",
80+
"enabled": false
8081
},
8182
{
8283
"name": "WExternWithExpr",

src/compiler/args.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let process_args arg_spec =
4343
let parse_args com =
4444
let usage = Printf.sprintf
4545
"Haxe Compiler %s - (C)2005-2024 Haxe Foundation\nUsage: haxe%s <target> [options] [hxml files and dot paths...]\n"
46-
s_version_full (if Sys.os_type = "Win32" then ".exe" else "")
46+
(s_version_full com.version) (if Sys.os_type = "Win32" then ".exe" else "")
4747
in
4848
let actx = {
4949
classes = [([],"Std")];
@@ -154,7 +154,7 @@ let parse_args com =
154154
com.debug <- true;
155155
),"","add debug information to the compiled code");
156156
("Miscellaneous",["--version"],["-version"],Arg.Unit (fun() ->
157-
raise (Helper.HelpMessage s_version_full);
157+
raise (Helper.HelpMessage (s_version_full com.version));
158158
),"","print version and exit");
159159
("Miscellaneous", ["-h";"--help"], ["-help"], Arg.Unit (fun () ->
160160
raise (Arg.Help "")

src/compiler/compilationCache.ml

+15-3
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,27 @@ class cache = object(self)
234234
) cc#get_modules acc
235235
) contexts []
236236

237+
method taint_module m_path reason =
238+
Hashtbl.iter (fun _ cc ->
239+
Hashtbl.iter (fun _ m ->
240+
if m.m_path = m_path then m.m_extra.m_cache_state <- MSBad (Tainted reason)
241+
) cc#get_modules;
242+
Hashtbl.iter (fun _ mc ->
243+
if mc.HxbData.mc_path = m_path then
244+
mc.HxbData.mc_extra.m_cache_state <- match reason, mc.mc_extra.m_cache_state with
245+
| CheckDisplayFile, (MSBad _ as state) -> state
246+
| _ -> MSBad (Tainted reason)
247+
) cc#get_hxb
248+
) contexts
249+
237250
method taint_modules file_key reason =
238251
Hashtbl.iter (fun _ cc ->
239252
Hashtbl.iter (fun _ m ->
240253
if Path.UniqueKey.lazy_key m.m_extra.m_file = file_key then m.m_extra.m_cache_state <- MSBad (Tainted reason)
241254
) cc#get_modules;
242-
let open HxbData in
243255
Hashtbl.iter (fun _ mc ->
244-
if Path.UniqueKey.lazy_key mc.mc_extra.m_file = file_key then
245-
mc.mc_extra.m_cache_state <- match reason, mc.mc_extra.m_cache_state with
256+
if Path.UniqueKey.lazy_key mc.HxbData.mc_extra.m_file = file_key then
257+
mc.HxbData.mc_extra.m_cache_state <- match reason, mc.HxbData.mc_extra.m_cache_state with
246258
| CheckDisplayFile, (MSBad _ as state) -> state
247259
| _ -> MSBad (Tainted reason)
248260
) cc#get_hxb

src/compiler/compiler.ml

+24-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ module Setup = struct
230230
let setup_common_context ctx =
231231
let com = ctx.com in
232232
ctx.com.print <- ctx.comm.write_out;
233-
Common.define_value com Define.HaxeVer (Printf.sprintf "%.3f" (float_of_int Globals.version /. 1000.));
233+
Common.define_value com Define.HaxeVer (Printf.sprintf "%.3f" (float_of_int version /. 1000.));
234234
Common.raw_define com "haxe3";
235235
Common.raw_define com "haxe4";
236236
Common.raw_define com "haxe5";
@@ -296,6 +296,7 @@ let do_type ctx mctx actx display_file_dot_path =
296296
Some (MacroContext.call_init_macro ctx.com mctx path)
297297
) mctx (List.rev actx.config_macros) in
298298
enter_stage com CInitMacrosDone;
299+
update_platform_config com; (* make sure to adapt all flags changes defined during init macros *)
299300
ServerMessage.compiler_stage com;
300301

301302
let macros = match mctx with None -> None | Some mctx -> mctx.g.macros in
@@ -309,7 +310,10 @@ let do_type ctx mctx actx display_file_dot_path =
309310
com.callbacks#run com.error_ext com.callbacks#get_after_init_macros;
310311
run_or_diagnose ctx (fun () ->
311312
if com.display.dms_kind <> DMNone then DisplayTexpr.check_display_file tctx cs;
312-
List.iter (fun cpath -> ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos)) (List.rev actx.classes);
313+
List.iter (fun cpath ->
314+
ignore(tctx.Typecore.g.Typecore.do_load_module tctx cpath null_pos);
315+
Typecore.flush_pass tctx.g PBuildClass "actx.classes"
316+
) (List.rev actx.classes);
313317
Finalization.finalize tctx;
314318
);
315319
end with TypeloadParse.DisplayInMacroBlock ->
@@ -418,6 +422,10 @@ let compile ctx actx callbacks =
418422
) (List.rev actx.cmds)
419423
end
420424

425+
let make_ice_message com msg backtrace =
426+
let ver = (s_version_full com.version) in
427+
let os_type = if Sys.unix then "unix" else "windows" in
428+
Printf.sprintf "%s\nHaxe: %s; OS type: %s;\n%s" msg ver os_type backtrace
421429
let compile_safe ctx f =
422430
let com = ctx.com in
423431
try
@@ -445,6 +453,12 @@ with
445453
handle_diagnostics ctx msg null_pos DKCompilerMessage;
446454
| Failure msg when not Helper.is_debug_run ->
447455
error ctx ("Error: " ^ msg) null_pos
456+
| Globals.Ice (msg,backtrace) when is_diagnostics com ->
457+
let s = make_ice_message com msg backtrace in
458+
handle_diagnostics ctx s null_pos DKCompilerMessage
459+
| Globals.Ice (msg,backtrace) when not Helper.is_debug_run ->
460+
let s = make_ice_message com msg backtrace in
461+
error ctx ("Error: " ^ s) null_pos
448462
| Helper.HelpMessage msg ->
449463
print_endline msg
450464
| Parser.TypePath (p,c,is_import,pos) ->
@@ -516,7 +530,14 @@ let compile_ctx callbacks ctx =
516530
catch_completion_and_exit ctx callbacks run
517531

518532
let create_context comm cs compilation_step params = {
519-
com = Common.create compilation_step cs version params (DisplayTypes.DisplayMode.create !Parser.display_mode);
533+
com = Common.create compilation_step cs {
534+
version = version;
535+
major = version_major;
536+
minor = version_minor;
537+
revision = version_revision;
538+
pre = version_pre;
539+
extra = Version.version_extra;
540+
} params (DisplayTypes.DisplayMode.create !Parser.display_mode);
520541
messages = [];
521542
has_next = false;
522543
has_error = false;

src/compiler/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(rule
2-
(deps (env_var ADD_REVISION))
2+
(deps (env_var ADD_REVISION) (universe))
33
(targets version.ml)
44
(action (with-stdout-to version.ml (run ../prebuild.exe version)))
55
)

src/compiler/hxb/hxbReader.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,7 @@ class hxb_reader
15891589
a.a_read <- self#read_option (fun () -> self#read_field_ref);
15901590
a.a_write <- self#read_option (fun () -> self#read_field_ref);
15911591
a.a_call <- self#read_option (fun () -> self#read_field_ref);
1592+
a.a_constructor <- self#read_option (fun () -> self#read_field_ref);
15921593

15931594
a.a_ops <- self#read_list (fun () ->
15941595
let i = read_byte ch in
@@ -2078,8 +2079,7 @@ class hxb_reader
20782079
^ "Attach the following information:"
20792080
in
20802081
let backtrace = Printexc.raw_backtrace_to_string backtrace in
2081-
let s = Printf.sprintf "%s\nHaxe: %s\n%s" msg s_version_full backtrace in
2082-
failwith s
2082+
raise (Globals.Ice (msg, backtrace))
20832083

20842084
method private read_chunk_data kind =
20852085
let path = String.concat "_" (ExtLib.String.nsplit (s_type_path mpath) ".") in

src/compiler/hxb/hxbWriter.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,7 @@ module HxbWriter = struct
452452
^ "Attach the following information:"
453453
in
454454
let backtrace = Printexc.raw_backtrace_to_string backtrace in
455-
let s = Printf.sprintf "%s\nHaxe: %s\n%s" msg s_version_full backtrace in
456-
failwith s
455+
raise (Globals.Ice (msg, backtrace))
457456

458457
let in_nested_scope writer = match writer.field_stack with
459458
| [] -> false (* can happen for cl_init and in EXD *)
@@ -1918,6 +1917,7 @@ module HxbWriter = struct
19181917
Chunk.write_option writer.chunk a.a_read (write_field_ref writer c CfrStatic );
19191918
Chunk.write_option writer.chunk a.a_write (write_field_ref writer c CfrStatic);
19201919
Chunk.write_option writer.chunk a.a_call (write_field_ref writer c CfrStatic);
1920+
Chunk.write_option writer.chunk a.a_constructor (write_field_ref writer c CfrStatic);
19211921

19221922
Chunk.write_list writer.chunk a.a_ops (fun (op, cf) ->
19231923
Chunk.write_u8 writer.chunk (binop_index op);

src/context/common.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ type context = {
356356
is_macro_context : bool;
357357
mutable json_out : json_api option;
358358
(* config *)
359-
version : int;
359+
version : compiler_version;
360360
mutable args : string list;
361361
mutable display : DisplayTypes.DisplayMode.settings;
362362
mutable debug : bool;
@@ -968,7 +968,7 @@ let init_platform com =
968968
end;
969969
(* Set the source header, unless the user has set one already or the platform sets a custom one *)
970970
if not (defined com Define.SourceHeader) && (com.platform <> Hl) then
971-
define_value com Define.SourceHeader ("Generated by Haxe " ^ s_version_full);
971+
define_value com Define.SourceHeader ("Generated by Haxe " ^ (s_version_full com.version));
972972
let forbid acc p = if p = name || PMap.mem p acc then acc else PMap.add p Forbidden acc in
973973
com.package_rules <- List.fold_left forbid com.package_rules ("java" :: (List.map platform_name platforms));
974974
update_platform_config com;

0 commit comments

Comments
 (0)