feat(pbs): add explicit guest lifecycle hooks
This commit is contained in:
@@ -80,7 +80,7 @@ Rules:
|
||||
- Attributes are not first-class values and are not reflectable in v1 core.
|
||||
- Attributes do not automatically survive into runtime or bytecode artifacts.
|
||||
- An attribute affects runtime artifacts only when another specification defines an explicit lowering for its semantic effect.
|
||||
- In v1 core, the normative reserved attributes are `Host`, `Capability`, `AssetLowering`, `BuiltinType`, `BuiltinConst`, `IntrinsicCall`, `Init`, `Frame`, `InitAllowed`, and `Doc`.
|
||||
- In v1 core, the normative reserved attributes are `Host`, `Capability`, `AssetLowering`, `BuiltinType`, `BuiltinConst`, `IntrinsicCall`, `Init`, `Frame`, `BeforePause`, `BeforeResume`, `InitAllowed`, and `Doc`.
|
||||
- `Host` is valid only on a host method signature declared directly inside a reserved stdlib/interface-module `declare host` body.
|
||||
- `Capability` is valid only on a host method signature declared directly inside a reserved stdlib/interface-module `declare host` body.
|
||||
- `AssetLowering` is valid only on a host method signature declared directly inside a reserved stdlib/interface-module `declare host` body.
|
||||
@@ -837,3 +837,23 @@ See [PBS generic contracts](../../../compiler/pbs/specs/generic-contracts.md).
|
||||
Templates are checked symbolically in definition scope. Required concrete owners validate all methods and constructors, including unused methods. Substitute complete bodies and applied Self; preserve position restrictions, invariant nominal/phantom identity and logical groups. Explicit function applications filter generic overloads by type arity; ordinary calls never infer them. Bound owner implementations require complete exact signatures and symbolic overlap rejection before use. Finite recursive applications are anchored; expanding type/body families are bounded errors.
|
||||
|
||||
See [Concrete generic structs and free functions](../../../compiler/pbs/specs/generic-structs-and-free-functions.md).
|
||||
|
||||
|
||||
## Controlled guest lifecycle admission
|
||||
|
||||
`[BeforePause]` and `[BeforeResume]` targets MUST be nongeneric top-level
|
||||
userland functions with explicit unit signature `fn name() -> void`, zero
|
||||
parameters, zero logical results and zero captures. Marker arguments and
|
||||
combinations with any other lifecycle marker are invalid; `[Doc]` remains
|
||||
allowed. Globals are not captures. Normal calls and closure creation/use inside
|
||||
the body remain subject to ordinary PBS rules.
|
||||
|
||||
Each role is independently optional and has at most one distinct target across
|
||||
the compiled graph/image, including imported modules. Targets may be in any
|
||||
compiled userland file, without colocation with `[Frame]`. Repeated imports of
|
||||
the same source declaration MUST NOT manufacture duplicate targets; distinct
|
||||
declarations for one role MUST produce a deterministic conflict diagnostic.
|
||||
Direct calls remain normal calls and do not request an OS transition or create
|
||||
a controlled invocation. Runtime FunctionId zero is reserved for the ordinary
|
||||
entry; physical hook IDs are validated after linking. Init/Frame requirements
|
||||
and their frontend/common assembly remain unchanged.
|
||||
|
||||
Reference in New Issue
Block a user