Files
Pierre-Marie de Rodat 1d5af55be5 Make it possible to bypass file readers to parse internal units
It is often necessary for generated libraries to handle some "intenal"
unit, that will define language builtins. This unit is generally not
represented as an actual source file ("filesystem" tense), but rather as
an in-memory source buffer, which is incompatible with file readers,
which currently forbid all in-memory parsing.

This commit introduces an internal hook (a new "Is_Internal" formal in
$.Implementation's Get_Unit) so that generated libraries can bypass file
readers and thus load their internal units from memory at all times.

TN: U422-030
2021-05-06 11:39:37 +02:00

15 lines
339 B
Plaintext

## vim: ft=makopython
_get_internal_unit = _import_func(
'foo_get_internal_unit',
[AnalysisContext._c_type], AnalysisUnit._c_type
)
def _get_internal_unit_method(self):
c_value = _get_internal_unit(self._c_value)
return AnalysisUnit._wrap(c_value)
AnalysisContext.get_internal_unit = property(_get_internal_unit_method)