Initial ES modules support
This commit is contained in:
+10
-10
@@ -110,24 +110,24 @@ The same thing happens on a large scale with partial types. Inside a walk, a cal
|
||||
|
||||
## 5. Representation in C
|
||||
|
||||
The C type of a value comes from its type only:
|
||||
The C type of a value comes from its type only. A type with one member is that member's C type:
|
||||
|
||||
| type | C |
|
||||
| member | C |
|
||||
|---|---|
|
||||
| `Unknown` | the code cannot run |
|
||||
| `Undefined`, `Null` | `undefined_t`, `null_t`: unit types |
|
||||
| `Bool` | `bool` |
|
||||
| `Int` | `int32_t` |
|
||||
| `Float` | `double` |
|
||||
| `Str` | `string_t` |
|
||||
| `Obj(cell)` | a pointer to the struct of the cell. The struct starts with a header that holds the cell's number |
|
||||
| `Str` or one `Obj`, plus `Undefined` and/or `Null` | that pointer. `NULL` is null, and `JSRT_UNDEFINED` is undefined |
|
||||
| `Obj` of several cells, maybe with `Undefined` and `Null` | a pointer to the header |
|
||||
| any other sum, and `Any` | `any_t`: a tagged union of every kind |
|
||||
| `Native` | `native_t`: the native's index |
|
||||
| `Obj` | a pointer to the struct of the object's class |
|
||||
|
||||
- **A field that can be absent** holds a sentinel for absent: `JSRT_ABSENT` in a pointer, a tag in an `any_t`.
|
||||
- **An op on a sum** tests which member the value is (by kind, by a sentinel, or by the cell's number in the header), and then works on that member.
|
||||
- **An array's struct** has `length`, `cap` and `items` after its header. An element holds undefined for a hole.
|
||||
A type with several members is a `jsrt_value`: a tag, which says the kind, and the value. A number in a `jsrt_value` is always a double, and an object's tag also says its class. `Unknown` means that the code cannot run.
|
||||
|
||||
- **The C of an op** is a macro of the runtime (lib/rt/core.h), which picks its code by the C types of its operands. A plain C value becomes a `jsrt_value` with a constant tag, so the C compiler removes the tag and keeps only the code for that kind.
|
||||
- **A field that can be absent** has a `has_` flag beside it. Getting it calls a lookup, which goes along the prototype chain.
|
||||
- **An op that depends on an object's class**, such as getting a field or calling a closure, tests the tag of a `jsrt_value` with a `switch`, and has code for each class.
|
||||
- **An array's struct** has `length`, `cap` and `items`. An element holds undefined for a hole.
|
||||
|
||||
## 6. Not in this model yet
|
||||
|
||||
|
||||
Reference in New Issue
Block a user