Commit graph

5 commits

Author SHA1 Message Date
Graeme Geldenhuys 5894411a35 chore(license): relicense from BSD-3-Clause to Apache 2.0 + Runtime Library Exception
Adopts the Swift/LLVM model: Apache License 2.0 with the Runtime Library
Exception text used verbatim by the Swift project. SPDX identifier:
Apache-2.0 WITH Swift-exception.

Apache 2.0 brings an explicit patent grant and patent-retaliation clause
that BSD-3 lacks. The Runtime Library Exception ensures binaries
produced by the Blaise compiler do not inherit attribution obligations
from the linked-in RTL.

* LICENSE — full Apache 2.0 + RLE text (replaces the deleted LICENCE).
* NOTICE — project header plus QBE attribution (MIT, vendored).
* docs/language-rationale.adoc — new Project Governance section
  capturing the decision, alternatives considered, and rationale.
* SPDX headers updated across all .pas, .pp, .inc, .c source files,
  build scripts, PasBuild plugins, and the Makefile.
* project.xml license field updated.
* tools/migrate_full.py HEADER template updated so generated
  self-hosting source carries the new licence.
2026-05-03 19:45:29 +01:00
Graeme Geldenhuys 2b8c071219 feat(opdf): replace recAnsiStr with recUtf8Str for Blaise strings
Blaise's single string type is UTF-8 with no code-page or element-size
fields — recAnsiStr is the wrong record type for it.  Emit recUtf8Str
(type 23) instead, with three signed offsets (RefCountOffset=-12,
LengthOffset=-8, CapacityOffset=-4) relative to the data pointer.

Changes in Blaise compiler:
- uDebugOPDF: EmitAnsiStr → EmitUtf8Str; REC_UTF8STR=23; canonical
  name 'Utf8String'; record size 12 bytes (no CodePage/ElementSize)
- CanonicalName: tyString now maps to 'Utf8String'

Test: TestOPDF_AnsiStr_Record updated to check '# recUtf8Str' and
'.ascii "Utf8String"'.
2026-05-02 12:31:47 +01:00
Graeme Geldenhuys 0e08dc3a53 feat(debug): OPDF Step 6c — recPointer, recArray, recSet, recProperty, recInterface, recConstant, recUnitDirectory
- recPointer: emitted for typed/untyped pointer fields; TargetTypeID links to
  base type; CanonicalName extended for tyStaticArray and tyOpenArray
- recArray: static arrays emit IsDynamic=0 with TArrayBound (LowerBound,
  UpperBound as Int64 quads); dynamic/open arrays emit IsDynamic=1 without bounds
- recSet: BaseTypeID references the base enum; SizeInBytes from RawSize
- recProperty: emitted after each recClass; field-backed uses numeric offset
  (patField), method-backed uses linker label (patMethod)
- recInterface: TypeID + ParentTypeID + zeroed GUID + method descriptors with
  ReturnTypeID and ParamCount per method
- recConstant: iterates program-block ConstDecls; ckOrd embeds 8-byte Int64,
  ckString embeds raw bytes
- recUnitDirectory: first record after header; RecordOffset computed via GAS
  label arithmetic (.Lopdf_unit0_start - .Lopdf_start); RecordCount patched at
  end; header Flags set to OPDF_FLAG_HAS_DIRECTORY = 1
- uSymbolTable: add Properties: TObjectList read property to TRecordTypeDesc
- 12 new tests; 37 OPDF tests total; 1072 compiler tests all passing
2026-05-01 23:37:07 +01:00
Graeme Geldenhuys 2e8eb590eb fix(debug): emit main program scope and fix PIE breakpoint addresses
- uDebugOPDF: add EmitFunctionScope_Main to emit recFunctionScope keyed on
  label 'main' for the program body, including per-line recLineInfo records
- uDebugOPDF: refactor EmitLineInfoForScope into EmitLineInfoForBlock so
  both procedure scopes and the main body share one implementation
- Blaise: pass -no-pie to gcc when linking a debug-opdf build so OPDF
  .quad addresses are absolute runtime addresses; PIE relocation produces
  relative offsets that the debugger cannot use without the load base
- Tests: three new assertions covering recFunctionScope, LowPC, and line
  info for the main program body (28 OPDF tests total, all passing)
2026-05-01 23:16:31 +01:00
Graeme Geldenhuys 914ef1289f feat(compiler): OPDF debug info emitter — Step 6a
New unit uDebugOPDF.pas with TOPDFEmitter:
- EmitHeader, EmitSection: writes .opdf ELF section with OPDF magic header
- EmitPrimitive, EmitEnum, EmitRecord, EmitClass, EmitAnsiStr: type records
- EmitGlobalVar: recGlobalVar with linker-resolved .quad address
- EmitFunctionScope: recFunctionScope with LowPC/HighPC labels
- EmitParameters: recParameter for each proc/func parameter
- EmitLocalVars: recLocalVar with RBP-relative stack offsets
- EmitLineInfoForScope: recLineInfo records from AST line numbers
  (uses function-start label as address; per-stmt addr needs QBE changes)
- CollectStmtLines: recursive AST walker for unique (line, col) pairs
- FNV-1a 32-bit TypeID allocation; ScopeID counter for scope linking
- DoEmit/PatchTotalRecords: idempotent emission with TotalRecords patching

Blaise.pas pipeline:
- --debug-opdf / -g flag: creates companion .opdf.s alongside output binary
- CompileToNative passes companion file to linker
- RunProcess: add poUsePipes so TProcess.Output is valid (pre-existing crash)

Tests: cp.test.opdf.pas with 22 tests covering all record types, fields,
addresses, and line info. Validated end-to-end with opdf_dump.

{$H+} is required for FPC compilation (string = AnsiString); not needed
when compiled by Blaise itself (Blaise defaults to AnsiString).
2026-05-01 22:53:56 +01:00