@jhlagado/azm 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -15
- package/dist/src/api-compile.js +27 -0
- package/dist/src/assembly/assemble-program.js +5 -0
- package/dist/src/assembly/import-visibility.d.ts +3 -0
- package/dist/src/assembly/import-visibility.js +204 -0
- package/dist/src/node/source-host.js +40 -13
- package/dist/src/outputs/write-asm80.js +4 -0
- package/dist/src/register-contracts/programModel-routines.js +33 -17
- package/dist/src/register-contracts/report.js +15 -3
- package/dist/src/register-contracts/smartCommentParsing.d.ts +1 -0
- package/dist/src/register-contracts/smartCommentParsing.js +42 -7
- package/dist/src/register-contracts/smartComments.d.ts +2 -2
- package/dist/src/register-contracts/smartComments.js +3 -4
- package/dist/src/source/logical-lines.d.ts +3 -0
- package/dist/src/source/source-span.d.ts +2 -0
- package/dist/src/syntax/parse-directive-statement.d.ts +1 -6
- package/dist/src/syntax/parse-directive-statement.js +3 -1
- package/dist/src/syntax/parse-layout-declarations.js +11 -2
- package/dist/src/syntax/parse-line.js +18 -2
- package/dist/src/tooling/api.js +1 -1
- package/docs/codebase/01-orientation-and-repository-layout.md +192 -0
- package/docs/codebase/02-source-loading-and-parsing.md +263 -0
- package/docs/codebase/03-assembly-and-z80-emission.md +251 -0
- package/docs/codebase/04-ops-and-register-contracts.md +237 -0
- package/docs/codebase/05-interfaces-and-output-artifacts.md +253 -0
- package/docs/codebase/06-verification-and-maintenance.md +202 -0
- package/docs/codebase/appendices/a-directory-file-reference.md +253 -0
- package/docs/codebase/appendices/b-compile-flow-reference.md +103 -0
- package/docs/codebase/appendices/c-public-surface-reference.md +106 -0
- package/docs/codebase/appendices/index.md +16 -0
- package/docs/codebase/index.md +46 -0
- package/package.json +2 -3
- package/docs/reference/cli.md +0 -158
- package/docs/reference/tooling-api.md +0 -320
package/docs/reference/cli.md
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# AZM CLI Reference
|
|
2
|
-
|
|
3
|
-
Status: active user reference
|
|
4
|
-
|
|
5
|
-
The `azm` command assembles `.asm` and `.z80` source files and writes the
|
|
6
|
-
requested object artifacts.
|
|
7
|
-
|
|
8
|
-
```sh
|
|
9
|
-
azm [options] <entry.asm|entry.z80>
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
The entry file must be the final argument. AZM source uses `.asm` or `.z80`.
|
|
13
|
-
Register contracts interface files use `.asmi`; they are loaded with `--interface`
|
|
14
|
-
and are not compile entries.
|
|
15
|
-
|
|
16
|
-
## Basic Use
|
|
17
|
-
|
|
18
|
-
Build the default artifact set next to the source file:
|
|
19
|
-
|
|
20
|
-
```sh
|
|
21
|
-
azm program.asm
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Write a specific primary output:
|
|
25
|
-
|
|
26
|
-
```sh
|
|
27
|
-
azm --type bin --output build/program.bin program.asm
|
|
28
|
-
azm --type hex --output build/program.hex program.asm
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
Add include search paths:
|
|
32
|
-
|
|
33
|
-
```sh
|
|
34
|
-
azm -I include -I vendor program.asm
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
Load project directive aliases:
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
azm --aliases azm.aliases.json program.asm
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Normalize Debug80 map source paths against the project root:
|
|
44
|
-
|
|
45
|
-
```sh
|
|
46
|
-
azm --source-root . --output build/program.hex src/program.asm
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Output Artifacts
|
|
50
|
-
|
|
51
|
-
By default AZM writes the primary output plus useful side artifacts using the
|
|
52
|
-
same base path.
|
|
53
|
-
|
|
54
|
-
| Artifact | Meaning |
|
|
55
|
-
| ------------------- | -------------------------------------- |
|
|
56
|
-
| `.hex` | Intel HEX output |
|
|
57
|
-
| `.bin` | flat binary output |
|
|
58
|
-
| `.d8.json` | Debug80 map |
|
|
59
|
-
| `.z80` | lowered assembler source |
|
|
60
|
-
| `.regcontracts.txt` | opt-in register contracts debug report |
|
|
61
|
-
| `.asmi` | inferred register contracts interface |
|
|
62
|
-
|
|
63
|
-
Disable standard artifacts when they are not needed:
|
|
64
|
-
|
|
65
|
-
```sh
|
|
66
|
-
azm --nod8m program.asm
|
|
67
|
-
azm --nobin --nohex --nod8m --rc audit program.asm
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Options
|
|
71
|
-
|
|
72
|
-
| Option | Meaning |
|
|
73
|
-
| --------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
74
|
-
| `-o, --output <file>` | Primary output path. The extension must match `--type`. |
|
|
75
|
-
| `-t, --type <hex\|bin>` | Primary output type. Default: `hex`. |
|
|
76
|
-
| `--nobin` | Do not write `.bin`. |
|
|
77
|
-
| `--nohex` | Do not write `.hex`. |
|
|
78
|
-
| `--nod8m` | Do not write `.d8.json`. |
|
|
79
|
-
| `--asm80` | Write lowered assembler source as `.z80`. |
|
|
80
|
-
| `--source-root <dir>` | Emit project-relative source paths in `.d8.json`. |
|
|
81
|
-
| `--case-style <mode>` | Lint mnemonic/register/op-head case: `off`, `upper`, `lower`, or `consistent`. |
|
|
82
|
-
| `--rc, --register-contracts <mode>` | Register contracts mode: `off`, `audit`, `warn`, `error`, or `strict`. |
|
|
83
|
-
| `--reg-report, --emit-register-report` | Opt-in debug report: write `.regcontracts.txt`. |
|
|
84
|
-
| `--reg-interface, --emit-register-interface` | Write inferred `.asmi` interface. |
|
|
85
|
-
| `--contracts, --annotate-register-contracts` | Update AZMDoc contract comments in source. |
|
|
86
|
-
| `--fix` | Apply conservative register contract source fixes and update contracts. |
|
|
87
|
-
| `--accept-out <routine:carrier>` | Promote an inferred output candidate while annotating. |
|
|
88
|
-
| `--interface <file>` | Load external register contracts from `.asmi`. Repeatable. |
|
|
89
|
-
| `--reg-profile, --register-profile <profile>` | Register contracts profile. Currently `mon3`. |
|
|
90
|
-
| `--aliases <file>` | Load project directive alias JSON. Repeatable. |
|
|
91
|
-
| `-I, --include <dir>` | Add an include search path. Repeatable. |
|
|
92
|
-
| `-V, --version` | Print package version. |
|
|
93
|
-
| `-h, --help` | Print CLI help. |
|
|
94
|
-
|
|
95
|
-
## Debug80 Maps
|
|
96
|
-
|
|
97
|
-
`--case-style` is a source-style lint only. It checks instruction mnemonics,
|
|
98
|
-
register names, and visible `op` heads/bodies. It does not rename labels,
|
|
99
|
-
constants, directives, or compile-time functions.
|
|
100
|
-
|
|
101
|
-
The `.d8.json` artifact records AZM as the generator, the package version, and
|
|
102
|
-
the input/output paths used for the map. When `--source-root` is supplied, file
|
|
103
|
-
keys and generator input paths are written relative to that directory with `/`
|
|
104
|
-
separators. Constants are emitted as `value` metadata without fake addresses;
|
|
105
|
-
labels and addressable data carry `address`.
|
|
106
|
-
|
|
107
|
-
## Register Contracts Examples
|
|
108
|
-
|
|
109
|
-
Audit inferred contracts without failing the build:
|
|
110
|
-
|
|
111
|
-
```sh
|
|
112
|
-
azm --rc audit program.asm
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Treat contract conflicts as build failures:
|
|
116
|
-
|
|
117
|
-
```sh
|
|
118
|
-
azm --rc error program.asm
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Treat every register contracts issue as a build failure, including unknown call
|
|
122
|
-
boundaries and stack effects AZM cannot prove within an `@` routine boundary:
|
|
123
|
-
|
|
124
|
-
```sh
|
|
125
|
-
azm --rc strict program.asm
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
Generate compact AZMDoc blocks in source:
|
|
129
|
-
|
|
130
|
-
```sh
|
|
131
|
-
azm --contracts --rc audit program.asm
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
Load external contracts for monitor/library routines:
|
|
135
|
-
|
|
136
|
-
```sh
|
|
137
|
-
azm --rc error --interface mon3.asmi program.asm
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## `.asmi` Interfaces
|
|
141
|
-
|
|
142
|
-
External register contract interfaces are plain metadata files:
|
|
143
|
-
|
|
144
|
-
```text
|
|
145
|
-
extern MON_PRINT_CHAR
|
|
146
|
-
in A
|
|
147
|
-
clobbers A
|
|
148
|
-
end
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Use `.asmi` for these files so they are clearly distinct from assembler source.
|
|
152
|
-
|
|
153
|
-
## Exit Behavior
|
|
154
|
-
|
|
155
|
-
The CLI exits with a non-zero status when parsing, semantic checks, register contracts
|
|
156
|
-
mode, lowering, or artifact writing reports an error. Diagnostics are printed
|
|
157
|
-
with file, line, column, severity, and diagnostic ID where that information is
|
|
158
|
-
available.
|
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
# AZM Tooling API
|
|
2
|
-
|
|
3
|
-
`@jhlagado/azm` exposes a stable programmatic surface for Node tooling. Use
|
|
4
|
-
these imports instead of deep paths under `dist/src`.
|
|
5
|
-
|
|
6
|
-
Install the package once, then import from the public entry points:
|
|
7
|
-
|
|
8
|
-
```sh
|
|
9
|
-
npm install @jhlagado/azm
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
## Stable entry points
|
|
13
|
-
|
|
14
|
-
- `@jhlagado/azm`
|
|
15
|
-
Re-exports the stable public surface.
|
|
16
|
-
- `@jhlagado/azm/tooling`
|
|
17
|
-
Layer A/B APIs for parsing, loading, diagnostics, spans, and semantics-only analysis.
|
|
18
|
-
- `@jhlagado/azm/compile`
|
|
19
|
-
Layer C compile API and default format writers.
|
|
20
|
-
|
|
21
|
-
## Debug80 Integration Path
|
|
22
|
-
|
|
23
|
-
Debug80 should link through the public package entry points, not internal
|
|
24
|
-
`dist/src/...` paths.
|
|
25
|
-
|
|
26
|
-
Use this path when Debug80 needs editor-style diagnostics, symbols, or
|
|
27
|
-
register contracts information without writing files:
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
import {
|
|
31
|
-
analyzeProgram,
|
|
32
|
-
analyzeRegisterContractsForTools,
|
|
33
|
-
loadProgram,
|
|
34
|
-
} from '@jhlagado/azm/tooling';
|
|
35
|
-
|
|
36
|
-
const loaded = await loadProgram({
|
|
37
|
-
entryFile: '/abs/path/to/main.asm',
|
|
38
|
-
includeDirs: ['/abs/path/to/includes'],
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
if (!loaded.loadedProgram) {
|
|
42
|
-
return loaded.diagnostics;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const analysis = analyzeProgram(loaded.loadedProgram, {
|
|
46
|
-
caseStyle: 'consistent',
|
|
47
|
-
requireMain: false,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const registerContracts = analyzeRegisterContractsForTools(loaded.loadedProgram, {
|
|
51
|
-
mode: 'audit',
|
|
52
|
-
registerContractsProfile: 'mon3',
|
|
53
|
-
});
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Use this path when Debug80 needs assembled bytes and debugger metadata:
|
|
57
|
-
|
|
58
|
-
```ts
|
|
59
|
-
import { compile, defaultFormatWriters } from '@jhlagado/azm/compile';
|
|
60
|
-
|
|
61
|
-
const result = await compile(
|
|
62
|
-
'/abs/path/to/main.asm',
|
|
63
|
-
{
|
|
64
|
-
includeDirs: ['/abs/path/to/includes'],
|
|
65
|
-
sourceRoot: '/abs/path/to/project',
|
|
66
|
-
d8mInputs: {
|
|
67
|
-
hex: '/abs/path/to/project/build/main.hex',
|
|
68
|
-
bin: '/abs/path/to/project/build/main.bin',
|
|
69
|
-
},
|
|
70
|
-
outputType: 'hex',
|
|
71
|
-
emitBin: true,
|
|
72
|
-
emitHex: true,
|
|
73
|
-
emitD8m: true,
|
|
74
|
-
registerContracts: 'audit',
|
|
75
|
-
registerContractsInterfaces: ['/abs/path/to/mon3.asmi'],
|
|
76
|
-
},
|
|
77
|
-
{ formats: defaultFormatWriters },
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
const diagnostics = result.diagnostics;
|
|
81
|
-
const d8m = result.artifacts.find((artifact) => artifact.kind === 'd8m');
|
|
82
|
-
const binary = result.artifacts.find((artifact) => artifact.kind === 'bin');
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
The integration contract is:
|
|
86
|
-
|
|
87
|
-
- source entries are `.asm` or `.z80`
|
|
88
|
-
- external register contracts are `.asmi`
|
|
89
|
-
- include search paths are supplied explicitly with `includeDirs`
|
|
90
|
-
- directive alias JSON files are supplied explicitly with `directiveAliasFiles`
|
|
91
|
-
- `compile()` returns artifacts in memory; the CLI is only responsible for
|
|
92
|
-
writing those artifacts to disk
|
|
93
|
-
- Debug80 should consume the `d8m` artifact for source/address metadata and the
|
|
94
|
-
`bin` artifact for loadable bytes (hex is acceptable when bin is not emitted)
|
|
95
|
-
- Do not rely on lowered `.z80` for Debug80 integration until asm80 coverage is
|
|
96
|
-
complete; use **bin + d8m** as the supported debugger path
|
|
97
|
-
- pass `sourceRoot` so D8 file keys are stable project-relative source paths
|
|
98
|
-
rather than basename-only paths
|
|
99
|
-
- pass `d8mInputs` when Debug80 knows the intended artifact paths; AZM records
|
|
100
|
-
those under `generator.inputs`
|
|
101
|
-
- D8 constants use `value` without `address`; only labels and addressable data
|
|
102
|
-
are breakpoint anchors
|
|
103
|
-
- diagnostics are data objects and should be displayed directly rather than
|
|
104
|
-
parsed from CLI text
|
|
105
|
-
|
|
106
|
-
## D8 Debug Map Shape
|
|
107
|
-
|
|
108
|
-
The D8 artifact is typed as `D8mArtifact`, with `json: D8mJson`. Debug80 can
|
|
109
|
-
import these types from `@jhlagado/azm/compile`.
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
import type { D8mArtifact, D8mJson, D8mSymbol } from '@jhlagado/azm/compile';
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
The top-level map contains:
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
{
|
|
119
|
-
format: 'd8-debug-map',
|
|
120
|
-
version: 1,
|
|
121
|
-
arch: 'z80',
|
|
122
|
-
addressWidth: 16,
|
|
123
|
-
endianness: 'little',
|
|
124
|
-
generator: {
|
|
125
|
-
name: 'azm',
|
|
126
|
-
tool: 'azm',
|
|
127
|
-
version: '0.1.1',
|
|
128
|
-
inputs: {
|
|
129
|
-
entry: 'src/pacmo/pacmo.z80',
|
|
130
|
-
hex: 'build/pacmo.hex',
|
|
131
|
-
bin: 'build/pacmo.bin',
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
files: {
|
|
135
|
-
'src/pacmo/pacmo.z80': {
|
|
136
|
-
segments: [],
|
|
137
|
-
symbols: [],
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
segments: [],
|
|
141
|
-
symbols: [],
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
Constants and labels intentionally have different shapes:
|
|
146
|
-
|
|
147
|
-
```ts
|
|
148
|
-
{ name: 'ColorRed', kind: 'constant', value: 1 }
|
|
149
|
-
{ name: 'main', kind: 'label', address: 0x4000 }
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
A constant value is not a breakpoint address. Debug80 should use labels and
|
|
153
|
-
addressable data symbols as breakpoint anchors.
|
|
154
|
-
|
|
155
|
-
## Layer A: Load and Parse
|
|
156
|
-
|
|
157
|
-
Use `loadProgram()` when you need the same AST, spans, and diagnostics that the compiler uses, but without lowering or writing artifacts.
|
|
158
|
-
|
|
159
|
-
```ts
|
|
160
|
-
import { loadProgram } from '@jhlagado/azm/tooling';
|
|
161
|
-
|
|
162
|
-
const result = await loadProgram({
|
|
163
|
-
entryFile: '/abs/path/to/main.asm',
|
|
164
|
-
includeDirs: ['/abs/path/to/includes'],
|
|
165
|
-
preloadedText: 'ORG 0100H\\nSTART:\\n RET\\n',
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
if (result.loadedProgram) {
|
|
169
|
-
console.log(result.loadedProgram.program.kind); // "Program"
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
for (const diagnostic of result.diagnostics) {
|
|
173
|
-
console.log(diagnostic.id, diagnostic.message);
|
|
174
|
-
}
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
Notes:
|
|
178
|
-
|
|
179
|
-
- `preloadedText` applies to the entry file only. This is intended for unsaved editor buffers.
|
|
180
|
-
- `signal?: AbortSignal` is accepted for best-effort cancellation of stale editor work.
|
|
181
|
-
- `parseEntryOnly` is not part of v1. Use `loadProgram()` and debounce at the caller when needed.
|
|
182
|
-
|
|
183
|
-
## Layer B: Analyze Without Emitting
|
|
184
|
-
|
|
185
|
-
Use `analyzeProgram()` after `loadProgram()` to run the current non-codegen semantic checks:
|
|
186
|
-
|
|
187
|
-
- entry contract validation such as `requireMain`
|
|
188
|
-
- case-style linting
|
|
189
|
-
- environment building
|
|
190
|
-
- instruction acceptance checks that do not require lowering
|
|
191
|
-
|
|
192
|
-
```ts
|
|
193
|
-
import { analyzeProgram, loadProgram } from '@jhlagado/azm/tooling';
|
|
194
|
-
|
|
195
|
-
const loaded = await loadProgram({ entryFile: '/abs/path/to/main.asm' });
|
|
196
|
-
if (!loaded.loadedProgram) {
|
|
197
|
-
throw new Error('Parse/load failed');
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const analysis = analyzeProgram(loaded.loadedProgram, {
|
|
201
|
-
caseStyle: 'consistent',
|
|
202
|
-
requireMain: true,
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
console.log(analysis.diagnostics);
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
`analysis.env` is returned only when semantic analysis completes without errors.
|
|
209
|
-
|
|
210
|
-
## Register Contracts Tooling
|
|
211
|
-
|
|
212
|
-
Use `analyzeRegisterContractsForTools()` after `loadProgram()` when an editor, lint runner, or future LSP server needs register contracts diagnostics without parsing report text. The function returns the same inferred output candidates used by the CLI report, plus ready-to-apply quick-fix metadata for confirming intent at the call site.
|
|
213
|
-
|
|
214
|
-
```ts
|
|
215
|
-
import { analyzeRegisterContractsForTools, loadProgram } from '@jhlagado/azm/tooling';
|
|
216
|
-
|
|
217
|
-
const loaded = await loadProgram({ entryFile: '/abs/path/to/main.z80' });
|
|
218
|
-
if (!loaded.loadedProgram) {
|
|
219
|
-
throw new Error('Parse/load failed');
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const registerContracts = analyzeRegisterContractsForTools(loaded.loadedProgram, {
|
|
223
|
-
mode: 'audit',
|
|
224
|
-
registerContractsProfile: 'mon3',
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
for (const diagnostic of registerContracts.candidateDiagnostics) {
|
|
228
|
-
console.log(diagnostic.file, diagnostic.line, diagnostic.message);
|
|
229
|
-
console.log(diagnostic.autoFixable); // true when CLI --fix can safely add the hint
|
|
230
|
-
if (diagnostic.autoFixable && diagnostic.codeAction) {
|
|
231
|
-
console.log(diagnostic.codeAction.edit.text); // "; expects out A\n"
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Candidate diagnostics use `kind: "register-contracts-output-candidate"` and `severity: "info"`.
|
|
237
|
-
The `autoFixable` flag distinguishes direct continuation reads that `--fix` may
|
|
238
|
-
confirm automatically from cases that need programmer review. Code actions are
|
|
239
|
-
intentionally simple text insertions: insert the supplied newline-terminated
|
|
240
|
-
`text` at column 1 of the supplied `line`, so the hint is inserted above the call
|
|
241
|
-
instruction. This keeps CLI, editor light-bulbs, and future LSP integrations
|
|
242
|
-
aligned around one inference source.
|
|
243
|
-
|
|
244
|
-
## Layer C: Full Compile
|
|
245
|
-
|
|
246
|
-
Use `compile()` when you want assembly plus output artifacts.
|
|
247
|
-
|
|
248
|
-
```ts
|
|
249
|
-
import { compile, defaultFormatWriters } from '@jhlagado/azm/compile';
|
|
250
|
-
|
|
251
|
-
const result = await compile(
|
|
252
|
-
'/abs/path/to/main.asm',
|
|
253
|
-
{ outputType: 'hex', emitAsm80: true },
|
|
254
|
-
{ formats: defaultFormatWriters },
|
|
255
|
-
);
|
|
256
|
-
```
|
|
257
|
-
|
|
258
|
-
**`emitAsm80` caveat:** Lowered `.z80` emission is gated but not universal.
|
|
259
|
-
Unsupported instructions or operand forms throw `UnsupportedAsm80LoweringError`,
|
|
260
|
-
surfaced as `AZMN_ASM80`. When assembly already succeeded, `compile()` still
|
|
261
|
-
returns bin/hex/d8 artifacts alongside the asm80 error. Run
|
|
262
|
-
`npm run check:asm80-coverage` on your sources before relying on lowered output.
|
|
263
|
-
|
|
264
|
-
The compiler accepts flat `.asm` / `.z80` source, retained AZM assembler
|
|
265
|
-
features, and the same output writers used by the CLI. External register contracts
|
|
266
|
-
interfaces are `.asmi` metadata files, not compile entry files.
|
|
267
|
-
|
|
268
|
-
Retained AZM features include the ASM80 baseline, compact AZMDoc `;!` comments,
|
|
269
|
-
directive aliases, AST `op` declarations, enums, `.type` / `.union`, `sizeof`,
|
|
270
|
-
`offset`, constant-only layout casts, and scalar type shorthand in `.ds` and
|
|
271
|
-
`.field`.
|
|
272
|
-
|
|
273
|
-
High-level ZAX constructs such as modules/imports, `func`, locals, formal args,
|
|
274
|
-
typed assignment/storage lowering, named sections, structured control, and
|
|
275
|
-
generated frames are outside this API contract for AZM source.
|
|
276
|
-
|
|
277
|
-
## Public Types
|
|
278
|
-
|
|
279
|
-
The public tooling surface includes:
|
|
280
|
-
|
|
281
|
-
- `Diagnostic`, `DiagnosticIds`, severity/id types
|
|
282
|
-
- `LoadedProgram`
|
|
283
|
-
- `AnalyzeProgramResult`, `LoadProgramResult`
|
|
284
|
-
- `RegisterContractsCandidateDiagnostic`, `RegisterContractsCodeAction`, `RegisterContractsOutputCandidate`
|
|
285
|
-
|
|
286
|
-
The public tooling contract is the package export surface, not deep internal
|
|
287
|
-
paths. Do not document retired internal modules as public API.
|
|
288
|
-
|
|
289
|
-
## Syntax Highlighting Example
|
|
290
|
-
|
|
291
|
-
Syntax colouring is an example consumer of the tooling API:
|
|
292
|
-
|
|
293
|
-
1. Call `loadProgram()` with the file path and optional unsaved buffer text.
|
|
294
|
-
2. Walk `loadedProgram.program.files[0].items` and inspect each item's `kind` and `span`.
|
|
295
|
-
3. Map those spans to TextMate scopes or semantic token kinds in the editor.
|
|
296
|
-
4. Fall back to regex/TextMate-only colouring if parsing fails or the editor needs a cheaper fast path.
|
|
297
|
-
|
|
298
|
-
The same spans and node kinds also support outline views, hover preparation, diagnostics, and navigation features.
|
|
299
|
-
|
|
300
|
-
## Migration From Deep Imports
|
|
301
|
-
|
|
302
|
-
Replace unstable imports such as:
|
|
303
|
-
|
|
304
|
-
```ts
|
|
305
|
-
import { loadProgram } from '@jhlagado/azm/dist/src/sourceLoader.js';
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
with:
|
|
309
|
-
|
|
310
|
-
```ts
|
|
311
|
-
import { loadProgram } from '@jhlagado/azm/tooling';
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
Likewise, prefer `@jhlagado/azm/compile` over `@jhlagado/azm/dist/src/compile.js`.
|
|
315
|
-
|
|
316
|
-
## Semver Policy
|
|
317
|
-
|
|
318
|
-
- Patch: bug fixes that preserve the intent of exported APIs and types
|
|
319
|
-
- Minor: additive exports, additive AST fields, new optional options
|
|
320
|
-
- Major: breaking changes to exported types, AST node shapes, or public function behavior
|