reflect.Package
An isolated runtime-compiled package.
Signature
class reflect.PackageAn isolated runtime-compiled package.
Source:<builtin>/reflect/reflect.bamlbytes 16094–24322
Fields
_inner
unknownStatic methods
_compile
(_finish
(compile
(Compiles files into an isolated package, resolving its dependencies
against packages.
Parameters
files: source text keyed by path, as the package'sbaml_src.packages: packages the source may depend on, keyed by the alias it imports them under.
Throws
reflect.errors.CompilationErrorif the source does not compile.- anything the package's top-level initialization throws, which is why
the clause is
unknown.
current
() -> reflect.Package throws neverThe package lexically enclosing this call site.
Instance methods
_with_types
((internal) Internal native backing with_types; every type is a type
value.
Exported class types, keyed by package-local name.
Diagnostics produced while compiling this package.
Exported enum types, keyed by package-local name.
The exported class called name, or null if the package exports
none.
The exported enum called name, or null if the package exports none.
Extract an exported function through an ordinary function-type
contract, or null if the package exports no function called name.
Throws
reflect.errors.CompilationErrorif the function exists but is not anF, or is an unspecialized generic.
The value of the global called name as T, or null if the package
has none. With a nullable T, a global holding null also reads as
null; use get_global to tell the two apart.
Throws
reflect.errors.TypeMismatchif the global's value is not aT.
The exported interface called name, or null if the package exports
none.
Exported free-function signatures, keyed by package-local name.
The exported class called name. A name the package exports as some
other kind of declaration is a miss. find_class returns null
instead of throwing.
Throws
reflect.errors.NotFoundif the package exports no class calledname.
The exported enum called name. A name the package exports as some
other kind of declaration is a miss. find_enum returns null instead
of throwing.
Throws
reflect.errors.NotFoundif the package exports no enum calledname.
get_function
<F>(Extract an exported function through an ordinary function-type contract.
find_function returns null for a missing name instead of throwing.
A lookup by name has nowhere to put type arguments, so an unspecialized generic function is refused here.
Throws
reflect.errors.NotFoundif the package exports no function calledname.reflect.errors.CompilationErrorif the function exists but is not anF, or is an unspecialized generic.
get_global
<T>(The value of the global variable or client declaration called
name, as T. find_global returns null for a missing name instead
of throwing.
Throws
reflect.errors.NotFoundif the package has no global calledname.reflect.errors.TypeMismatchif the global's value is not aT.
The exported interface called name. A name the package exports as
some other kind of declaration is a miss. find_interface returns
null instead of throwing.
Throws
reflect.errors.NotFoundif the package exports no interface calledname.
globals
(self) -> map<string, unknown> throws neverGlobal variables and client declarations, keyed by package-local
name, with their current values. Each value is the global itself,
shared with every reader: changing its contents is visible everywhere.
Exported interface types, keyed by package-local name.
tests
(self) -> map<string, () -> null throws unknown> throws unknownBundled tests as directly invocable zero-argument callables.
with_types
(A package that exports everything this one does, plus types under
the given names, for a later Package.compile to mount: a bare class,
enum, interface, or alias declaration is re-exported under its name
(the same declaration, so a consumer that mounts both packages sees
one type), any other type is declared as an alias, and every
declaration a mounted type reaches is exported under its own name. A
name this package already exports is refused.
Implementations
reflect.AnyClass for T
Instance methods
The class declaration's schema metadata, or empty metadata when the runtime type is not a class.
Read the field called name as T, or null if this value's class
declares no such field. A present field holding null also reads as
null; use has_field or get<T?> to tell the two apart.
Throws
reflect.errors.TypeMismatchif the field's value is not aT.
A value-bound handle to the field called name, or null if this
value's class declares no such field.
get
<T>(self, name: string) -> T throws reflect.errors.NotFound | reflect.errors.TypeMismatchRead the field called name as T. Read a nullable field with a
nullable T (get<int?>). find returns null for a missing field
instead of throwing.
Throws
reflect.errors.NotFoundif this value's class declares no field calledname.reflect.errors.TypeMismatchif the field's value is not aT.
A value-bound handle to the field called name. find_field returns
null instead of throwing.
Throws
reflect.errors.NotFoundif this value's class declares no field calledname.
has_field
(self, name: string) -> bool throws neverWhether this value's runtime class declares a field called name.
false when the runtime type is not a class.
Reflected fields bound to this value for Field.value<T>().
name
(self) -> string throws neverThe rendered name of this value's concrete runtime type.
This value's concrete runtime type.
Source:<builtin>/reflect/reflect.bamlbytes 14431–14461
Related definitions
reflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.Classreflect.class.Fieldreflect.CompileArtifactreflect.Diagnosticreflect.Enumreflect.errors.CompilationErrorreflect.errors.NotFoundreflect.errors.TypeMismatchreflect.Functionreflect.Interfacereflect.Metareflect.Typereflect.TypeView