Appearance
| 1 | namespace IR is | |
| 2 | use Semantic.Symbols.Function | |
| 3 | ||
| 4 | /// Which functions the program's own sources compiled to, as against a | |
| 5 | /// source library's or nothing the program wrote: what a back end's | |
| 6 | /// text form keeps when it is asked for the program's functions only. | |
| 7 | class PROGRAM_FUNCTIONS is | |
| 8 | init() is si | |
| 9 | ||
| 10 | /// Whether `function` was compiled from one of the program's own | |
| 11 | /// source files. The entry the top-level statements are gathered | |
| 12 | /// into is the program's, though it has no position. | |
| 13 | /// | |
| 14 | /// - function: the function to classify | |
| 15 | contains(function: Function) -> bool static is | |
| 16 | if function.is_top_level_entry then | |
| 17 | return true | |
| 18 | fi | |
| 19 | ||
| 20 | let location = source_location(function) | |
| 21 | ||
| 22 | if location.is_internal \/ location.is_reflected \/ location.is_unknown then | |
| 23 | return false | |
| 24 | fi | |
| 25 | ||
| 26 | let libraries = IoC.CONTAINER.instance.build_flags.library_sources | |
| 27 | ||
| 28 | return !(libraries?.library_for(IO.Path.get_full_path(location.file_name))? ?? false) | |
| 29 | si | |
| 30 | ||
| 31 | /// Where a report about `function` points: a generator frame's | |
| 32 | /// members have no source of their own, so it is the generator. | |
| 33 | /// | |
| 34 | /// - function: the function to locate | |
| 35 | source_location(function: Function) -> Source.LOCATION static => | |
| 36 | if let frame: Semantic.Symbols.STATE_MACHINE_FRAME_BASE = function.owner then | |
| 37 | frame.owning_function.location | |
| 38 | else | |
| 39 | function.location | |
| 40 | fi | |
| 41 | si | |
| 42 | si |