Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source code clean-ups #1112

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
]
},
"ghul.test": {
"version": "1.3.2",
"version": "1.3.3",
"commands": [
"ghul-test"
]
},
"ghul.compiler": {
"version": "0.8.16",
"version": "0.8.17",
"commands": [
"ghul-compiler"
]
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.8.17-alpha.33</Version>
<Version>0.8.18-alpha.12</Version>
<NoWarn>$(NoWarn);NU1507</NoWarn>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<ItemGroup>
<!-- ghūl runtime -->
<PackageVersion Include="ghul.runtime" Version="1.3.2" />
<PackageVersion Include="ghul.runtime" Version="1.3.3" />

<!-- ghūl compiler dependencies -->
<PackageVersion Include="System.Reflection.MetadataLoadContext" Version="8.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion ghul.ghulproj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<!-- Build options -->
<PackageOutputPath>./nupkg</PackageOutputPath>
<GhulCompiler>dotnet ghul-compiler</GhulCompiler>
<GhulCompiler>dotnet ghul-compiler --show-analysis-stats</GhulCompiler>
<InvariantGlobalization>true</InvariantGlobalization>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/semantic/pull-down/err.expected
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ test.ghul: 38,23..38,33: error: member test_value not found in Test.DDDD
test.ghul: 49,9..49,13: error: duplicate method
test.ghul: 51,9..51,13: error: duplicate method
test.ghul: 76,11..76,15: error: Test.CCCC[Ghul.string].test_value: Ghul.string does not implement Test.P.test_value: Ghul.int due to different return type Ghul.string
test.ghul: 76,11..76,15: error: inherit multiple properties with the same name but different types Test.CCCC.test_value: Ghul.string, Test.P.test_value: Ghul.int
test.ghul: 76,11..76,15: error: cannot inherit multiple properties with the same name but different types Test.CCCC.test_value: Ghul.string, Test.P.test_value: Ghul.int
6 changes: 0 additions & 6 deletions integration-tests/template/.vscode/ghul.json

This file was deleted.

6 changes: 0 additions & 6 deletions project-tests/ambiguous-method-hiding-1/.vscode/ghul.json

This file was deleted.

6 changes: 0 additions & 6 deletions project-tests/runtime-pipes/.vscode/ghul.json

This file was deleted.

26 changes: 25 additions & 1 deletion project-tests/runtime-pipes/common.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Tests is
iv[T](index: int, value: T) -> INDEXED_VALUE[T] => new INDEXED_VALUE[T](index, value);

expect_equal[T](a: T, b: T) is
write_line("expect_equal: {{0}} == {{1}}", a, b);
write_line("expect_equal: {a} == {b}", a, b);
si

assert_are_equal[T](expected: Iterable[T], actual: Pipe[T]) is
Expand All @@ -23,4 +23,28 @@ namespace Tests is

CollectionAssert.are_equal(expected_elements, actual_elements);
si

assert_equal[T](a: Iterable[T], b: Iterable[T]) is
// FIXME: can no-longer construct LIST[T] from an Iterable[T]
// not sure if this is a change from .NET 6 to .NET 8 or if it's
// a compiler bug:

let la: Collections.LIST[T] = new Collections.LIST[T]();
let lb: Collections.LIST[T] = new Collections.LIST[T]();

la.add_range(a);
lb.add_range(b);

CollectionAssert.are_equal(la, lb);
si

collect[T](iterator: LIST_REVERSE_ITERATOR[T]) -> Iterable[T] is
let result = new LIST[T]();

while iterator.move_next() do
result.add(iterator.current);
od

return result;
si
si
2 changes: 1 addition & 1 deletion project-tests/runtime-pipes/run.expected
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ run test: PipeOperatorShould.Pipe_SkipThenFilter_ReturnsFilteredTailSequence
finished: PipeOperatorShould.Pipe_SkipThenFilter_ReturnsFilteredTailSequence

run test: PipeOperatorShould.Pipe_SkipThenFirst_ReturnsCorrectElement
expect_equal: Ghul.MAYBE[System.Int32] == Ghul.MAYBE[System.Int32]
expect_equal: 6 == 6
finished: PipeOperatorShould.Pipe_SkipThenFirst_ReturnsCorrectElement

run test: PipeOperatorShould.Pipe_SkipThenIndex_StartsIndexingFromZero
Expand Down
31 changes: 0 additions & 31 deletions project-tests/runtime-pipes/tests.ghul

This file was deleted.

6 changes: 0 additions & 6 deletions project-tests/runtime-ranges/.vscode/ghul.json

This file was deleted.

6 changes: 3 additions & 3 deletions src/analysis/analyser.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ namespace Analysis is

_command_map = new Collections.MAP[string,CommandHandler]();

_despatcher = new COMMAND_DESPATCHER(reader, writer, _timers, _log, watchdog);
_despatcher = new COMMAND_DESPATCHER(reader, writer, _timers, _log, watchdog, build_flags.want_analysis_stats);

build_flags.want_compile_up_to_expressions = true;

let file_edited_handler = new FILE_EDITED_HANDLER(watchdog, timers, compiler, build_flags, library_files, symbol_table);

let full_compile_handler = new FULL_COMPILE_HANDLER(watchdog, timers, compiler, file_edited_handler, build_flags);
let compile_handler = new COMPILE_HANDLER(watchdog, timers, compiler, file_edited_handler, build_flags);

let full_compiler: FULL_COMPILER = new FULL_COMPILER(watchdog, compiler, file_edited_handler, timers);

Expand All @@ -75,7 +75,7 @@ namespace Analysis is
);

_despatcher.add_handler(
"COMPILE", full_compile_handler
"COMPILE", compile_handler
);

_despatcher.add_handler(
Expand Down
22 changes: 16 additions & 6 deletions src/analysis/command_despatcher.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace Analysis is
_reader: IO.TextReader;
_writer: IO.TextWriter;
_command_map: Collections.MAP[string,CommandHandler];
_want_stats_report: bool;
_last_report_time: System.DateTime;

_listening: bool;

Expand All @@ -26,13 +28,16 @@ namespace Analysis is
writer: IO.TextWriter,
timers: TIMERS,
log: IO.TextWriter,
watchdog: WATCHDOG
watchdog: WATCHDOG,
want_stats_report: bool
) is
_reader = reader;
_writer = writer;
_timers = timers;
_log = log;
_watchdog = watchdog;
_want_stats_report = want_stats_report;
_last_report_time = System.DateTime.now;

_command_map = new Collections.MAP[string,CommandHandler]();
si
Expand Down Expand Up @@ -65,16 +70,21 @@ namespace Analysis is
let timer_name = command.to_lower_invariant();

_timers.start(timer_name);

handler.handle(_reader, _writer);

_timers.finish(timer_name);

@IF.not.release()
_log.write_line(_timers[timer_name]);

_watchdog.increment(_writer);

if _want_stats_report then
let elapsed_since_last_report = System.DateTime.now.subtract(_last_report_time);

if elapsed_since_last_report.total_seconds > 60.0D then
_last_report_time = System.DateTime.now;

_log.write(_timers);
fi
fi

return true;
else
_log.write_line("ghūl: no handler found for command: '{command}' in {_command_map}");
Expand Down
18 changes: 13 additions & 5 deletions src/analysis/command_handlers.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,6 @@ namespace Analysis is
writer.flush();

_timers.finish("compile-all");
@IF.not.release()
IO.Std.error.write_line(_timers["compile-all"]);
yrt
si
si
Expand Down Expand Up @@ -326,6 +324,12 @@ namespace Analysis is
paths.add(path);
od

let want_timer = paths.count == 1 /\ !_library_files?;

if want_timer then
_timers.start("edit-single");
fi

if _library_files? then
for library_file_path in _library_files do
parse_and_add_file(library_file_path, writer, IO.File.open_text(library_file_path), true);
Expand Down Expand Up @@ -372,17 +376,21 @@ namespace Analysis is

IoC.CONTAINER.instance.logger.end_analysis();

if want_timer then
_timers.finish("edit-single");
fi

writer.write("{cast char(12)}");
writer.write_line("PARTIAL DONE");
writer.write_line(_timers.edit_timer.max_average_milliseconds);
writer.write_line(_timers.edit_single_timer.max_average_milliseconds);
writer.write("{cast char(12)}");
writer.flush();
yrt
si
si

// This does a full compile of all files
class FULL_COMPILE_HANDLER: CommandHandler is
class COMPILE_HANDLER: CommandHandler is
_watchdog: WATCHDOG;
_compiler: COMPILER;
_timers: TIMERS;
Expand Down Expand Up @@ -444,7 +452,7 @@ namespace Analysis is

writer.write("{cast char(12)}");
writer.write_line("FULL DONE");
writer.write_line(_timers.full_compile_timer.max_average_milliseconds);
writer.write_line(_timers.compile_timer.max_average_milliseconds);
writer.write("{cast char(12)}");
writer.flush();
yrt
Expand Down
1 change: 1 addition & 0 deletions src/compiler/build_flags.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Compiler is
want_assembler: bool public;
want_keep_out_il: bool public;
want_library_boilerplate: bool public;
want_analysis_stats: bool public;
ignore_errors: bool public;
exclude_runtime_symbols: bool public;
is_test_run: bool public;
Expand Down
11 changes: 2 additions & 9 deletions src/driver/main.ghul
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ namespace Driver is
flags.want_keep_out_il = true;
elif s =~ "--emit-boilerplate-il" then
emit_boilerplate_il_path = get_next_argument(args_iterator);
elif s =~ "--show-analysis-stats" then
flags.want_analysis_stats = true;
elif s.starts_with('-') then
Std.error.write_line("warning: ignoring unknown option: {s}");
elif SOURCE_FILE_CATEGORIZER.is_ghul(s) then
Expand Down Expand Up @@ -385,17 +387,8 @@ namespace Driver is
ilasm_args = "{ilasm_args} -debug -pdbfmt=portable";
fi

@IF.not.release()
container.timers.start("il-asm");

let ilasm = System.Diagnostics.Process.start(ilasm_path, ilasm_args);

@IF.not.release()
container.timers.finish("il-asm");

@IF.not.release()
Std.error.write_line(container.timers["il-asm"]);

ilasm.wait_for_exit();

let result = ilasm.exit_code;
Expand Down
Loading
Loading