|
1 | 1 | module DAECompilerCthulhuExt |
2 | 2 |
|
3 | 3 | using Core.IR |
4 | | -using DAECompiler: DAECompiler, DAEIPOResult, UncompilableIPOResult, Settings, ADAnalyzer, structural_analysis!, find_matching_ci, StructureCache, ir_to_src, get_method_instance, MappingInfo, AnalyzedSource |
| 4 | +using DAECompiler: DAECompiler, DAEIPOResult, UncompilableIPOResult, Settings, ADAnalyzer, structural_analysis!, find_matching_ci, matched_system_structure, StructureCache, ir_to_src, get_method_instance, MappingInfo, AnalyzedSource |
5 | 5 | using Compiler: Compiler, InferenceResult, NativeInterpreter, SOURCE_MODE_GET_SOURCE, get_inference_world, typeinf_ext, Effects, get_ci_mi, NoCallInfo |
6 | 6 | using Accessors: setproperties |
7 | 7 | using Diffractor: FRuleCallInfo |
@@ -105,9 +105,21 @@ function Cthulhu.menu_commands(provider::DAEProvider) |
105 | 105 | commands = Cthulhu.default_menu_commands(provider) |
106 | 106 | filter!(x -> !in(x.name, (:optimize, :dump_params, :llvm, :native)), commands) |
107 | 107 | push!(commands, toggle_setting(provider, 'f', :force_inline_all, "force inline all")) |
| 108 | + push!(commands, Cthulhu.perform_action(show_mss, 'm', :show_mss, :actions, "Show system structure")) |
108 | 109 | return commands |
109 | 110 | end |
110 | 111 |
|
| 112 | +function show_mss(state::CthulhuState) |
| 113 | + result = state.ci.inferred::DAEIPOResult |
| 114 | + terminal = state.terminal |
| 115 | + io = terminal.out_stream::IO |
| 116 | + mss = matched_system_structure(result, state.provider.settings.mode) |
| 117 | + (_, width) = displaysize(terminal) |
| 118 | + printstyled(io, '\n', '-'^((width - 26) ÷ 2), " Showing system structure ", '-'^((width - 26) ÷ 2), '\n'; color = :light_black) |
| 119 | + show(io, MIME"text/plain"(), mss) |
| 120 | + printstyled(io, '\n', '-'^width, "\n\n"; color = :light_black) |
| 121 | +end |
| 122 | + |
111 | 123 | function toggle_setting(provider::DAEProvider, key::Char, name::Symbol, description::String = string(name)) |
112 | 124 | callback = state -> toggle_setting!(state, name) |
113 | 125 | Command(callback, key, name, description, :toggles) |
|
0 commit comments