raz / commit abf74c58

commit
abf74c587442cc26ef0cf0605bf84e6dcdf7be7d
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
8310908e
Approve the report

Per-target files of a module must export the same interface, and the
compiler checks it. The plan gains its two limits: under 5,000 lines,
and at least 400,000 lines of jed compiled a second.

patch · log

2 files changed, +28 -7

PLAN.md (history) modified +8 -4

@@ -3,7 +3,7 @@
33 jed (Polish *jeden*, one) is a small systems language in Wirth's
44 tradition: full control of memory, volatile access, atomics, calls into
55 C, generic modules. Its compiler is meant to be read in a long weekend:
6-about 4,500 lines of Free Pascal, one pass, no IR, no optimizer, writing
6+about 4,550 lines of Free Pascal, one pass, no IR, no optimizer, writing
77 x86-64 machine code and the ELF file itself.
88
99 The language is defined by `doc/jed.md`. Where this plan and the report
@@ -14,6 +14,10 @@
1414 - The compiler is Free Pascal 3.2.2, `{$mode objfpc}{$H-}`: records,
1515 pointers, shortstrings. No classes, ansistrings, exceptions, dynamic
1616 arrays or SysUtils.
17+- The compiler stays under 5,000 lines, and compiles at least 400,000
18+ lines of jed a second, from reading the sources to writing the
19+ executable. `make bench` measures it, and a step that breaks either
20+ limit isn't done.
1721 - Clarity over cleverness. Every unit opens with a header comment: what
1822 it is, what it depends on, what it leaves out. Comments say why, and
1923 what wherever a layout or encoding isn't obvious.
@@ -52,7 +56,7 @@
5256 | File | Lines | What |
5357 |---|---|---|
5458 | `src/scan.pas` | ~430 | Symbols, literals, comments, error messages |
55-| `src/sym.pas` | ~390 | Types, objects, scopes, layout |
59+| `src/sym.pas` | ~450 | Types, objects, scopes, layout |
5660 | `src/x64.pas` | ~400 | Code buffer, chunks, fixups, instruction encoder |
5761 | `src/gen.pas` | ~660 | Items: loading, storing, copying, frames, calls |
5862 | `src/parse.pas` | ~1,900 | Declarations, statements, expressions, built-ins |
@@ -64,7 +68,7 @@
6468
6569 Stage 1: the core
6670
67-- [ ] 1. Language report, `doc/jed.md`. Reviewed and approved before
71+- [x] 1. Language report, `doc/jed.md`. Reviewed and approved before
6872 any more code.
6973 - [ ] 2. Scanner and symbol table, `scan.pas` and `sym.pas` (drafts
7074 exist), brought in line with the report; they compile.
@@ -76,7 +80,7 @@
7680 modules and `extern`.
7781 - [ ] 6. `lib/Rt.jed`, `lib/Out.jed`; examples (hello, args, variants
7882 and slices, volatile); `make check` runs them against expected
79- output.
83+ output; `make bench` times the compiler on generated jed.
8084
8185 Stage 2: allocation, results, generics
8286

doc/jed.md modified +20 -3

@@ -137,9 +137,26 @@
137137 first of `Name.OS-ARCH.jed`, `Name.OS.jed`, `Name.ARCH.jed` and
138138 `Name.jed` that exists, where `OS-ARCH` is the target, for now only
139139 `linux-x86_64`. So a module whose code depends on the machine or the
140-system comes in one file per target, each with the same exports, and
141-the modules that import it don't change. Machine code (section 8) and
142-system calls belong in such files.
140+system comes in one file per target, and the modules that import it
141+don't change. Machine code (section 8) and system calls belong in such
142+files.
143+
144+The compiler holds every file of such a module to the same interface.
145+When it takes one of `Name.*.jed`, it also reads the declarations of
146+the others beside it, and of `Name.jed` if there is one, and reports an
147+error unless they all export the same names, each the same kind of
148+thing:
149+
150+- a constant of the same type (its value may differ: a system call
151+ number, say);
152+- a type of the same kind, and for a record or variant the same
153+ exported fields and cases, with the same types (unexported fields,
154+ and so the size and layout, may differ);
155+- a variable of the same type;
156+- a procedure of the same signature.
157+
158+Two types here are the same if they are built alike, a name in one file
159+standing for the same name in another.
143160
144161 **Module bodies.** A module may end with `begin` and statements, its
145162 body. Every module's body runs once, before the main module's `main`: