implements PR029
This commit is contained in:
@@ -248,6 +248,7 @@ Rules:
|
||||
- Reserved stdlib/toolchain interface modules MAY use attributes where explicitly allowed by syntax and semantics.
|
||||
- Attribute interpretation is compile-time only unless another specification explicitly lowers its effect into runtime-facing metadata.
|
||||
- Reserved attribute names used by builtin-type and intrinsic shells do not become ordinary value-level syntax.
|
||||
- `Slot(...)` is not part of the v1 attribute surface; source that uses `Slot` must be rejected in syntax phase.
|
||||
|
||||
### 6.2 Top-level declarations
|
||||
|
||||
|
||||
@@ -62,7 +62,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`, `BuiltinType`, `BuiltinConst`, `IntrinsicCall`, and `Slot`.
|
||||
- In v1 core, the normative reserved attributes are `Host`, `BuiltinType`, `BuiltinConst`, and `IntrinsicCall`.
|
||||
- `Host` is valid only on a host method signature declared directly inside a reserved stdlib/interface-module `declare host` body.
|
||||
- `Host` is invalid on ordinary user-authored modules, top-level `fn`, struct methods, service methods, callbacks, contracts, and constants.
|
||||
- `Host` metadata is consumed by the compiler during host-binding lowering.
|
||||
@@ -70,7 +70,6 @@ Rules:
|
||||
- `BuiltinType` is valid only on a reserved top-level `declare builtin type` declaration.
|
||||
- `BuiltinConst` is valid only on a reserved top-level `declare const` declaration that omits an initializer.
|
||||
- `IntrinsicCall` is valid only on a method signature declared directly inside a reserved `declare builtin type` body.
|
||||
- `Slot` is valid only on a field declaration in the header of a reserved `declare builtin type`.
|
||||
- Builtin metadata is consumed by the compiler during VM-owned builtin and intrinsic lowering rather than by host-binding lowering.
|
||||
|
||||
### 2.4 Tuple shapes
|
||||
@@ -184,7 +183,9 @@ Rules:
|
||||
- `BuiltinType.version` MUST be a positive integer literal.
|
||||
- Two builtin type declarations in the same resolved stdlib environment MUST NOT lower to the same canonical `(name, version)` unless they denote the same builtin declaration after project/module resolution.
|
||||
- A builtin field type must be builtin-layout-admissible as defined by the builtin/intrinsics specification.
|
||||
- A builtin field `Slot` attribute, when present, MUST declare a non-negative integer literal and must match the declaration's canonical flattened layout.
|
||||
- Builtin field slot offsets are inferred by the compiler from canonical field order and flattened builtin layout width.
|
||||
- Builtin layout composition must be acyclic.
|
||||
- A builtin field that depends on a builtin layout with unresolved flattened width is statically invalid.
|
||||
- `IntrinsicCall` MUST declare exactly the named argument `name` and MAY additionally declare `version`.
|
||||
- `IntrinsicCall.name` MUST be a non-empty string literal.
|
||||
- `IntrinsicCall.version`, when present, MUST be a positive integer literal.
|
||||
@@ -657,7 +658,6 @@ At minimum, deterministic static diagnostics are required for:
|
||||
- invalid `BuiltinType` attribute target,
|
||||
- invalid `BuiltinConst` attribute target,
|
||||
- invalid `IntrinsicCall` attribute target,
|
||||
- invalid `Slot` attribute target,
|
||||
- duplicate `Host` attribute on one host method,
|
||||
- missing required `Host` attribute on a reserved host method,
|
||||
- malformed `Host(module=..., name=..., version=...)` argument set,
|
||||
@@ -675,9 +675,9 @@ At minimum, deterministic static diagnostics are required for:
|
||||
- malformed `BuiltinConst(target=..., name=..., version=...)` argument set,
|
||||
- invalid empty `BuiltinConst.target` or `BuiltinConst.name`,
|
||||
- invalid non-positive `BuiltinConst.version`,
|
||||
- invalid builtin field `Slot(...)`,
|
||||
- overlapping builtin field slot range,
|
||||
- builtin field type not builtin-layout-admissible,
|
||||
- cyclic builtin layout composition,
|
||||
- unresolved flattened builtin layout width,
|
||||
- duplicate canonical builtin type identity,
|
||||
- duplicate canonical builtin intrinsic identity,
|
||||
- duplicate canonical builtin constant identity,
|
||||
|
||||
@@ -117,8 +117,8 @@ Illustrative form:
|
||||
```pbs
|
||||
[BuiltinType(name="vec2", version=1)]
|
||||
declare builtin type Vec2(
|
||||
[Slot(0)] pub x: float,
|
||||
[Slot(1)] pub y: float,
|
||||
pub x: float,
|
||||
pub y: float,
|
||||
) {
|
||||
[IntrinsicCall(name="dot")]
|
||||
fn dot(other: Vec2) -> float;
|
||||
@@ -196,22 +196,16 @@ Consequences:
|
||||
- a builtin field declaration does not imply that builtin values are structs,
|
||||
- and a builtin field declaration does not allow user code to provide storage-level implementation bodies.
|
||||
|
||||
## 10. `Slot` Metadata
|
||||
## 10. Builtin Slot Inference
|
||||
|
||||
`Slot(n)` identifies the starting flattened slot offset of a builtin field within
|
||||
the enclosing builtin layout.
|
||||
Builtin field slot offsets are inferred by the compiler, not authored in source.
|
||||
|
||||
Rules:
|
||||
|
||||
- `n` is zero-based,
|
||||
- `Slot(n)` refers to the starting slot offset after flattening nested builtin-layout-admissible fields,
|
||||
- slot offsets must be unique,
|
||||
- slot offsets must match the declaration's canonical flattened layout,
|
||||
- and overlapping slot ranges are invalid.
|
||||
|
||||
`Slot` exists to make canonical layout explicit.
|
||||
Future grammar may allow offset inference by declaration order, but explicit slot
|
||||
metadata is valid and authoritative in this temporary contract.
|
||||
- slot offsets are zero-based and deterministic,
|
||||
- offsets are computed from declaration order plus flattened widths of field types,
|
||||
- nested builtin fields contribute their full flattened width to subsequent offsets,
|
||||
- and source-level `Slot(...)` metadata is forbidden in v1.
|
||||
|
||||
## 11. Builtin Layout Admissibility
|
||||
|
||||
@@ -256,14 +250,14 @@ Example:
|
||||
```pbs
|
||||
[BuiltinType(name="color", version=1)]
|
||||
declare builtin type Color(
|
||||
[Slot(0)] pub raw: int,
|
||||
pub raw: int,
|
||||
);
|
||||
|
||||
[BuiltinType(name="pixel", version=1)]
|
||||
declare builtin type Pixel(
|
||||
[Slot(0)] pub x: int,
|
||||
[Slot(1)] pub y: int,
|
||||
[Slot(2)] pub color: Color,
|
||||
pub x: int,
|
||||
pub y: int,
|
||||
pub color: Color,
|
||||
);
|
||||
```
|
||||
|
||||
@@ -332,8 +326,8 @@ Example:
|
||||
```pbs
|
||||
[BuiltinType(name="vec2", version=1)]
|
||||
declare builtin type Vec2(
|
||||
[Slot(0)] pub x: float,
|
||||
[Slot(1)] pub y: float,
|
||||
pub x: float,
|
||||
pub y: float,
|
||||
) {
|
||||
[IntrinsicCall(name="dot")]
|
||||
fn dot(other: Vec2) -> float;
|
||||
@@ -530,13 +524,13 @@ At minimum, a conforming implementation must reject:
|
||||
1. `declare builtin type` in an ordinary user-authored module,
|
||||
2. missing required `BuiltinType` metadata on a builtin declaration,
|
||||
3. duplicate builtin field names within one declaration,
|
||||
4. duplicate or overlapping slot assignments,
|
||||
4. source-level `Slot(...)` usage in builtin declarations,
|
||||
5. builtin field types that are not builtin-layout-admissible,
|
||||
6. `IntrinsicCall` used outside a builtin declaration body,
|
||||
7. `BuiltinConst` used outside a reserved top-level `declare const` shell,
|
||||
8. duplicate canonical builtin type identities in the same compilation environment,
|
||||
9. duplicate intrinsic canonical identities within the same builtin owner and version line,
|
||||
10. mismatched declared field slot metadata versus flattened layout,
|
||||
10. cyclic or unresolved flattened builtin layout composition,
|
||||
11. executable member bodies inside builtin declarations,
|
||||
12. any lowering that routes VM-owned builtin operations through the host-binding pipeline.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user