diff options
| author | Cliff Click <cliffc@acm.org> | 2026-11-16 14:25:14 -0800 |
|---|---|---|
| committer | Cliff Click <cliffc@acm.org> | 2026-11-16 14:25:14 -0800 |
| commit | 0dcd3513a633479ce228f24826db4f09e4c0fc8b (patch) | |
| tree | d8fb6d0fb382df5799789e9dc1eb0fae2d381cce /chapter29/docs | |
| parent | 51a029304d8105b201bdfb81a7692b8a1b16b028 (diff) | |
| download | Simple-0dcd3513a633479ce228f24826db4f09e4c0fc8b.tar.gz Simple-0dcd3513a633479ce228f24826db4f09e4c0fc8b.zip | |
Phi fix
Fix Phi/Add refactoring peephole to canonicalize regardless of peephole order.
Treat class fcns as having `self` be the class pointer
Diffstat (limited to 'chapter29/docs')
| -rw-r--r-- | chapter29/docs/29-grammar.md | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/chapter29/docs/29-grammar.md b/chapter29/docs/29-grammar.md index cb231ce0..d580a28b 100644 --- a/chapter29/docs/29-grammar.md +++ b/chapter29/docs/29-grammar.md @@ -57,6 +57,7 @@ constructorParameter : type '^'? bindingModifier? IDENTIFIER ; // A method is an ordinary fixed function binding in a struct definition. // The compiler supplies self; it is not written in parameterList. +// Global functions use their owning class singleton as self. // Function types and expressions both receive their implicit receiver here. methodDeclaration : 'val' bindingModifier? IDENTIFIER '=' functionExpression ';' ; @@ -220,10 +221,10 @@ one-pass IR builder: - A statement beginning with `{` might be a block or a function-type binding. `Declarations` and `Types` use speculative parsing and cursor restore; qualified type lookup also stops before a suffix that belongs to an expression. -- Bare assignment, field assignment, and compound updates share the grammar's - precedence but use different IR paths. `References` decides between an SSA - local, a constructor field's local value, and an actual memory access. A - function-valued field may also supply an implicit receiver to a call. +- Bare fields resolve through their receiver, so reads, assignments, and + updates share the field-access path. Locals use SSA; class declarations + retain Scope values until initializer exit. Global functions receive their + owning class singleton as `self`; instance methods receive their object. - `for` updates are scanned first and parsed after the body, where their effects belong. Explicit constructor bodies are scanned first and parsed after field discovery, so later fields have local slots. Both use `Lexer.skipTo`, which |
