From 264716cb2c895c8e1e682ff920d946b64d6eefdb Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Mon, 26 Oct 2026 13:31:43 +0000 Subject: [PATCH] The tests, conform/, examples/ and the docs' examples held to report 2026-10.37 whole import SYSTEM where a program reaches memory other than through a variable, []const U8 where a string is only read, atomics on the variable; err tests keep their point, their messages moved by the added import line. make check passes as it is and with RAZ_STRICT=1. --- diff --git a/conform/err/ArrayConstAdr.raz b/conform/err/ArrayConstAdr.raz index 12170da..0428599 100644 --- a/conform/err/ArrayConstAdr.raz +++ b/conform/err/ArrayConstAdr.raz @@ -1,8 +1,9 @@ module ArrayConstAdr; +import SYSTEM; const P: [2]I64 = [1, 2]; proc main*; var p: ^[2]I64; begin - p := ADR(P); + p := SYSTEM.ADR(P); end; end ArrayConstAdr. diff --git a/conform/err/AtPAdr.raz b/conform/err/AtPAdr.raz index 1557a4e..016f626 100644 --- a/conform/err/AtPAdr.raz +++ b/conform/err/AtPAdr.raz @@ -1,7 +1,8 @@ module AtPAdr; +import SYSTEM; proc main*; var p: ^I64; begin - p := ADR(1); + p := SYSTEM.ADR(1); end; end AtPAdr. diff --git a/conform/err/AtomicI64.raz b/conform/err/AtomicI64.raz index 88e229d..b384362 100644 --- a/conform/err/AtomicI64.raz +++ b/conform/err/AtomicI64.raz @@ -2,6 +2,6 @@ proc main*; var n: I64; _ok: BOOL; begin - _ok := CAS(ADR(n), 0, 1); + _ok := CAS(n, 0, 1); end; end AtomicI64. diff --git a/conform/err/BytesVolatile.raz b/conform/err/BytesVolatile.raz index 7512025..fcb4117 100644 --- a/conform/err/BytesVolatile.raz +++ b/conform/err/BytesVolatile.raz @@ -1,4 +1,5 @@ module BytesVolatile; +import SYSTEM; type Regs = record ctrl: U32; status: U32; end; proc main*; var r: ^VOLATILE Regs; b: []U8; diff --git a/conform/err/ConstAdr.raz b/conform/err/ConstAdr.raz index 9b77ed3..2fb2fc8 100644 --- a/conform/err/ConstAdr.raz +++ b/conform/err/ConstAdr.raz @@ -1,8 +1,9 @@ module ConstAdr; +import SYSTEM; type R = record n: INT; end; proc f(const r: R): ^R; begin - return ADR(r); + return SYSTEM.ADR(r); end; proc main*; var r: R; diff --git a/conform/err/ExportAdr.raz b/conform/err/ExportAdr.raz index 1988584..e958efb 100644 --- a/conform/err/ExportAdr.raz +++ b/conform/err/ExportAdr.raz @@ -1,8 +1,9 @@ module ExportAdr; import Owner; +import SYSTEM; proc main*; var _p: ^INT; begin - _p := ADR(Owner.n); + _p := SYSTEM.ADR(Owner.n); end; end ExportAdr. diff --git a/conform/err/GenDotsRecord.raz b/conform/err/GenDotsRecord.raz index d2eaeb3..c8aeb82 100644 --- a/conform/err/GenDotsRecord.raz +++ b/conform/err/GenDotsRecord.raz @@ -1,5 +1,6 @@ module GenDotsRecord; import C; +import SYSTEM; type R = record a, b: I64; end; proc main*; var r: R; diff --git a/conform/err/PackedAddress.raz b/conform/err/PackedAddress.raz index d226bbb..dc4e424 100644 --- a/conform/err/PackedAddress.raz +++ b/conform/err/PackedAddress.raz @@ -1,4 +1,5 @@ module PackedAddress; +import SYSTEM; (* A field of a packed record may be misaligned: it has no address, and no volatile access *) type @@ -12,12 +13,12 @@ proc main*; var h: Header; p: ^U32; q: ^VOLATILE Header; k: ^U8; s: []U16; begin - p := ADR(h.len); + p := SYSTEM.ADR(h.len); put(h.len); s := h.vals[0..1]; - q := ADR(h); + q := SYSTEM.ADR(h); q^.len := 2; - k := ADR(h.tag); + k := SYSTEM.ADR(h.tag); h.len := 3; end; diff --git a/conform/err/PtrArray.raz b/conform/err/PtrArray.raz index 17a91e7..22f71dd 100644 --- a/conform/err/PtrArray.raz +++ b/conform/err/PtrArray.raz @@ -1,8 +1,9 @@ module PtrArray; +import SYSTEM; proc main*; var a: [4]I64; p: ^[4]I64; begin - p := ADR(a); + p := SYSTEM.ADR(a); p[1] := 0; end; end PtrArray. diff --git a/conform/err/PtrAsSlice.raz b/conform/err/PtrAsSlice.raz index 02fb5c7..e860450 100644 --- a/conform/err/PtrAsSlice.raz +++ b/conform/err/PtrAsSlice.raz @@ -1,7 +1,8 @@ module PtrAsSlice; +import SYSTEM; proc main*; var a: [4]U8; s: []U8; begin - s := PTR(a); + s := SYSTEM.PTR(a); end; end PtrAsSlice. diff --git a/conform/err/PtrElement.raz b/conform/err/PtrElement.raz index 586286f..20715ef 100644 --- a/conform/err/PtrElement.raz +++ b/conform/err/PtrElement.raz @@ -1,7 +1,8 @@ module PtrElement; +import SYSTEM; proc main*; var a: [4]U8; p: ^INT; begin - p := PTR(a); + p := SYSTEM.PTR(a); end; end PtrElement. diff --git a/conform/err/PtrExport.raz b/conform/err/PtrExport.raz index 84fe94a..710886e 100644 --- a/conform/err/PtrExport.raz +++ b/conform/err/PtrExport.raz @@ -1,8 +1,9 @@ module PtrExport; import Owner; +import SYSTEM; proc main*; var p: ^INT; begin - p := PTR(Owner.a); + p := SYSTEM.PTR(Owner.a); end; end PtrExport. diff --git a/conform/err/PtrInteger.raz b/conform/err/PtrInteger.raz index e56f3ec..0ce0f7d 100644 --- a/conform/err/PtrInteger.raz +++ b/conform/err/PtrInteger.raz @@ -1,8 +1,9 @@ module PtrInteger; +import SYSTEM; proc main*; var n: INT; p: ^INT; begin n := 1; - p := PTR(n); + p := SYSTEM.PTR(n); end; end PtrInteger. diff --git a/conform/err/PtrLiteral.raz b/conform/err/PtrLiteral.raz index 3507efd..a662120 100644 --- a/conform/err/PtrLiteral.raz +++ b/conform/err/PtrLiteral.raz @@ -1,7 +1,8 @@ module PtrLiteral; +import SYSTEM; proc main*; var p: ^U8; begin - p := PTR([]); + p := SYSTEM.PTR([]); end; end PtrLiteral. diff --git a/conform/err/PtrPacked.raz b/conform/err/PtrPacked.raz index 95235e2..50f6ab4 100644 --- a/conform/err/PtrPacked.raz +++ b/conform/err/PtrPacked.raz @@ -1,8 +1,9 @@ module PtrPacked; +import SYSTEM; type R = packed record tag: U8; words: [3]I32; end; proc main*; var r: R; p: ^I32; begin - p := PTR(r.words); + p := SYSTEM.PTR(r.words); end; end PtrPacked. diff --git a/conform/err/PtrPointer.raz b/conform/err/PtrPointer.raz index a9fb820..f931628 100644 --- a/conform/err/PtrPointer.raz +++ b/conform/err/PtrPointer.raz @@ -1,9 +1,10 @@ module PtrPointer; +import SYSTEM; proc main*; var a: [4]U8; p, q: ^U8; pa: ^[4]U8; begin - p := ADR(a[0]); pa := ADR(a); - q := PTR(p); - q := PTR(pa); + p := SYSTEM.ADR(a[0]); pa := SYSTEM.ADR(a); + q := SYSTEM.PTR(p); + q := SYSTEM.PTR(pa); end; end PtrPointer. diff --git a/conform/err/PtrView.raz b/conform/err/PtrView.raz index 6d187f9..3b5809b 100644 --- a/conform/err/PtrView.raz +++ b/conform/err/PtrView.raz @@ -1,8 +1,9 @@ module PtrView; +import SYSTEM; proc main*; var w: I64; p: ^U8; begin w := 0; - p := PTR(w.([8]U8)); + p := SYSTEM.PTR(w.([8]U8)); end; end PtrView. diff --git a/conform/err/PtrVolatile.raz b/conform/err/PtrVolatile.raz index a8cc3ac..38b3328 100644 --- a/conform/err/PtrVolatile.raz +++ b/conform/err/PtrVolatile.raz @@ -1,9 +1,10 @@ module PtrVolatile; +import SYSTEM; var regs: [4]U32; proc main*; var v: ^VOLATILE [4]U32; p: ^U32; begin - v := ADR(regs); - p := PTR(v^); + v := SYSTEM.ADR(regs); + p := SYSTEM.PTR(v^); end; end PtrVolatile. diff --git a/conform/err/SliceLiteralPart.raz b/conform/err/SliceLiteralPart.raz index c93e567..2dbf296 100644 --- a/conform/err/SliceLiteralPart.raz +++ b/conform/err/SliceLiteralPart.raz @@ -1,3 +1,3 @@ module SliceLiteralPart; -const Rows: [][]INT = [[1, 2], 3]; +const Rows: []const []const INT = [[1, 2], 3]; end SliceLiteralPart. diff --git a/conform/err/SliceLiteralRecord.raz b/conform/err/SliceLiteralRecord.raz index dff9834..3dff42d 100644 --- a/conform/err/SliceLiteralRecord.raz +++ b/conform/err/SliceLiteralRecord.raz @@ -1,4 +1,4 @@ module SliceLiteralRecord; -type Rule = record name: []U8; keys: []INT; end; +type Rule = record name: []const U8; keys: []const INT; end; const Rules: [1]Rule = [{name: "up", keys: [[1]]}]; end SliceLiteralRecord. diff --git a/conform/err/StmtVarOrProc.raz b/conform/err/StmtVarOrProc.raz index af58774..14b1ae9 100644 --- a/conform/err/StmtVarOrProc.raz +++ b/conform/err/StmtVarOrProc.raz @@ -1,3 +1,4 @@ module StmtVarOrProc; +import SYSTEM; extern 5; end StmtVarOrProc. diff --git a/conform/err/ViewAdr.raz b/conform/err/ViewAdr.raz index e7a0dfb..0ab58da 100644 --- a/conform/err/ViewAdr.raz +++ b/conform/err/ViewAdr.raz @@ -1,7 +1,8 @@ module ViewAdr; +import SYSTEM; var mem: [16]U8; p: ^I64; proc main*; begin - p := ADR(mem[0].(I64)); + p := SYSTEM.ADR(mem[0].(I64)); end; end ViewAdr. diff --git a/conform/err/Volatile.raz b/conform/err/Volatile.raz index f57aa24..67fdaec 100644 --- a/conform/err/Volatile.raz +++ b/conform/err/Volatile.raz @@ -1,8 +1,9 @@ module Volatile; +import SYSTEM; proc main*; var x: I64; p: ^VOLATILE I64; q: ^I64; begin - p := ADR(x); + p := SYSTEM.ADR(x); q := p; end; end Volatile. diff --git a/conform/run/Args.raz b/conform/run/Args.raz index a642652..b229159 100644 --- a/conform/run/Args.raz +++ b/conform/run/Args.raz @@ -1,10 +1,11 @@ module Args; import Out; +import SYSTEM; proc main*: INT; var i, n: INT; a: ^^U8; s: ^U8; begin - a := ARGV(); + a := SYSTEM.ARGV(); for i := 1 to ARGC() - 1 do s := a[i]; n := 0; diff --git a/conform/run/Arith.raz b/conform/run/Arith.raz index a0080dc..535996c 100644 --- a/conform/run/Arith.raz +++ b/conform/run/Arith.raz @@ -8,12 +8,12 @@ var g: I64; -proc show(s: []U8; n: I64); +proc show(s: []const U8; n: I64); begin Out.str(s); Out.str(" "); Out.int(n); Out.ln; end; -proc showb(s: []U8; t: BOOL); +proc showb(s: []const U8; t: BOOL); begin if t then show(s, 1); else show(s, 0); end; end; diff --git a/conform/run/ArrayConst.raz b/conform/run/ArrayConst.raz index 56fcda0..9a94bd2 100644 --- a/conform/run/ArrayConst.raz +++ b/conform/run/ArrayConst.raz @@ -13,7 +13,7 @@ Mixes: [2]set of Color = [{red, blue}, {}]; Neg: [3]I16 = [-1, -32768, 32767]; -proc sum(a: []I64): I64; +proc sum(a: []const I64): I64; var s: I64; i: INT; begin for i := 0 to LEN(a) - 1 do s := s + a[i]; end; diff --git a/conform/run/ArrayConstLen.raz b/conform/run/ArrayConstLen.raz index ee0e492..7e2ba57 100644 --- a/conform/run/ArrayConstLen.raz +++ b/conform/run/ArrayConstLen.raz @@ -1,17 +1,17 @@ module ArrayConstLen; import Out, Widths; -type Rule = record class: []U8; tag: INT; end; +type Rule = record class: []const U8; tag: INT; end; const - Primes: []I64 = [2, 3, 5, 7, 11]; - Rules: []Rule = [{class: "firefox", tag: 2}, {class: "mpv", tag: 3}]; - Names: [][]U8 = ["one", "two", "three"]; + Primes: []const I64 = [2, 3, 5, 7, 11]; + Rules: []const Rule = [{class: "firefox", tag: 2}, {class: "mpv", tag: 3}]; + Names: []const []const U8 = ["one", "two", "three"]; Count = LEN(Primes); (* a constant *) var buf: [Count]I64; -proc sum(a: []I64): I64; +proc sum(a: []const I64): I64; var s: I64; i: INT; begin for i := 0 to LEN(a) - 1 do s := s + a[i]; end; @@ -28,7 +28,7 @@ end; proc main*; -const Local: []U8 = [1, 2, 3, 4]; +const Local: []const U8 = [1, 2, 3, 4]; var i: INT; begin Out.int(LEN(Primes)); Out.str(" "); Out.int(sum(Primes)); Out.str(" "); diff --git a/conform/run/ArrayEq.raz b/conform/run/ArrayEq.raz index 3371d23..0df7e5e 100644 --- a/conform/run/ArrayEq.raz +++ b/conform/run/ArrayEq.raz @@ -1,5 +1,6 @@ module ArrayEq; import Out; +import SYSTEM; type Colour = (red, green, blue); @@ -30,8 +31,8 @@ say(f[0..1] = f[2..3]); say(f[0..1] = [true, false]); m := [{red}, {green, blue}]; n := m; say(m = n); n[1] := {blue}; say(m = n); - p := [ADR(x), nil]; q := p; - say(p = q); q[1] := ADR(x); say(p = q); + p := [SYSTEM.ADR(x), nil]; q := p; + say(p = q); q[1] := SYSTEM.ADR(x); say(p = q); t := [104, 101, 108, 108, 111]; say(t = "hello"); say("hello" = t[0..5]); say("hell" = t[0..4]); say("help" # t[0..4]); say("" = t[0..0]); diff --git a/conform/run/BytesOf.raz b/conform/run/BytesOf.raz index 3edb05b..ba71420 100644 --- a/conform/run/BytesOf.raz +++ b/conform/run/BytesOf.raz @@ -6,6 +6,7 @@ with a view of the same place, which is the target's order too. *) module BytesOf; import Out; +import SYSTEM; type Header = record magic: U32; count: U16; flags: U8; end; @@ -62,7 +63,7 @@ Out.int(LEN(BYTES(none))); Out.str(" "); Out.int(LEN(BYTES(g[2..2]))); Out.ln; Out.int(LEN(gBytes())); Out.str(" "); Out.int(I64(gBytes()[4].(I32))); Out.ln; - p := ADR(h); + p := SYSTEM.ADR(h); n := 0; for i := 0 to OFFSET(Header, flags) do (* not the padding after *) INC(n, I32(BYTES(p^)[i])); diff --git a/conform/run/CallArrayKept.raz b/conform/run/CallArrayKept.raz index 6d944aa..222d83a 100644 --- a/conform/run/CallArrayKept.raz +++ b/conform/run/CallArrayKept.raz @@ -23,13 +23,13 @@ end; (* The array in r, as a slice *) -proc bytes(const r: R): []U8; +proc bytes(const r: R): []const U8; begin return r.a[0..8]; end; proc main*; -var s, t, u, v: []U8; i: INT; +var s, t, u, v: []const U8; i: INT; begin s := name('a')[0..8]; t := name('b')[0..8]; diff --git a/conform/run/ConstParam.raz b/conform/run/ConstParam.raz index 0cb42a7..b0d2aa7 100644 --- a/conform/run/ConstParam.raz +++ b/conform/run/ConstParam.raz @@ -5,7 +5,7 @@ Big = record a: [100]INT; name: []U8; n: INT; end; Shape = variant circle(r: INT); rect(w, h: INT); end; -const Ten: Big = {n: 10, name: "ten"}; +const Ten: Big = {n: 10}; var g: Big; @@ -17,7 +17,7 @@ return s; end; -proc first(const s: []U8): U8; +proc first(const s: []const U8): U8; begin return s[0]; end; diff --git a/conform/run/ConstParamSlice.raz b/conform/run/ConstParamSlice.raz index ad56d2f..061dd4f 100644 --- a/conform/run/ConstParamSlice.raz +++ b/conform/run/ConstParamSlice.raz @@ -8,12 +8,12 @@ var line: Line; -proc used(const l: Line): []U8; +proc used(const l: Line): []const U8; begin return l.text[0..l.len]; end; -proc make(s: []U8): Line; +proc make(s: []const U8): Line; var l: Line; begin COPY(l.text, s); @@ -22,7 +22,7 @@ end; proc main*; -var s: []U8; +var s: []const U8; begin line := make("hello"); s := used(line); diff --git a/conform/run/ConstSlice.raz b/conform/run/ConstSlice.raz index 7aec74e..fd820b8 100644 --- a/conform/run/ConstSlice.raz +++ b/conform/run/ConstSlice.raz @@ -24,7 +24,7 @@ end; proc main*; -var a: [5]U8; w: []U8; r, b: []const U8; shapes: [2]Shape; cs: []const Shape; +var a: [5]U8; w: []const U8; r, b: []const U8; shapes: [2]Shape; cs: []const Shape; begin a := "hello"; w := a; diff --git a/conform/run/Continue.raz b/conform/run/Continue.raz index 3f2f184..4699246 100644 --- a/conform/run/Continue.raz +++ b/conform/run/Continue.raz @@ -6,7 +6,7 @@ import Out; proc main*; -var i, j, n: INT; t: []U8; +var i, j, n: INT; t: []const U8; begin for i := 1 to 10 do if i mod 3 = 0 then continue; end; (* a lone continue *) diff --git a/conform/run/CopyOverlap.raz b/conform/run/CopyOverlap.raz index d8cd600..ffe8834 100644 --- a/conform/run/CopyOverlap.raz +++ b/conform/run/CopyOverlap.raz @@ -11,7 +11,7 @@ cases, wrong: INT; (* Says where a copy came out wrong. *) -proc fail(kind: []U8; d, s, n: INT); +proc fail(kind: []const U8; d, s, n: INT); begin Out.str(kind); Out.str(" wrong: d "); Out.int(I64(d)); Out.str(" s "); Out.int(I64(s)); Out.str(" n "); Out.int(I64(n)); Out.ln; diff --git a/conform/run/Defers.raz b/conform/run/Defers.raz index 388406b..77d00e5 100644 --- a/conform/run/Defers.raz +++ b/conform/run/Defers.raz @@ -5,12 +5,12 @@ var depth: I64; -proc enter(s: []U8); +proc enter(s: []const U8); begin Out.str(s); INC(depth); end; -proc leave(s: []U8); +proc leave(s: []const U8); begin Out.str(s); DEC(depth); end; diff --git a/conform/run/EmptySliceConst.raz b/conform/run/EmptySliceConst.raz index cdebf65..7ea8e17 100644 --- a/conform/run/EmptySliceConst.raz +++ b/conform/run/EmptySliceConst.raz @@ -4,16 +4,16 @@ (* A constant typed []T whose literal is [] is the empty slice, used as a slice is: as a table with nothing in it, or a part of a constant *) -type Prop = record name: []U8; runs: [][2]I32; end; +type Prop = record name: []const U8; runs: []const [2]I32; end; const - None: []I64 = []; - Wide: [][2]I32 = [[1100H, 115FH]]; - Narrow: [][2]I32 = []; - Props: []Prop = [{name: "wide", runs: Wide}, {name: "narrow", runs: Narrow}, {name: "none", runs: []}, + None: []const I64 = []; + Wide: []const [2]I32 = [[1100H, 115FH]]; + Narrow: []const [2]I32 = []; + Props: []const Prop = [{name: "wide", runs: Wide}, {name: "narrow", runs: Narrow}, {name: "none", runs: []}, {name: "Widths.Wide", runs: Widths.Wide}, {name: "Widths.Narrow", runs: Widths.Narrow}]; -proc sum(a: []I64): I64; +proc sum(a: []const I64): I64; var s: I64; i: INT; begin for i := 0 to LEN(a) - 1 do s := s + a[i]; end; @@ -21,7 +21,7 @@ end; proc main*; -var s: []I64; i: INT; +var s: []const I64; i: INT; begin s := None; Out.int(LEN(None)); Out.str(" "); Out.int(sum(None)); Out.str(" "); Out.int(LEN(s)); Out.str(" "); diff --git a/conform/run/ErrorValues.raz b/conform/run/ErrorValues.raz index 7f0fdfd..98b9e99 100644 --- a/conform/run/ErrorValues.raz +++ b/conform/run/ErrorValues.raz @@ -8,7 +8,7 @@ One: ERROR = "same"; Two: ERROR = "same"; -proc yes(name: []U8; b: BOOL); +proc yes(name: []const U8; b: BOOL); begin Out.str(name); if b then Out.str(" true"); else Out.str(" false"); end; diff --git a/conform/run/Escapes.raz b/conform/run/Escapes.raz index b26a910..d43f783 100644 --- a/conform/run/Escapes.raz +++ b/conform/run/Escapes.raz @@ -3,7 +3,7 @@ import Out; proc main*; -var s: []U8; i: INT; +var s: []const U8; i: INT; begin s := "\xaF\xAF\u{1f600}\u{1F600}\x41\u{e9}"; for i := 0 to LEN(s) - 1 do diff --git a/conform/run/Fill.raz b/conform/run/Fill.raz index ce03928..192fb03 100644 --- a/conform/run/Fill.raz +++ b/conform/run/Fill.raz @@ -3,6 +3,7 @@ U64s := Filled(U64), I8s := Filled(I8), Bools := Filled(BOOL), Ptrs := Filled(^I64), Sets := Filled(FillKinds.Colours), Colours := Filled(FillKinds.Colour), Rgbs := Filled(FillKinds.Rgb), Spans := Filled(FillKinds.Span); +import SYSTEM; var calls: INT; (* how many times next has been called *) @@ -47,7 +48,7 @@ U64s.check("U64", 0123456789ABCDEFH, 1); I8s.check("I8", -2, 3); Bools.check("BOOL", true, false); - Ptrs.check("pointer", ADR(x), ADR(y)); + Ptrs.check("pointer", SYSTEM.ADR(x), SYSTEM.ADR(y)); Sets.check("set", {FillKinds.red, FillKinds.blue}, {FillKinds.green}); Colours.check("enumeration", FillKinds.blue, FillKinds.green); Rgbs.check("3-byte record", {r: 1, g: 2, b: 3}, {r: 9, g: 9, b: 9}); @@ -74,13 +75,13 @@ FILL(s[1..8], 0); Out.int(sum(a)); Out.char(' '); for i := 0 to 99 do big[i] := U64(i); end; - p := ADR(big); + p := SYSTEM.ADR(big); FILL(p^[10..100], 0); t := 0; for i := 0 to 99 do INC(t, I64(big[i])); end; Out.int(t); Out.char(' '); FILL(p^, 0); - FILL(ps, ADR(x)); + FILL(ps, SYSTEM.ADR(x)); FILL(ps, nil); if (big[1] = 0) and (ps[2] = nil) then Out.str("zero"); end; Out.ln; diff --git a/conform/run/FirstUse.raz b/conform/run/FirstUse.raz index 81f5f50..047577d 100644 --- a/conform/run/FirstUse.raz +++ b/conform/run/FirstUse.raz @@ -1,15 +1,16 @@ module FirstUse; import Out, Str, Table := Table([]const U8, Colour, Str.hash, Str.eq), Ints := Pile(I64), More := Pile(I64), Never := Loud(I64), Ones := Loud(U8); +import SYSTEM; type Colour = (red, green, blue); var names: Table.Table; (* Table is made here, after Colour *) -proc show(k: []U8); +proc show(k: []const U8); var c: Colour; found: BOOL; begin - c, found := Table.get(ADR(names), k); + c, found := Table.get(SYSTEM.ADR(names), k); Out.str(k); if not found then Out.str(" -"); elsif c = red then Out.str(" red"); else Out.str(" not red"); end; Out.ln; @@ -28,6 +29,6 @@ end; begin - _ := Table.put(ADR(names), "rose", red); - _ := Table.put(ADR(names), "sky", blue); + _ := Table.put(SYSTEM.ADR(names), "rose", red); + _ := Table.put(SYSTEM.ADR(names), "sky", blue); end FirstUse. diff --git a/conform/run/Generic.raz b/conform/run/Generic.raz index 7503b71..bcee0b3 100644 --- a/conform/run/Generic.raz +++ b/conform/run/Generic.raz @@ -1,5 +1,6 @@ module Generic; -import Out, Stack, Ints := Pile(I64), More := Pile(I64), Strs := Pile([]U8); +import Out, Stack, Ints := Pile(I64), More := Pile(I64), Strs := Pile([]const U8); +import SYSTEM; proc yes(b: BOOL); begin @@ -7,19 +8,19 @@ end; proc main*; -var l: Strs.Pile; v: I64; s: []U8; ok: BOOL; +var l: Strs.Pile; v: I64; s: []const U8; ok: BOOL; begin ok := Ints.push(Stack.p, 7); ok := More.push(Stack.p, 8); (* two imports, one instance: one pile *) Out.int(Stack.top()); Out.char(' '); Out.int(Stack.p^.len); Out.char(' '); yes(ok); Out.ln; v, ok := Ints.pop(Stack.p); Out.int(v); Out.char(' '); Out.int(Stack.p^.len); Out.ln; - ok := Strs.push(ADR(l), "b"); - ok := Strs.push(ADR(l), "a"); - s, ok := Strs.pop(ADR(l)); - Out.str(s); Out.str(Strs.top(ADR(l))); yes(ok); Out.ln; - s, ok := Strs.pop(ADR(l)); - s, ok := Strs.pop(ADR(l)); + ok := Strs.push(SYSTEM.ADR(l), "b"); + ok := Strs.push(SYSTEM.ADR(l), "a"); + s, ok := Strs.pop(SYSTEM.ADR(l)); + Out.str(s); Out.str(Strs.top(SYSTEM.ADR(l))); yes(ok); Out.ln; + s, ok := Strs.pop(SYSTEM.ADR(l)); + s, ok := Strs.pop(SYSTEM.ADR(l)); Out.char('['); Out.str(s); Out.str("] "); yes(ok); Out.ln; end; diff --git a/conform/run/Inline.raz b/conform/run/Inline.raz index 69996f7..4a7e787 100644 --- a/conform/run/Inline.raz +++ b/conform/run/Inline.raz @@ -73,7 +73,7 @@ return incr(n); end; -proc second(s: []U8): U8; +proc second(s: []const U8): U8; begin return s[1]; end; @@ -91,13 +91,13 @@ return (n # 0) and even(n - 1); end; -proc show(s: []U8; n: INT); +proc show(s: []const U8; n: INT); begin Out.str(s); Out.str(" "); Out.int(n); Out.ln; end; proc main*; -var i, n: INT; s: []U8; p: Pair; f: proc(a, b: INT): INT; c: U8; +var i, n: INT; s: []const U8; p: Pair; f: proc(a, b: INT): INT; c: U8; begin show("sub", sub(note(10), note(3))); show("order", trace[0] * 10 + trace[1]); diff --git a/conform/run/IntWiden.raz b/conform/run/IntWiden.raz index 0a452c3..7090773 100644 --- a/conform/run/IntWiden.raz +++ b/conform/run/IntWiden.raz @@ -27,14 +27,14 @@ return three(); end; -proc show(label: []U8; v: I64); +proc show(label: []const U8; v: I64); begin Out.str(label); Out.str(" "); Out.int(v); Out.str("\n"); end; proc main*; var - a, b, c, i: I64; n: INT; s: []U8; u: U64; w: UINT; + a, b, c, i: I64; n: INT; s: []const U8; u: U64; w: UINT; begin s := "hello"; n := -2; diff --git a/conform/run/JoinStr.raz b/conform/run/JoinStr.raz index ad3daf4..f391c91 100644 --- a/conform/run/JoinStr.raz +++ b/conform/run/JoinStr.raz @@ -8,7 +8,7 @@ Word = ("sat" + " ") + "on"; proc main*; -var w: []U8; +var w: []const U8; begin Out.str(Line); Out.str(Both); Out.ln; diff --git a/conform/run/Kinds.raz b/conform/run/Kinds.raz index c5c6d47..f6cc15a 100644 --- a/conform/run/Kinds.raz +++ b/conform/run/Kinds.raz @@ -5,7 +5,7 @@ Color* = (red, green, blue, black); Colors* = set of Color; Cell = record ch: U8; attr: U8; fg: Color; end; - Point = record x, y: I64; name: []U8; end; + Point = record x, y: I64; name: []const U8; end; Line = record a, b: Point; end; var log: [8]U8; nlog: I64; @@ -25,7 +25,7 @@ Out.str(" "); end; -proc name(c: Color): []U8; +proc name(c: Color): []const U8; begin match c of | red: return "red"; diff --git a/conform/run/LaterCallback.raz b/conform/run/LaterCallback.raz index 9bc48e0..08f26fa 100644 --- a/conform/run/LaterCallback.raz +++ b/conform/run/LaterCallback.raz @@ -2,10 +2,11 @@ (* A procedure type's parameter or result may name a type declared later in its type section, however passed (report, 4 and 5.9). *) import Out; +import SYSTEM; type Lines = record - each: proc(var r: Lines; s: []U8); + each: proc(var r: Lines; s: []const U8); look: proc(const r: Lines): INT; copy: proc(r: Lines): Lines; at: proc(p: ^Lines): (INT, Lines); @@ -29,7 +30,7 @@ name: [8]U8; end; -proc count(var r: Lines; s: []U8); +proc count(var r: Lines; s: []const U8); begin INC(r.n, LEN(s)); end; @@ -76,7 +77,7 @@ Out.int(r.look(r)); Out.ln; c := r.copy(r); Out.int(c.n); Out.char(' '); Out.int(r.n); Out.ln; - k, c := r.at(ADR(r)); + k, c := r.at(SYSTEM.ADR(r)); Out.int(k); Out.char(' '); Out.int(c.n); Out.ln; pi.hit := hit; po.back := back; Out.int(pi.hit(po)); Out.char(' '); Out.int(pi.hit(po)); Out.ln; diff --git a/conform/run/MatchInt.raz b/conform/run/MatchInt.raz index e901b88..e8fdfe6 100644 --- a/conform/run/MatchInt.raz +++ b/conform/run/MatchInt.raz @@ -38,7 +38,7 @@ end; proc main*; -var i: INT; s: []U8; +var i: INT; s: []const U8; begin s := "a1 _Z\t9?"; for i := 0 to LEN(s) - 1 do Out.int(kind(s[i])); end; diff --git a/conform/run/MatchStr.raz b/conform/run/MatchStr.raz index 66411b7..c200250 100644 --- a/conform/run/MatchStr.raz +++ b/conform/run/MatchStr.raz @@ -6,7 +6,7 @@ type Op = (none, add, sub, mul); -proc op(word: []U8): Op; +proc op(word: []const U8): Op; begin match word of | "add", Plus, `+`: return add; @@ -18,7 +18,7 @@ end; proc main*; -var a: [3]U8; s: []U8; +var a: [3]U8; s: []const U8; begin Out.int(I64(op("add"))); Out.int(I64(op("plus"))); Out.int(I64(op("+"))); Out.int(I64(op("sub"))); Out.int(I64(op("-"))); Out.int(I64(op("mul"))); diff --git a/conform/run/Offsets.raz b/conform/run/Offsets.raz index 2545009..5ee374d 100644 --- a/conform/run/Offsets.raz +++ b/conform/run/Offsets.raz @@ -20,7 +20,7 @@ Typed = U8(OFFSET(Mixed, e) + 250); (* 24 + 250 wraps to 18 *) (* name, then the offset and the size of a field *) -proc row(name: []U8; off, size: INT); +proc row(name: []const U8; off, size: INT); begin Out.str(name); Out.str(" "); Out.int(off); Out.str(" "); Out.int(size); Out.ln; end; diff --git a/conform/run/PackedFields.raz b/conform/run/PackedFields.raz index 9e8463a..f62f43f 100644 --- a/conform/run/PackedFields.raz +++ b/conform/run/PackedFields.raz @@ -1,6 +1,7 @@ module PackedFields; (* A packed record's fields are read and written wherever they sit *) import Out; +import SYSTEM; type Header = packed record kind: U8; len: U32; big: I64; tag: U8; end; @@ -16,7 +17,7 @@ Out.hex(U64(g.len), 8); Out.str(" "); Out.int(g.big); Out.str(" "); Out.int(I64(g.tag)); Out.ln; - b := ADR(g.kind); + b := SYSTEM.ADR(g.kind); Out.int(I64(b[1])); Out.ln; end; diff --git a/conform/run/Pow2.raz b/conform/run/Pow2.raz index ff907b4..4027279 100644 --- a/conform/run/Pow2.raz +++ b/conform/run/Pow2.raz @@ -5,7 +5,7 @@ var bad: I64; -proc check(s: []U8; x, got, want: I64); +proc check(s: []const U8; x, got, want: I64); begin if got # want then Out.str(s); Out.str(" "); Out.int(x); Out.str(": "); diff --git a/conform/run/Ptr.raz b/conform/run/Ptr.raz index 7e6476a..b9af9ad 100644 --- a/conform/run/Ptr.raz +++ b/conform/run/Ptr.raz @@ -1,8 +1,9 @@ -(* PTR(s), the address a slice starts at (report section 6.8): ADR(s[0]) +(* SYSTEM.PTR(s), the address a slice starts at (report section 6.8): SYSTEM.ADR(s[0]) when s isn't empty; nil for a slice as it starts and for []; and, of an array, the address of its first element. *) module Ptr; import Out; +import SYSTEM; type Value = record n: INT; p: ^U8; end; @@ -13,7 +14,7 @@ (* a slice as a pointer and a length, with no test for the empty one *) proc valueOf(s: []U8): Value; begin - return {n: LEN(s), p: PTR(s)}; + return {n: LEN(s), p: SYSTEM.PTR(s)}; end; (* and back: empty when n is 0, whatever p is *) @@ -29,7 +30,7 @@ proc first(const a: [3]I64): ^I64; begin - return PTR(a); + return SYSTEM.PTR(a); end; proc main*; @@ -41,24 +42,24 @@ s := a[0..6]; Out.str(bytes(valueOf(s))); Out.str(bytes(valueOf(s[1..3]))); Out.str("\n"); - if PTR(s) = ADR(s[0]) then Out.str("a slice: ADR(s[0])\n"); end; - if PTR(a) = ADR(a[0]) then Out.str("an array: ADR(a[0])\n"); end; - if PTR(s[2..5]) = ADR(a[2]) then Out.str("a slice of it: ADR(a[2])\n"); end; - if PTR(same(s)) = ADR(a[0]) then Out.str("a call's slice\n"); end; + if SYSTEM.PTR(s) = SYSTEM.ADR(s[0]) then Out.str("a slice: ADR(s[0])\n"); end; + if SYSTEM.PTR(a) = SYSTEM.ADR(a[0]) then Out.str("an array: ADR(a[0])\n"); end; + if SYSTEM.PTR(s[2..5]) = SYSTEM.ADR(a[2]) then Out.str("a slice of it: ADR(a[2])\n"); end; + if SYSTEM.PTR(same(s)) = SYSTEM.ADR(a[0]) then Out.str("a call's slice\n"); end; v := valueOf(none); if v.p = nil then Out.str("a slice as it starts: nil\n"); end; v := valueOf([]); if v.p = nil then Out.str("[]: nil\n"); end; Out.int(LEN(bytes(v))); Out.str(" bytes back\n"); kept := s[3..5]; - Out.str(PTR(kept)[0..2]); Out.str("\n"); + Out.str(SYSTEM.PTR(kept)[0..2]); Out.str("\n"); w := [10, 20, 30]; - if first(w) = ADR(w[0]) then Out.str("a const parameter: in place\n"); end; + if first(w) = SYSTEM.ADR(w[0]) then Out.str("a const parameter: in place\n"); end; ws := w[0..3]; - q := PTR(ws); + q := SYSTEM.PTR(ws); for i := 0 to 2 do Out.int(q[i]); Out.str(" "); end; Out.str("\n"); - d := PTR(Digits); + d := SYSTEM.PTR(Digits); Out.int(d[3]); Out.str("\n"); end; diff --git a/conform/run/PtrOrder.raz b/conform/run/PtrOrder.raz index 9e93eb3..188e73b 100644 --- a/conform/run/PtrOrder.raz +++ b/conform/run/PtrOrder.raz @@ -1,6 +1,7 @@ (* Pointers compare with = # < <= > >=, as unsigned addresses. *) module PtrOrder; import Out; +import SYSTEM; proc yes(b: BOOL); begin @@ -10,10 +11,10 @@ proc main*; var a: [3]I64; p, q: ^I64; begin - p := ADR(a[0]); - q := ADR(a[2]); + p := SYSTEM.ADR(a[0]); + q := SYSTEM.ADR(a[2]); yes(p < q); yes(p <= q); yes(p > q); yes(p >= q); yes(p = q); yes(p # q); - q := ADR(a[0]); + q := SYSTEM.ADR(a[0]); yes(p <= q); yes(p >= q); yes(p < q); Out.ln; end; diff --git a/conform/run/RawStrings.raz b/conform/run/RawStrings.raz index 9621203..71765df 100644 --- a/conform/run/RawStrings.raz +++ b/conform/run/RawStrings.raz @@ -9,9 +9,9 @@ -v say what is done `; Joined = `back` + "`" + `quote`; - Names: [2][]U8 = [`one`, `two`]; + Names: [2][]const U8 = [`one`, `two`]; -proc show(s: []U8); +proc show(s: []const U8); begin Out.int(LEN(s)); Out.str(" |"); Out.str(s); Out.str("|\n"); end; diff --git a/conform/run/RealRead.raz b/conform/run/RealRead.raz index b971f50..a1e0540 100644 --- a/conform/run/RealRead.raz +++ b/conform/run/RealRead.raz @@ -2,11 +2,12 @@ bits, for numbers a reader of decimals easily gets one off. *) module RealRead; import Out; +import SYSTEM; proc bits(x: F64): U64; var p: ^U64; begin - p := ^U64(ADR(x)); + p := ^U64(SYSTEM.ADR(x)); return p^; end; diff --git a/conform/run/RecordConst.raz b/conform/run/RecordConst.raz index 9e4bdda..15c90ee 100644 --- a/conform/run/RecordConst.raz +++ b/conform/run/RecordConst.raz @@ -2,12 +2,12 @@ import Out; type Act = (quit, focus, spawn); - Rule = record cls: []U8; tag: INT; float: BOOL; end; + Rule = record cls: []const U8; tag: INT; float: BOOL; end; Key = record mods: U8; sym: U32; act: Act; arg: [8]U8; run: proc(n: INT); end; const Rules: [3]Rule = [{cls: "firefox", tag: 2}, {cls: "mpv", float: true}, {}]; Nums: [3]I64 = [10, 20, 30]; - Lists: [2][]I64 = [Nums, Nums]; + Lists: [2][]const I64 = [Nums, Nums]; Home: Rule = {cls: "home", tag: 7}; Grid: [2][2]U8 = [[1, 2], [3, 4]]; proc hello(n: INT); diff --git a/conform/run/Sameness.raz b/conform/run/Sameness.raz index bb683fb..87bb7d5 100644 --- a/conform/run/Sameness.raz +++ b/conform/run/Sameness.raz @@ -3,6 +3,7 @@ anonymous one. *) module Sameness; import Out; +import SYSTEM; type Node = record v: I64; end; @@ -14,11 +15,11 @@ var r: Node; p1: P1; p2: P2; n: ^Node; q: NodePtr; begin r.v := 7; - n := ADR(r); + n := SYSTEM.ADR(r); p1 := n; n := p1; p2 := n; - q := ADR(r); + q := SYSTEM.ADR(r); Out.int(p2^.v + q^.v); Out.ln; end; diff --git a/conform/run/Sizes.raz b/conform/run/Sizes.raz index 8c18067..35f3361 100644 --- a/conform/run/Sizes.raz +++ b/conform/run/Sizes.raz @@ -5,7 +5,7 @@ type Empty = record end; -proc line(name: []U8; b: BOOL); +proc line(name: []const U8; b: BOOL); begin Out.str(name); if b then Out.str(" yes"); else Out.str(" NO"); end; @@ -21,7 +21,7 @@ line("UINT is an address", SIZE(UINT) = SIZE(^U8)); line("procedure is an address", SIZE(proc) = SIZE(^U8)); line("ERROR is an address", SIZE(ERROR) = SIZE(^U8)); - line("slice is two", SIZE([]U8) = 2 * SIZE(^U8)); + line("slice is two", SIZE([]const U8) = 2 * SIZE(^U8)); line("empty record", SIZE(Empty) = 0); end; diff --git a/conform/run/SliceLiteralConst.raz b/conform/run/SliceLiteralConst.raz index 747772e..e327449 100644 --- a/conform/run/SliceLiteralConst.raz +++ b/conform/run/SliceLiteralConst.raz @@ -5,17 +5,17 @@ import Out; type - Rule = record name: []U8; keys: []INT; end; - Shape = variant dot; poly(xs: []INT); end; + Rule = record name: []const U8; keys: []const INT; end; + Shape = variant dot; poly(xs: []const INT); end; const - Rows: [][]INT = [[1, 2], [3], []]; - Deep: [][][]U8 = [[['a', 'b'], "cd"], [], [['e']]]; - Rules: []Rule = [{name: "up", keys: [107, 65]}, {name: "none", keys: []}]; + Rows: []const []const INT = [[1, 2], [3], []]; + Deep: []const []const []const U8 = [[['a', 'b'], "cd"], [], [['e']]]; + Rules: []const Rule = [{name: "up", keys: [107, 65]}, {name: "none", keys: []}]; Shapes: [2]Shape = [poly([1, 2, 3]), dot]; - Words: [][]U8 = [['h', 'i'], "there"]; + Words: []const []const U8 = [['h', 'i'], "there"]; -proc sum(xs: []INT): INT; +proc sum(xs: []const INT): INT; var i, s: INT; begin s := 0; diff --git a/conform/run/SlicePtrBackwards.raz b/conform/run/SlicePtrBackwards.raz index 93f6ffa..89081e5 100644 --- a/conform/run/SlicePtrBackwards.raz +++ b/conform/run/SlicePtrBackwards.raz @@ -2,11 +2,12 @@ (* A slice of a pointer isn't checked against a length, but it can't run backwards *) import Out; +import SYSTEM; proc main*; var a: [8]U8; p: ^U8; hi: I64; begin - p := ADR(a[0]); + p := SYSTEM.ADR(a[0]); for hi := 4 to 0 by -2 do Out.int(LEN(p[2..hi])); Out.str(" "); diff --git a/conform/run/SmallWiden.raz b/conform/run/SmallWiden.raz index f577a91..ad95983 100644 --- a/conform/run/SmallWiden.raz +++ b/conform/run/SmallWiden.raz @@ -28,7 +28,7 @@ end; proc main*; -var s: []U8; a, b: U8; c: I8; w: U16; n, i: INT; u: UINT; +var s: []const U8; a, b: U8; c: I8; w: U16; n, i: INT; u: UINT; begin s := "7319"; for i := 0 to LEN(s) - 1 do n := n * 10 + s[i] - '0'; end; diff --git a/conform/run/Sorted.raz b/conform/run/Sorted.raz index 6190949..9929902 100644 --- a/conform/run/Sorted.raz +++ b/conform/run/Sorted.raz @@ -3,7 +3,7 @@ module Sorted; import Out, Rt, Ints := Order(I64, below), ByAge := Order(Person, younger); -type Person = record name: []U8; age: I64; end; +type Person = record name: []const U8; age: I64; end; proc below(a, b: I64): BOOL; begin diff --git a/conform/run/Strings.raz b/conform/run/Strings.raz index 80fa234..0871985 100644 --- a/conform/run/Strings.raz +++ b/conform/run/Strings.raz @@ -5,7 +5,7 @@ var buf: [8]U8; -proc count(xs: []I64): I64; +proc count(xs: []const I64): I64; var i: INT; s: I64; begin s := 0; @@ -14,7 +14,7 @@ end; proc main*; -var a: []U8; b: [5]U8; c: [3]I64; d: [][]U8; +var a: []const U8; b: [5]U8; c: [3]I64; d: [][]const U8; begin a := "hello"; if a = greeting then Out.str("eq "); end; diff --git a/conform/run/SystemInt.raz b/conform/run/SystemInt.raz index 7bdf9b1..18a681e 100644 --- a/conform/run/SystemInt.raz +++ b/conform/run/SystemInt.raz @@ -2,6 +2,7 @@ (* INT and UINT: what gives them, where they widen, shifts modulo the width, and another module's variables read but not changed *) import Out, Shared; +import SYSTEM; var cells: [10]I32; @@ -11,7 +12,7 @@ end; (* an INT returned as an I64 *) -proc len(s: []U8): I64; +proc len(s: []const U8): I64; begin return LEN(s); end; @@ -30,8 +31,8 @@ Out.int(i); Out.str(" "); Out.int(I64(b)); Out.str(" "); Out.int(len("abc")); Out.str(" "); Out.int(I64(w)); Out.ln; - p := ADR(cells[2]); - q := ADR(cells[9]); + p := SYSTEM.ADR(cells[2]); + q := SYSTEM.ADR(cells[9]); n := q - p; (* an INT *) u := UINT(q) - UINT(p); Out.int(n); Out.str(" "); Out.int(I64(u)); Out.str(" "); diff --git a/conform/run/Try.raz b/conform/run/Try.raz index d032ca8..7653285 100644 --- a/conform/run/Try.raz +++ b/conform/run/Try.raz @@ -141,7 +141,7 @@ return 0; end; -proc show(what: []U8; v: INT; e: ERROR); +proc show(what: []const U8; v: INT; e: ERROR); begin Out.str(what); Out.str(": "); Out.int(v); if e = nil then Out.str(" ok"); else Out.str(" "); Out.str(MSG(e)); end; diff --git a/conform/run/TwoWords.raz b/conform/run/TwoWords.raz index 4b5a514..3e4185d 100644 --- a/conform/run/TwoWords.raz +++ b/conform/run/TwoWords.raz @@ -4,6 +4,7 @@ on, through a procedure value, run off the end, and with a call in the second. *) import Out; +import SYSTEM; var log: INT; @@ -34,7 +35,7 @@ return nested(n); end; -proc tail(s: []U8; i: INT): []U8; +proc tail(s: []const U8; i: INT): []const U8; begin defer note; return s[i..LEN(s)]; @@ -60,7 +61,7 @@ _, v := nested(3); Out.int(v); Out.str(" "); Out.int(log); Out.ln; (* in order: the second result is the one left *) v, v := nested(4); Out.int(v); Out.ln; - pv := ADR(q); pv^, p := nested(5); Out.int(q); Out.str(" "); Out.int(p); Out.ln; + pv := SYSTEM.ADR(q); pv^, p := nested(5); Out.int(q); Out.str(" "); Out.int(p); Out.ln; (* three results, which come back in memory, some dropped *) _, p, q := three(1); Out.int(p); Out.str(" "); Out.int(q); Out.ln; p, _, _ := three(7); Out.int(p); Out.ln; diff --git a/conform/run/VariantConst.raz b/conform/run/VariantConst.raz index ef210ce..99a0683 100644 --- a/conform/run/VariantConst.raz +++ b/conform/run/VariantConst.raz @@ -2,7 +2,7 @@ import Out; type - Shape = variant circle(r: F64); rect(w, h: INT); dot; named(name: []U8; n: U8); end; + Shape = variant circle(r: F64); rect(w, h: INT); dot; named(name: []const U8; n: U8); end; Rule = record tag: INT; s: Shape; end; const diff --git a/conform/run/Views.raz b/conform/run/Views.raz index edcf1b8..fed0ab0 100644 --- a/conform/run/Views.raz +++ b/conform/run/Views.raz @@ -4,6 +4,7 @@ bytes are written here a byte at a time where order matters. *) module Views; import Out, ViewData; +import SYSTEM; type Header = record magic: U32; count: U32; end; @@ -13,7 +14,7 @@ mem: [64]U8; (* a module's array *) regs: [4]U64; -proc show(label: []U8; v: I64); +proc show(label: []const U8; v: I64); begin Out.str(label); Out.str(" "); Out.int(v); Out.ln; end; @@ -25,7 +26,7 @@ end; (* a slice parameter's element, viewed *) -proc sum(s: []U8): I64; +proc sum(s: []const U8): I64; var i, t: INT; begin t := 0; @@ -74,7 +75,7 @@ (* a packed record, and a pointer read from bytes, then followed *) mem[40].(Pair) := {tag: 1, value: 300}; show("Pair's value", I64(mem[41].(I32))); - p := ADR(n); + p := SYSTEM.ADR(n); mem[48].(^I64) := p; mem[48].(^I64)^ := 77; show("n through a pointer from bytes", n); diff --git a/conform/run/ZeroStart.raz b/conform/run/ZeroStart.raz index 862b216..8670c70 100644 --- a/conform/run/ZeroStart.raz +++ b/conform/run/ZeroStart.raz @@ -10,17 +10,17 @@ Shape = variant first(x: I64); second(y: I64); end; var - n: I64; u: U8; ok: BOOL; p: ^Rec; f: proc; e: ERROR; s: []U8; + n: I64; u: U8; ok: BOOL; p: ^Rec; f: proc; e: ERROR; s: []const U8; c: Colour; fl: Flags; r: Rec; a: [3]I64; v: Shape; -proc line(name: []U8; zero: BOOL); +proc line(name: []const U8; zero: BOOL); begin Out.str(name); if zero then Out.str(" zero"); else Out.str(" NOT ZERO"); end; Out.ln; end; -proc which(name: []U8; v: Shape); +proc which(name: []const U8; v: Shape); begin Out.str(name); match v of @@ -39,7 +39,7 @@ proc locals; var - n: I64; u: U8; ok: BOOL; p: ^Rec; f: proc; e: ERROR; s: []U8; + n: I64; u: U8; ok: BOOL; p: ^Rec; f: proc; e: ERROR; s: []const U8; c: Colour; fl: Flags; r: Rec; a: [3]I64; v: Shape; begin line("local number", (n = 0) and (u = 0)); diff --git a/conform/run/mods/Filled.raz b/conform/run/mods/Filled.raz index 1e06894..db32b1f 100644 --- a/conform/run/mods/Filled.raz +++ b/conform/run/mods/Filled.raz @@ -4,6 +4,7 @@ may be a record, which = doesn't compare. *) module Filled(T); import Out; +import SYSTEM; (* The lengths of the slices filled *) const Lens: [7]INT = [0, 1, 2, 7, 8, 9, 100]; @@ -24,7 +25,7 @@ wrong: INT; (* elements that hold what they shouldn't *) (* The bytes of the T at p: BYTES takes no BOOL, set or enumeration *) -proc bytesAt(p: ^T): []U8; +proc bytesAt(p: ^T): []const U8; var q: ^U8; begin q := ^U8(p); @@ -36,7 +37,7 @@ var i: INT; begin for i := 0 to LEN(a) - 1 do - if bytesAt(ADR(a[i])) # bytesAt(ADR(v)) then INC(wrong); end; + if bytesAt(SYSTEM.ADR(a[i])) # bytesAt(SYSTEM.ADR(v)) then INC(wrong); end; end; end; @@ -81,7 +82,7 @@ (* Fills slices and arrays with v, around s, and says how many elements were filled and how many are wrong, after name *) -proc check*(name: []U8; v, s: T); +proc check*(name: []const U8; v, s: T); begin filled := 0; wrong := 0; diff --git a/conform/run/mods/Stack.raz b/conform/run/mods/Stack.raz index b8d4512..7d34ecd 100644 --- a/conform/run/mods/Stack.raz +++ b/conform/run/mods/Stack.raz @@ -1,5 +1,6 @@ module Stack; import Ints := Pile(I64); +import SYSTEM; var s: Ints.Pile; @@ -11,5 +12,5 @@ end; begin - p := ADR(s); + p := SYSTEM.ADR(s); end Stack. diff --git a/doc/raz-lib.md b/doc/raz-lib.md index 3ba1209..ba32914 100644 --- a/doc/raz-lib.md +++ b/doc/raz-lib.md @@ -211,7 +211,7 @@ ``` module Both; -import Out, C; (* C: printf, fflush and C's FILE *stdout *) +import Out, C, SYSTEM; (* C: printf, fflush and C's FILE *stdout *) proc main*; begin diff --git a/doc/raz-tutorial.7 b/doc/raz-tutorial.7 index 0a1e536..8a721c2 100644 --- a/doc/raz-tutorial.7 +++ b/doc/raz-tutorial.7 @@ -74,7 +74,7 @@ var count*: INT; (* the greetings so far *) -proc hello*(name: []U8); +proc hello*(name: []const U8); begin Out.str("hello, "); Out.str(name); @@ -540,7 +540,7 @@ type Span = record p: ^U8; n: INT; end; -proc spanOf(s: []U8): Span; +proc spanOf(s: []const U8): Span; begin return {p: SYSTEM.PTR(s), n: LEN(s)}; end; @@ -847,7 +847,7 @@ TooBig*: ERROR = "not a number up to 1000"; (* the number s holds, up to 1000 *) -proc number(s: []U8): (INT, ERROR); +proc number(s: []const U8): (INT, ERROR); var n: I64; ok: BOOL; begin if LEN(s) = 0 then return 0, Empty; end; @@ -857,7 +857,7 @@ end; (* the sum of the numbers in words: the first error ends it *) -proc total(words: [][]U8): (INT, ERROR); +proc total(words: [][]const U8): (INT, ERROR); var i, sum: INT; begin for i := 0 to LEN(words) - 1 do @@ -867,7 +867,7 @@ end; proc main*; -var words: [3][]U8; i, n: INT; err: ERROR; +var words: [3][]const U8; i, n: INT; err: ERROR; begin words := ["42", "", "12345"]; for i := 0 to 2 do @@ -949,7 +949,7 @@ end; (* the lines of the file at path, or -1 if it can't be read *) -proc lines(path: []U8): INT; +proc lines(path: []const U8): INT; var fd, n, i, count: INT; buf: [4096]U8; begin fd := Sys.openRead(path); @@ -1077,7 +1077,7 @@ end; end; -proc kind(c: I32): []U8; +proc kind(c: I32): []const U8; begin match c of | ' ', '\et', '\en': return "space"; @@ -1087,7 +1087,7 @@ end; end; -proc colour(name: []U8): Colour; +proc colour(name: []const U8): Colour; begin match name of | "red", "rose": return red; @@ -1178,14 +1178,14 @@ .Bd -literal -offset indent module Generics; import Out, Ints := Biggest(INT, before), - Words := Biggest([]U8, shorter), Order := Sort(INT, before); + Words := Biggest([]const U8, shorter), Order := Sort(INT, before); proc before(a, b: INT): BOOL; begin return a < b; end; -proc shorter(a, b: []U8): BOOL; +proc shorter(a, b: []const U8): BOOL; begin return LEN(a) < LEN(b); end; diff --git a/doc/raz.md b/doc/raz.md index fe7e49c..7291b6b 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -1535,7 +1535,7 @@ import Sys, Out; (* Prints the first line of the file at path. *) -proc head(path: []U8): BOOL; +proc head(path: []const U8): BOOL; var fd, n, i: INT; buf: [256]U8; begin fd := Sys.openRead(path); diff --git a/examples/Args.raz b/examples/Args.raz index af12048..54936b9 100644 --- a/examples/Args.raz +++ b/examples/Args.raz @@ -1,6 +1,7 @@ (* Prints its arguments, one per line, and exits with how many. *) module Args; import Out; +import SYSTEM; (* The length of a C string. *) proc len(s: ^U8): INT; @@ -15,7 +16,7 @@ var i: INT; s: ^U8; begin for i := 1 to ARGC() - 1 do - s := ARGV()[i]; + s := SYSTEM.ARGV()[i]; Out.str(s[0..len(s)]); Out.ln; end; diff --git a/examples/Cpu.raz b/examples/Cpu.raz index 29ae5cd..5174e9f 100644 --- a/examples/Cpu.raz +++ b/examples/Cpu.raz @@ -2,6 +2,7 @@ other procedure. cpuid's vendor string, from leaf 0. *) module Cpu; import Out; +import SYSTEM; (* cpuid leaf 0: puts the 12 bytes of the vendor in buf, rdi. *) proc vendor(buf: ^U8); @@ -20,7 +21,7 @@ proc main*; var buf: [12]U8; i: INT; ok: BOOL; begin - vendor(ADR(buf[0])); + vendor(SYSTEM.ADR(buf[0])); ok := true; for i := 0 to 11 do if (buf[i] < ' ') or (buf[i] > '~') then ok := false; end; diff --git a/examples/Printf.raz b/examples/Printf.raz index fb34caf..5c622c7 100644 --- a/examples/Printf.raz +++ b/examples/Printf.raz @@ -2,6 +2,7 @@ a buffer of its own, so each is flushed before the other writes. *) module Printf; import Out, C; +import SYSTEM; proc main*; var i: INT; diff --git a/examples/Pthreads.raz b/examples/Pthreads.raz index 095f889..ee1fb29 100644 --- a/examples/Pthreads.raz +++ b/examples/Pthreads.raz @@ -2,6 +2,7 @@ and using the heap and Out, which lock themselves. *) module Pthreads; import Out, C, Heap, Mem; +import SYSTEM; const Workers = 4; @@ -35,7 +36,7 @@ for i := 0 to N - 1 do numbers^[i] := i + 1; end; for i := 0 to Workers - 1 do parts[i] := {lo: i * N div Workers, hi: (i + 1) * N div Workers}; - if C.pthread_create(ADR(t[i]), nil, work, ^U8(ADR(parts[i]))) # 0 then + if C.pthread_create(SYSTEM.ADR(t[i]), nil, work, ^U8(SYSTEM.ADR(parts[i]))) # 0 then Out.str("can't start a thread\n"); return 1; end; diff --git a/examples/Sh.raz b/examples/Sh.raz index 5d0e853..0e3c78a 100644 --- a/examples/Sh.raz +++ b/examples/Sh.raz @@ -13,6 +13,7 @@ bg), assignments, globs, $(...), if and while. *) module Sh; import Opt, Files, Sys, Str, Buf, Fmt, Out, Arena, Heap, Rt; +import SYSTEM; const maxWords = 64; (* of a command *) @@ -85,7 +86,7 @@ proc readWord; var b: Buf.Buf; q: U8; begin - Buf.init(b, ADR(arena.base)); + Buf.init(b, SYSTEM.ADR(arena.base)); while (at < LEN(s)) and not special(s[at]) do q := s[at]; match q of @@ -148,7 +149,7 @@ var t: Token; c: ^Command; begin p^ := {n: 1}; - c := ADR(p^.cmds[0]); + c := SYSTEM.ADR(p^.cmds[0]); t := next(); while (t # sep) and (t # amp) and (t # eof) do if t = word then @@ -157,7 +158,7 @@ INC(c^.n); elsif t = pipe then if (c^.n = 0) or (p^.n = maxCmds) then say("a | without a command", []); return t, false; end; - c := ADR(p^.cmds[p^.n]); + c := SYSTEM.ADR(p^.cmds[p^.n]); INC(p^.n); else if next() # word then say("a redirection without a file", []); return t, false; end; @@ -185,7 +186,7 @@ if (i = LEN(path)) or (path[i] = ':') then dir := path[start..i]; start := i + 1; - Buf.init(b, ADR(arena.base)); + Buf.init(b, SYSTEM.ADR(arena.base)); Fmt.write(b, "{}/{}", [Fmt.str(dir), Fmt.str(name)]); info, err := Sys.info(Buf.bytes(b)); if (err = 0) and info.file and (info.mode & 49H # 0) then return Buf.bytes(b), true; end; @@ -246,11 +247,11 @@ pids: [maxCmds]INT; fds: [3]INT; i, j, inNext, r, w, leader, joins, how, _pid: INT; c: ^Command; path: []const U8; found, _ok: BOOL; st: Sys.Status; begin - if (p^.n = 1) and not p^.background and builtin(ADR(p^.cmds[0])) then return; end; + if (p^.n = 1) and not p^.background and builtin(SYSTEM.ADR(p^.cmds[0])) then return; end; leader := 0; inNext := 0; for i := 0 to p^.n - 1 do - c := ADR(p^.cmds[i]); + c := SYSTEM.ADR(p^.cmds[i]); fds := [inNext, 0, 0]; inNext := 0; if i < p^.n - 1 then r, w := Sys.pipe(); fds[1] := w; inNext := r; end; @@ -306,9 +307,9 @@ s := script; at := 0; repeat - t, ok := parse(ADR(p)); + t, ok := parse(SYSTEM.ADR(p)); if not ok then status := 2; return; end; - if p.cmds[0].n > 0 then start(ADR(p)); end; + if p.cmds[0].n > 0 then start(SYSTEM.ADR(p)); end; until t = eof; end; diff --git a/examples/Volatile.raz b/examples/Volatile.raz index 6953cd4..037c830 100644 --- a/examples/Volatile.raz +++ b/examples/Volatile.raz @@ -4,6 +4,7 @@ size, in the order written. *) module Volatile; import Out; +import SYSTEM; type Uart = record @@ -17,7 +18,7 @@ proc main*; var dev: ^VOLATILE Uart; i: INT; begin - dev := ^VOLATILE Uart(ADR(page)); + dev := ^VOLATILE Uart(SYSTEM.ADR(page)); dev^.control := 1; dev^.status := 0FFH; for i := 0 to 2 do diff --git a/examples/Window.raz b/examples/Window.raz index 10f4b43..0255b5d 100644 --- a/examples/Window.raz +++ b/examples/Window.raz @@ -4,6 +4,7 @@ check, not run: it needs a display. *) module Window; import Out; +import SYSTEM; link "libX11.so.6"; const @@ -56,12 +57,12 @@ _ := XSelectInput(d, w, ExposureMask + KeyPressMask); _ := XMapWindow(d, w); repeat - _ := XNextEvent(d, ^U8(ADR(ev))); + _ := XNextEvent(d, ^U8(SYSTEM.ADR(ev))); if I32(ev[0]) = Expose then _ := XDrawString(d, w, XDefaultGC(d, s), 20, 45, text, I32(LEN(text))); end; until I32(ev[0]) = KeyPress; - key := ^KeyEvent(ADR(ev)); + key := ^KeyEvent(SYSTEM.ADR(ev)); Out.str("key "); Out.int(INT(key^.keycode)); Out.ln; _ := XCloseDisplay(d); return 0; diff --git a/examples/Workers.raz b/examples/Workers.raz index f0e28aa..88709ad 100644 --- a/examples/Workers.raz +++ b/examples/Workers.raz @@ -2,6 +2,7 @@ from a shared counter and add up their results under a Mutex. *) module Workers; import Out, Thread; +import SYSTEM; const Workers = 4; @@ -24,13 +25,13 @@ proc work(_arg: ^U8); var n, r: INT; begin - n := XADD(ADR(next), 1); + n := XADD(next, 1); while n < Jobs do r := job(n * 1000); Thread.lock(m); total := total + r; Thread.unlock(m); - n := XADD(ADR(next), 1); + n := XADD(next, 1); end; end; diff --git a/test/bench/Grep.raz b/test/bench/Grep.raz index eb0f7f2..6ec796a 100644 --- a/test/bench/Grep.raz +++ b/test/bench/Grep.raz @@ -8,6 +8,7 @@ whole only where both are. *) module Grep; import Out; +import SYSTEM; check off; const @@ -42,7 +43,7 @@ begin i := 0; while i + 8 <= LEN(s) do - p := ^U64(ADR(s[i])); + p := ^U64(SYSTEM.ADR(s[i])); m := zeros(p^ xor 0A0A0A0A0A0A0A0AH); if m # 0 then return i + lowest(m); end; i := i + 8; @@ -60,8 +61,8 @@ wb := U64(Word[B]) * Ones; i := 0; while i + 7 <= last do - p := ^U64(ADR(s[i + A])); - q := ^U64(ADR(s[i + B])); + p := ^U64(SYSTEM.ADR(s[i + A])); + q := ^U64(SYSTEM.ADR(s[i + B])); m := zeros(p^ xor wa) & zeros(q^ xor wb); while m # 0 do j := i + lowest(m); diff --git a/test/bench/Heapsort.raz b/test/bench/Heapsort.raz index 856e87f..c40c549 100644 --- a/test/bench/Heapsort.raz +++ b/test/bench/Heapsort.raz @@ -1,6 +1,7 @@ (* A heap sort of pseudo-random numbers. *) module Heapsort; import Out; +import SYSTEM; check off; const diff --git a/test/bench/Jacobi.raz b/test/bench/Jacobi.raz index 40242ef..4cc284c 100644 --- a/test/bench/Jacobi.raz +++ b/test/bench/Jacobi.raz @@ -2,6 +2,7 @@ neighbours, the edges held. *) module Jacobi; import Out; +import SYSTEM; check off; const diff --git a/test/bench/Lines.raz b/test/bench/Lines.raz index d121230..d3897a2 100644 --- a/test/bench/Lines.raz +++ b/test/bench/Lines.raz @@ -3,6 +3,7 @@ IndexByte, which is assembly, and a counting loop. *) module Lines; import Out, Bytes; +import SYSTEM; check off; const diff --git a/test/bench/NBody.raz b/test/bench/NBody.raz index 98f9010..f30bb81 100644 --- a/test/bench/NBody.raz +++ b/test/bench/NBody.raz @@ -3,6 +3,7 @@ inner loop. *) module NBody; import Out, Math; +import SYSTEM; check off; const diff --git a/test/bench/Search.raz b/test/bench/Search.raz index ff6cfad..576df6a 100644 --- a/test/bench/Search.raz +++ b/test/bench/Search.raz @@ -2,6 +2,7 @@ turn, over a text of four letters. *) module Search; import Out; +import SYSTEM; check off; const diff --git a/test/bench/Sum.raz b/test/bench/Sum.raz index b89bba1..eb2e44e 100644 --- a/test/bench/Sum.raz +++ b/test/bench/Sum.raz @@ -1,6 +1,7 @@ (* A sum over a slice: the loop of a procedure that takes one. *) module Sum; import Out; +import SYSTEM; check off; const diff --git a/test/err/AsmControl.err b/test/err/AsmControl.err index 42e52db..8a11dd5 100644 --- a/test/err/AsmControl.err +++ b/test/err/AsmControl.err @@ -1,4 +1,4 @@ -test/err/AsmControl.raz:4:5: error: can't assemble mov with these operands - 4 | mov eax, cr0; +test/err/AsmControl.raz:5:5: error: can't assemble mov with these operands + 5 | mov eax, cr0; | ^^^ raz: 1 error diff --git a/test/err/AsmControl.raz b/test/err/AsmControl.raz index 0109b97..f31810b 100644 --- a/test/err/AsmControl.raz +++ b/test/err/AsmControl.raz @@ -1,4 +1,5 @@ module AsmControl; +import SYSTEM; proc f; code mov eax, cr0; diff --git a/test/err/AsmJccRegister.err b/test/err/AsmJccRegister.err index da1b9a2..83f28a4 100644 --- a/test/err/AsmJccRegister.err +++ b/test/err/AsmJccRegister.err @@ -1,4 +1,4 @@ -test/err/AsmJccRegister.raz:4:5: error: unknown instruction jz - 4 | jz rax; +test/err/AsmJccRegister.raz:5:5: error: unknown instruction jz + 5 | jz rax; | ^^ raz: 1 error diff --git a/test/err/AsmJccRegister.raz b/test/err/AsmJccRegister.raz index 4368b37..8a80da8 100644 --- a/test/err/AsmJccRegister.raz +++ b/test/err/AsmJccRegister.raz @@ -1,4 +1,5 @@ module AsmJccRegister; +import SYSTEM; proc f; code jz rax; diff --git a/test/err/AsmLabel.err b/test/err/AsmLabel.err index f014608..aa13b9c 100644 --- a/test/err/AsmLabel.err +++ b/test/err/AsmLabel.err @@ -1,4 +1,4 @@ -test/err/AsmLabel.raz:4:9: error: label nowhere isn't defined - 4 | jmp nowhere; +test/err/AsmLabel.raz:5:9: error: label nowhere isn't defined + 5 | jmp nowhere; | ^^^^^^^ raz: 1 error diff --git a/test/err/AsmLabel.raz b/test/err/AsmLabel.raz index 972d441..a492bc8 100644 --- a/test/err/AsmLabel.raz +++ b/test/err/AsmLabel.raz @@ -1,4 +1,5 @@ module AsmLabel; +import SYSTEM; proc f; code jmp nowhere; diff --git a/test/err/AsmMemory.err b/test/err/AsmMemory.err index bb99c29..51e789e 100644 --- a/test/err/AsmMemory.err +++ b/test/err/AsmMemory.err @@ -1,4 +1,4 @@ -test/err/AsmMemory.raz:4:16: error: expected a memory operand, [base + index * scale + disp] - 4 | mov rax, [8]; +test/err/AsmMemory.raz:5:16: error: expected a memory operand, [base + index * scale + disp] + 5 | mov rax, [8]; | ^ raz: 1 error diff --git a/test/err/AsmMemory.raz b/test/err/AsmMemory.raz index 6bea013..17146f1 100644 --- a/test/err/AsmMemory.raz +++ b/test/err/AsmMemory.raz @@ -1,4 +1,5 @@ module AsmMemory; +import SYSTEM; proc f; code mov rax, [8]; diff --git a/test/err/AsmOperands.err b/test/err/AsmOperands.err index 3ace6e6..3179bf9 100644 --- a/test/err/AsmOperands.err +++ b/test/err/AsmOperands.err @@ -1,4 +1,4 @@ -test/err/AsmOperands.raz:4:5: error: can't assemble lea with these operands - 4 | lea rax, rbx; +test/err/AsmOperands.raz:5:5: error: can't assemble lea with these operands + 5 | lea rax, rbx; | ^^^ raz: 1 error diff --git a/test/err/AsmOperands.raz b/test/err/AsmOperands.raz index fc8dc02..da72727 100644 --- a/test/err/AsmOperands.raz +++ b/test/err/AsmOperands.raz @@ -1,4 +1,5 @@ module AsmOperands; +import SYSTEM; proc f; code lea rax, rbx; diff --git a/test/err/AsmUnknown.err b/test/err/AsmUnknown.err index 080d72a..768f6e6 100644 --- a/test/err/AsmUnknown.err +++ b/test/err/AsmUnknown.err @@ -1,4 +1,4 @@ -test/err/AsmUnknown.raz:4:5: error: unknown instruction frob - 4 | frob rax; +test/err/AsmUnknown.raz:5:5: error: unknown instruction frob + 5 | frob rax; | ^^^^ raz: 1 error diff --git a/test/err/AsmUnknown.raz b/test/err/AsmUnknown.raz index 140b7d8..9426ae7 100644 --- a/test/err/AsmUnknown.raz +++ b/test/err/AsmUnknown.raz @@ -1,4 +1,5 @@ module AsmUnknown; +import SYSTEM; proc f; code frob rax; diff --git a/test/err/AtPByte.err b/test/err/AtPByte.err index ad851ce..88dc625 100644 --- a/test/err/AtPByte.err +++ b/test/err/AtPByte.err @@ -1,4 +1,4 @@ -test/err/AtPByte.raz:4:11: error: expected a byte from 0 to 255, found 300 - 4 | db 1, 300; +test/err/AtPByte.raz:5:11: error: expected a byte from 0 to 255, found 300 + 5 | db 1, 300; | ^^^ raz: 1 error diff --git a/test/err/AtPByte.raz b/test/err/AtPByte.raz index 1e07068..41c8049 100644 --- a/test/err/AtPByte.raz +++ b/test/err/AtPByte.raz @@ -1,4 +1,5 @@ module AtPByte; +import SYSTEM; proc f(a: I64); code db 1, 300; diff --git a/test/err/BareC.raz b/test/err/BareC.raz index 84acc3c..df720a2 100644 --- a/test/err/BareC.raz +++ b/test/err/BareC.raz @@ -1,4 +1,5 @@ module BareC; +import SYSTEM; extern proc getpid(): I32; proc main*; begin diff --git a/test/err/ConvDeref.err b/test/err/ConvDeref.err index fdcd98d..19fec2b 100644 --- a/test/err/ConvDeref.err +++ b/test/err/ConvDeref.err @@ -1,5 +1,5 @@ -test/err/ConvDeref.raz:4:15: error: a conversion can't be dereferenced - 4 | b := ^INT(a)^ +test/err/ConvDeref.raz:5:15: error: a conversion can't be dereferenced + 5 | b := ^INT(a)^ | ^ help: convert into a pointer variable, then dereference that raz: 1 error diff --git a/test/err/ConvDeref.raz b/test/err/ConvDeref.raz index f730e69..7bc2991 100644 --- a/test/err/ConvDeref.raz +++ b/test/err/ConvDeref.raz @@ -1,4 +1,5 @@ module ConvDeref; +import SYSTEM; var a, b: INT; begin b := ^INT(a)^ diff --git a/test/err/DeclAtomicSize.err b/test/err/DeclAtomicSize.err index fda9ee1..a45d4ce 100644 --- a/test/err/DeclAtomicSize.err +++ b/test/err/DeclAtomicSize.err @@ -1,4 +1,4 @@ -test/err/DeclAtomicSize.raz:8:15: error: expected an INT or a UINT variable, found ^U8 - 8 | n := XADD(p, 1); +test/err/DeclAtomicSize.raz:9:15: error: expected an INT or a UINT variable, found ^U8 + 9 | n := XADD(p, 1); | ^ raz: 1 error diff --git a/test/err/DeclAtomicSize.raz b/test/err/DeclAtomicSize.raz index 263efb4..f35be51 100644 --- a/test/err/DeclAtomicSize.raz +++ b/test/err/DeclAtomicSize.raz @@ -1,10 +1,11 @@ module DeclAtomicSize; +import SYSTEM; proc main*; var b: U8; var p: ^U8; var n: I64; begin - p := ADR(b); + p := SYSTEM.ADR(b); n := XADD(p, 1); end; end DeclAtomicSize. diff --git a/test/err/DeclSyscallArg.err b/test/err/DeclSyscallArg.err index 93ed16d..9a48ebe 100644 --- a/test/err/DeclSyscallArg.err +++ b/test/err/DeclSyscallArg.err @@ -1,4 +1,4 @@ -test/err/DeclSyscallArg.raz:5:21: error: expected an integer or a pointer, found 1.5 - 5 | n := SYSCALL(1, 1.5); - | ^^^ +test/err/DeclSyscallArg.raz:6:28: error: expected an integer or a pointer, found 1.5 + 6 | n := SYSTEM.SYSCALL(1, 1.5); + | ^^^ raz: 1 error diff --git a/test/err/DeclSyscallArg.raz b/test/err/DeclSyscallArg.raz index 3abb9b0..0fd27dd 100644 --- a/test/err/DeclSyscallArg.raz +++ b/test/err/DeclSyscallArg.raz @@ -1,7 +1,8 @@ module DeclSyscallArg; +import SYSTEM; proc main*; var n: I64; begin - n := SYSCALL(1, 1.5); + n := SYSTEM.SYSCALL(1, 1.5); end; end DeclSyscallArg. diff --git a/test/err/ExprJoinStrings.err b/test/err/ExprJoinStrings.err index ab07717..53c2005 100644 --- a/test/err/ExprJoinStrings.err +++ b/test/err/ExprJoinStrings.err @@ -1,4 +1,4 @@ -test/err/ExprJoinStrings.raz:7:13: error: + doesn't join []U8 +test/err/ExprJoinStrings.raz:7:13: error: + doesn't join []const U8 7 | Out.str(s + "def"); | ^ help: strings are joined in a Buf: Buf.str(b, s) diff --git a/test/err/ExprJoinStrings.raz b/test/err/ExprJoinStrings.raz index 98e3f33..2df9303 100644 --- a/test/err/ExprJoinStrings.raz +++ b/test/err/ExprJoinStrings.raz @@ -1,7 +1,7 @@ module ExprJoinStrings; import Out; proc main*; -var s: []U8; +var s: []const U8; begin s := "abc"; Out.str(s + "def"); diff --git a/test/err/ExprNoField.err b/test/err/ExprNoField.err index f810657..926ade6 100644 --- a/test/err/ExprNoField.err +++ b/test/err/ExprNoField.err @@ -1,9 +1,9 @@ -test/err/ExprNoField.raz:7:10: error: expected a record, found ^R - 7 | n := p.x; +test/err/ExprNoField.raz:8:10: error: expected a record, found ^R + 8 | n := p.x; | ^ help: through a pointer, write p^.x -test/err/ExprNoField.raz:8:10: error: expected a record, found []U8 - 8 | n := s.len; +test/err/ExprNoField.raz:9:10: error: expected a record, found []U8 + 9 | n := s.len; | ^ help: its length is LEN(s) raz: 2 errors diff --git a/test/err/ExprNoField.raz b/test/err/ExprNoField.raz index 119e48c..e5e470e 100644 --- a/test/err/ExprNoField.raz +++ b/test/err/ExprNoField.raz @@ -1,9 +1,10 @@ module ExprNoField; +import SYSTEM; type R = record x: I64; end; proc main*; var r: R; p: ^R; s: []U8; n: I64; begin - p := ADR(r); + p := SYSTEM.ADR(r); n := p.x; n := s.len; end; diff --git a/test/err/ExternRec.err b/test/err/ExternRec.err index c2e8f45..0127c1d 100644 --- a/test/err/ExternRec.err +++ b/test/err/ExternRec.err @@ -1,4 +1,4 @@ -test/err/ExternRec.raz:5:13: error: C takes integers, BOOL, reals, pointers and procedures - 5 | extern proc f(r: R); +test/err/ExternRec.raz:6:13: error: C takes integers, BOOL, reals, pointers and procedures + 6 | extern proc f(r: R); | ^ raz: 1 error diff --git a/test/err/ExternRec.raz b/test/err/ExternRec.raz index 6c90f96..ef5eec5 100644 --- a/test/err/ExternRec.raz +++ b/test/err/ExternRec.raz @@ -1,4 +1,5 @@ module ExternRec; +import SYSTEM; type R = record a, b: I64; end; diff --git a/test/err/F32Dots.err b/test/err/F32Dots.err index 5040ac2..ab58ae1 100644 --- a/test/err/F32Dots.err +++ b/test/err/F32Dots.err @@ -1,4 +1,4 @@ -test/err/F32Dots.raz:8:22: error: an F32 goes to ... as F64(x) - 8 | C.printf("%f\n", x); +test/err/F32Dots.raz:9:22: error: an F32 goes to ... as F64(x) + 9 | C.printf("%f\n", x); | ^ raz: 1 error diff --git a/test/err/F32Dots.raz b/test/err/F32Dots.raz index 445d23d..4ebc18b 100644 --- a/test/err/F32Dots.raz +++ b/test/err/F32Dots.raz @@ -1,5 +1,6 @@ module F32Dots; import C; +import SYSTEM; proc main*; var x: F32; diff --git a/test/err/GenCodeValue.err b/test/err/GenCodeValue.err index 4113a36..695c3ea 100644 --- a/test/err/GenCodeValue.err +++ b/test/err/GenCodeValue.err @@ -1,4 +1,4 @@ -test/err/GenCodeValue.raz:6:10: error: a code procedure with two results can only be called - 6 | f := Two; +test/err/GenCodeValue.raz:7:10: error: a code procedure with two results can only be called + 7 | f := Two; | ^^^ raz: 1 error diff --git a/test/err/GenCodeValue.raz b/test/err/GenCodeValue.raz index b5c7926..3ac03dd 100644 --- a/test/err/GenCodeValue.raz +++ b/test/err/GenCodeValue.raz @@ -1,4 +1,5 @@ module GenCodeValue; +import SYSTEM; type F = proc(): (I64, I64); proc Two(): (I64, I64); code ret; end; proc main*; var f: F; diff --git a/test/err/Static.raz b/test/err/Static.raz index c034a29..421ea15 100644 --- a/test/err/Static.raz +++ b/test/err/Static.raz @@ -1,5 +1,6 @@ module Static; import Bare, C; +import SYSTEM; proc main*; begin diff --git a/test/err/StmtCReturns.err b/test/err/StmtCReturns.err index 61fa362..d7c44a5 100644 --- a/test/err/StmtCReturns.err +++ b/test/err/StmtCReturns.err @@ -1,4 +1,4 @@ -test/err/StmtCReturns.raz:3:13: error: C returns a single value - 3 | extern proc f(): R; +test/err/StmtCReturns.raz:4:13: error: C returns a single value + 4 | extern proc f(): R; | ^ raz: 1 error diff --git a/test/err/StmtCReturns.raz b/test/err/StmtCReturns.raz index fcd37b3..0af32cc 100644 --- a/test/err/StmtCReturns.raz +++ b/test/err/StmtCReturns.raz @@ -1,4 +1,5 @@ module StmtCReturns; +import SYSTEM; type R = record a: I64; end; extern proc f(): R; end StmtCReturns. diff --git a/test/err/StmtCodeParams.err b/test/err/StmtCodeParams.err index 2fa9495..09d1b48 100644 --- a/test/err/StmtCodeParams.err +++ b/test/err/StmtCodeParams.err @@ -1,4 +1,4 @@ -test/err/StmtCodeParams.raz:2:6: error: too many parameters for a code procedure - 2 | proc f(a, b, c, d, e, f, g: I64); +test/err/StmtCodeParams.raz:3:6: error: too many parameters for a code procedure + 3 | proc f(a, b, c, d, e, f, g: I64); | ^ raz: 1 error diff --git a/test/err/StmtCodeParams.raz b/test/err/StmtCodeParams.raz index c84f606..4d31130 100644 --- a/test/err/StmtCodeParams.raz +++ b/test/err/StmtCodeParams.raz @@ -1,4 +1,5 @@ module StmtCodeParams; +import SYSTEM; proc f(a, b, c, d, e, f, g: I64); code ret; end; end StmtCodeParams. diff --git a/test/err/StmtCodeResult.err b/test/err/StmtCodeResult.err index 42fb99f..e7de3cf 100644 --- a/test/err/StmtCodeResult.err +++ b/test/err/StmtCodeResult.err @@ -1,4 +1,4 @@ -test/err/StmtCodeResult.raz:3:6: error: a code procedure returns a single value - 3 | proc f: R; +test/err/StmtCodeResult.raz:4:6: error: a code procedure returns a single value + 4 | proc f: R; | ^ raz: 1 error diff --git a/test/err/StmtCodeResult.raz b/test/err/StmtCodeResult.raz index 6b27150..2501968 100644 --- a/test/err/StmtCodeResult.raz +++ b/test/err/StmtCodeResult.raz @@ -1,4 +1,5 @@ module StmtCodeResult; +import SYSTEM; type R = record a: I64; end; proc f: R; code ret; end; diff --git a/test/err/StmtCodeSlices.err b/test/err/StmtCodeSlices.err index 53390a7..269fe1c 100644 --- a/test/err/StmtCodeSlices.err +++ b/test/err/StmtCodeSlices.err @@ -1,4 +1,4 @@ -test/err/StmtCodeSlices.raz:2:6: error: too many parameters for a code procedure - 2 | proc f(a, b, c, d, e: I64; s: []U8); +test/err/StmtCodeSlices.raz:3:6: error: too many parameters for a code procedure + 3 | proc f(a, b, c, d, e: I64; s: []U8); | ^ raz: 1 error diff --git a/test/err/StmtCodeSlices.raz b/test/err/StmtCodeSlices.raz index 5ebe0fc..4427512 100644 --- a/test/err/StmtCodeSlices.raz +++ b/test/err/StmtCodeSlices.raz @@ -1,4 +1,5 @@ module StmtCodeSlices; +import SYSTEM; proc f(a, b, c, d, e: I64; s: []U8); code ret; end; end StmtCodeSlices. diff --git a/test/err/StmtCodeTakes.err b/test/err/StmtCodeTakes.err index 796cf65..5f910aa 100644 --- a/test/err/StmtCodeTakes.err +++ b/test/err/StmtCodeTakes.err @@ -1,4 +1,4 @@ -test/err/StmtCodeTakes.raz:3:6: error: a code procedure takes integers, BOOL, reals, pointers, procedures and slices - 3 | proc f(r: R); +test/err/StmtCodeTakes.raz:4:6: error: a code procedure takes integers, BOOL, reals, pointers, procedures and slices + 4 | proc f(r: R); | ^ raz: 1 error diff --git a/test/err/StmtCodeTakes.raz b/test/err/StmtCodeTakes.raz index fe26242..5a7d0f5 100644 --- a/test/err/StmtCodeTakes.raz +++ b/test/err/StmtCodeTakes.raz @@ -1,4 +1,5 @@ module StmtCodeTakes; +import SYSTEM; type R = record a: I64; end; proc f(r: R); code ret; end; diff --git a/test/err/StmtCodeTwo.err b/test/err/StmtCodeTwo.err index 3ca639e..0b4db17 100644 --- a/test/err/StmtCodeTwo.err +++ b/test/err/StmtCodeTwo.err @@ -1,4 +1,4 @@ -test/err/StmtCodeTwo.raz:2:6: error: a code procedure returns two results only in rax and rdx - 2 | proc f: (F64, I64); +test/err/StmtCodeTwo.raz:3:6: error: a code procedure returns two results only in rax and rdx + 3 | proc f: (F64, I64); | ^ raz: 1 error diff --git a/test/err/StmtCodeTwo.raz b/test/err/StmtCodeTwo.raz index 4682ba5..754cc5b 100644 --- a/test/err/StmtCodeTwo.raz +++ b/test/err/StmtCodeTwo.raz @@ -1,4 +1,5 @@ module StmtCodeTwo; +import SYSTEM; proc f: (F64, I64); code ret; end; end StmtCodeTwo. diff --git a/test/err/VarGivenAddress.raz b/test/err/VarGivenAddress.raz index 4fbea1b..ba3bc54 100644 --- a/test/err/VarGivenAddress.raz +++ b/test/err/VarGivenAddress.raz @@ -1,13 +1,14 @@ module VarGivenAddress; +import SYSTEM; type B = record n: INT; end; proc f(var b: B); begin b.n := 1; end; proc g(const b: B): INT; begin return b.n; end; proc main*; var b: B; p: ^B; begin - p := ADR(b); - f(ADR(b)); + p := SYSTEM.ADR(b); + f(SYSTEM.ADR(b)); f(p); - _ := g(ADR(b)); + _ := g(SYSTEM.ADR(b)); end; end VarGivenAddress. diff --git a/test/err/ZeroDigit.raz b/test/err/ZeroDigit.raz index 135d380..d8a8e35 100644 --- a/test/err/ZeroDigit.raz +++ b/test/err/ZeroDigit.raz @@ -1,7 +1,7 @@ module ZeroDigit; (* \0 before a digit is a warning; \x00, \0 at the end, \0 before a letter, an escaped backslash before 0 and a raw string are quiet. *) -var s*: []U8; c*: U8; +var s*: []const U8; c*: U8; proc main*; begin s := "a\x0012"; diff --git a/test/err/mods/Bare.raz b/test/err/mods/Bare.raz index 98c6b81..769cd92 100644 --- a/test/err/mods/Bare.raz +++ b/test/err/mods/Bare.raz @@ -1,5 +1,6 @@ (* A module that needs a program without C. *) module Bare; +import SYSTEM; link static; proc f*: I64; diff --git a/test/libc/ThreadSignalC.raz b/test/libc/ThreadSignalC.raz index 90b018e..270759f 100644 --- a/test/libc/ThreadSignalC.raz +++ b/test/libc/ThreadSignalC.raz @@ -4,6 +4,7 @@ joined, is -3. ThreadSignal is the same, without C; this copy runs over the C library's Sys. *) import Thread, Sys, Fmt, C; +import SYSTEM; var r, got, done: INT; @@ -12,7 +13,7 @@ var buf: [16]U8; begin got := Sys.read(r, buf); - _ := XCHG(ADR(done), 1); + _ := XCHG(done, 1); end; proc quick(_arg: ^U8); @@ -28,7 +29,7 @@ t, e := Thread.spawn(reader, nil); if e # nil then Fmt.print("no thread\n", []); return; end; (* again until it lands: the first may come before the read begins *) - while (XADD(ADR(done), 0) = 0) and (tries < 1000) do + while (XADD(done, 0) = 0) and (tries < 1000) do k := Thread.signal(t, Sys.sigUsr1); if k # 0 then Fmt.print("signal: {}\n", [Fmt.int(k)]); end; Sys.sleep(5); diff --git a/test/libc/Through.raz b/test/libc/Through.raz index 20aa9e0..a8c519a 100644 --- a/test/libc/Through.raz +++ b/test/libc/Through.raz @@ -3,6 +3,7 @@ writes out what Out holds. *) module Through; import Out, Heap, Mem; +import SYSTEM; type Node = record next: ^Node; n: I64; end; diff --git a/test/libc/Through.stderr b/test/libc/Through.stderr index f6eeb0a..dfb1df8 100644 --- a/test/libc/Through.stderr +++ b/test/libc/Through.stderr @@ -1,2 +1,2 @@ -test/libc/Through.raz:30:7: index 3 is out of range for a length of 3 - in Through.main at test/libc/Through.raz:30:7: p = nil, list = nil, i = 3, sum = 500500 +test/libc/Through.raz:31:7: index 3 is out of range for a length of 3 + in Through.main at test/libc/Through.raz:31:7: p = nil, list = nil, i = 3, sum = 500500 diff --git a/test/list/Listing.expect b/test/list/Listing.expect index 84572bc..ccdfdaa 100644 --- a/test/list/Listing.expect +++ b/test/list/Listing.expect @@ -4,13 +4,13 @@ 4 ret Listing.main: - 17 proc main*; + 18 proc main*; 0 push rbp 1 mov rbp, rsp 4 sub rsp, 32 11 mov [rbp - 8], rbx 15 xor ebx, ebx - 20 for i := 1 to 3 do + 21 for i := 1 to 3 do 17 mov rbx, 1 22 cmp rbx, 3 26 jg 168 @@ -20,7 +20,7 @@ 53 nop 61 nop 64 add rbx, 1 - 21 if i # 2 then total := add(total, twice(i)); end; + 22 if i # 2 then total := add(total, twice(i)); end; 68 cmp rbx, 2 72 je 134 78 mov r8, [Listing.total] @@ -43,7 +43,7 @@ 154 add rbx, 1 158 cmp rbx, 3 162 jle 68 - 23 end main; + 24 end main; 168 mov rbx, [rbp - 8] 172 leave 173 ret diff --git a/test/list/Listing.raz b/test/list/Listing.raz index a384a11..a67ffbe 100644 --- a/test/list/Listing.raz +++ b/test/list/Listing.raz @@ -1,5 +1,6 @@ module Listing; (* raz -S: each line of source, and the instructions made for it *) +import SYSTEM; var total: I64; diff --git a/test/msg/ArrayConstAdr.err b/test/msg/ArrayConstAdr.err index c2e9bd5..3f900a9 100644 --- a/test/msg/ArrayConstAdr.err +++ b/test/msg/ArrayConstAdr.err @@ -1,4 +1,4 @@ -conform/err/ArrayConstAdr.raz:6:14: error: ADR needs a variable - 6 | p := ADR(P); - | ^ +conform/err/ArrayConstAdr.raz:7:21: error: ADR needs a variable + 7 | p := SYSTEM.ADR(P); + | ^ raz: 1 error diff --git a/test/msg/AtPAdr.err b/test/msg/AtPAdr.err index 3050898..d0b3b4f 100644 --- a/test/msg/AtPAdr.err +++ b/test/msg/AtPAdr.err @@ -1,4 +1,4 @@ -conform/err/AtPAdr.raz:5:14: error: ADR needs a variable - 5 | p := ADR(1); - | ^ +conform/err/AtPAdr.raz:6:21: error: ADR needs a variable + 6 | p := SYSTEM.ADR(1); + | ^ raz: 1 error diff --git a/test/msg/AtomicI64.err b/test/msg/AtomicI64.err index 29d2507..847608c 100644 --- a/test/msg/AtomicI64.err +++ b/test/msg/AtomicI64.err @@ -1,4 +1,4 @@ -conform/err/AtomicI64.raz:5:16: error: expected a pointer to an INT, a UINT or a pointer, found ^I64 - 5 | _ok := CAS(ADR(n), 0, 1); - | ^^^^^^ +conform/err/AtomicI64.raz:5:16: error: expected an INT, a UINT or a pointer variable, found I64 + 5 | _ok := CAS(n, 0, 1); + | ^ raz: 1 error diff --git a/test/msg/BytesVolatile.err b/test/msg/BytesVolatile.err index dae16c7..ba07fb5 100644 --- a/test/msg/BytesVolatile.err +++ b/test/msg/BytesVolatile.err @@ -1,5 +1,5 @@ -conform/err/BytesVolatile.raz:7:16: error: BYTES can't take a volatile variable - 7 | b := BYTES(r^); +conform/err/BytesVolatile.raz:8:16: error: BYTES can't take a volatile variable + 8 | b := BYTES(r^); | ^^ help: reading and writing its bytes through a slice wouldn't be volatile accesses raz: 1 error diff --git a/test/msg/ConstAdr.err b/test/msg/ConstAdr.err index 1753246..9fd7404 100644 --- a/test/msg/ConstAdr.err +++ b/test/msg/ConstAdr.err @@ -1,5 +1,5 @@ -conform/err/ConstAdr.raz:5:16: error: r is only read here, and can't be changed - 5 | return ADR(r); - | ^ +conform/err/ConstAdr.raz:6:23: error: r is only read here, and can't be changed + 6 | return SYSTEM.ADR(r); + | ^ help: a const parameter, a constant, and the names a match gives their fields, are only read: take a var parameter to change it raz: 1 error diff --git a/test/msg/ExportAdr.err b/test/msg/ExportAdr.err index 74da26a..bbd7707 100644 --- a/test/msg/ExportAdr.err +++ b/test/msg/ExportAdr.err @@ -1,4 +1,4 @@ -conform/err/ExportAdr.raz:6:15: error: Owner.n is Owner's, and can't be changed outside it - 6 | _p := ADR(Owner.n); - | ^^^^^^^ +conform/err/ExportAdr.raz:7:22: error: Owner.n is Owner's, and can't be changed outside it + 7 | _p := SYSTEM.ADR(Owner.n); + | ^^^^^^^ raz: 1 error diff --git a/test/msg/GenDotsRecord.err b/test/msg/GenDotsRecord.err index 5fd9f16..d1ceef1 100644 --- a/test/msg/GenDotsRecord.err +++ b/test/msg/GenDotsRecord.err @@ -1,4 +1,4 @@ -conform/err/GenDotsRecord.raz:7:20: error: only a single value goes to ... - 7 | C.printf("%d", r); +conform/err/GenDotsRecord.raz:8:20: error: only a single value goes to ... + 8 | C.printf("%d", r); | ^ raz: 1 error diff --git a/test/msg/PackedAddress.err b/test/msg/PackedAddress.err index d2dad80..0a0bc6e 100644 --- a/test/msg/PackedAddress.err +++ b/test/msg/PackedAddress.err @@ -1,13 +1,13 @@ -conform/err/PackedAddress.raz:15:14: error: a field of a packed record has no address - 15 | p := ADR(h.len); - | ^^^^^ -conform/err/PackedAddress.raz:16:9: error: a field of a packed record can't be a var parameter - 16 | put(h.len); +conform/err/PackedAddress.raz:16:21: error: a field of a packed record has no address + 16 | p := SYSTEM.ADR(h.len); + | ^^^^^ +conform/err/PackedAddress.raz:17:9: error: a field of a packed record can't be a var parameter + 17 | put(h.len); | ^^^^^ -conform/err/PackedAddress.raz:17:10: error: can't make a slice of a field of a packed record - 17 | s := h.vals[0..1]; +conform/err/PackedAddress.raz:18:10: error: can't make a slice of a field of a packed record + 18 | s := h.vals[0..1]; | ^^^^^^ -conform/err/PackedAddress.raz:19:5: error: a field of a packed record can't be volatile - 19 | q^.len := 2; +conform/err/PackedAddress.raz:20:5: error: a field of a packed record can't be volatile + 20 | q^.len := 2; | ^^ raz: 4 errors diff --git a/test/msg/PtrArray.err b/test/msg/PtrArray.err index 372eb1a..f08edbe 100644 --- a/test/msg/PtrArray.err +++ b/test/msg/PtrArray.err @@ -1,4 +1,4 @@ -conform/err/PtrArray.raz:6:5: error: a pointer to an array is indexed as p^[i] - 6 | p[1] := 0; +conform/err/PtrArray.raz:7:5: error: a pointer to an array is indexed as p^[i] + 7 | p[1] := 0; | ^ raz: 1 error diff --git a/test/msg/PtrAsSlice.err b/test/msg/PtrAsSlice.err index 0cacfea..556e6f0 100644 --- a/test/msg/PtrAsSlice.err +++ b/test/msg/PtrAsSlice.err @@ -1,5 +1,5 @@ -conform/err/PtrAsSlice.raz:5:10: error: can't use ^U8 as []U8 - 5 | s := PTR(a); - | ^^^^^^ +conform/err/PtrAsSlice.raz:6:10: error: can't use ^U8 as []U8 + 6 | s := SYSTEM.PTR(a); + | ^^^^^^^^^^^^^ help: a pointer has no length: p[0..n], for a pointer p, is the slice of the n elements it starts raz: 1 error diff --git a/test/msg/PtrElement.err b/test/msg/PtrElement.err index 2ea46d0..4556858 100644 --- a/test/msg/PtrElement.err +++ b/test/msg/PtrElement.err @@ -1,4 +1,4 @@ -conform/err/PtrElement.raz:5:10: error: can't use ^U8 as ^INT - 5 | p := PTR(a); - | ^^^^^^ +conform/err/PtrElement.raz:6:10: error: can't use ^U8 as ^INT + 6 | p := SYSTEM.PTR(a); + | ^^^^^^^^^^^^^ raz: 1 error diff --git a/test/msg/PtrExport.err b/test/msg/PtrExport.err index 524b6b4..a4c8d7a 100644 --- a/test/msg/PtrExport.err +++ b/test/msg/PtrExport.err @@ -1,5 +1,5 @@ -conform/err/PtrExport.raz:6:14: error: Owner.a is Owner's, and can't be changed outside it - 6 | p := PTR(Owner.a); - | ^^^^^^^ +conform/err/PtrExport.raz:7:21: error: Owner.a is Owner's, and can't be changed outside it + 7 | p := SYSTEM.PTR(Owner.a); + | ^^^^^^^ help: a pointer to it could change it, as a slice of it could: copy it to a variable here first raz: 1 error diff --git a/test/msg/PtrInteger.err b/test/msg/PtrInteger.err index a5e4b2c..48b36a6 100644 --- a/test/msg/PtrInteger.err +++ b/test/msg/PtrInteger.err @@ -1,4 +1,4 @@ -conform/err/PtrInteger.raz:6:14: error: PTR needs a slice or an array, found INT - 6 | p := PTR(n); - | ^ +conform/err/PtrInteger.raz:7:21: error: PTR needs a slice or an array, found INT + 7 | p := SYSTEM.PTR(n); + | ^ raz: 1 error diff --git a/test/msg/PtrLiteral.err b/test/msg/PtrLiteral.err index adf0059..41aea83 100644 --- a/test/msg/PtrLiteral.err +++ b/test/msg/PtrLiteral.err @@ -1,5 +1,5 @@ -conform/err/PtrLiteral.raz:5:14: error: PTR can't take an array literal, which has no type here - 5 | p := PTR([]); - | ^ +conform/err/PtrLiteral.raz:6:21: error: PTR can't take an array literal, which has no type here + 6 | p := SYSTEM.PTR([]); + | ^ help: PTR([]) would be nil, the empty slice's pointer; give any other literal a variable first raz: 1 error diff --git a/test/msg/PtrPacked.err b/test/msg/PtrPacked.err index e07535b..86dfc2b 100644 --- a/test/msg/PtrPacked.err +++ b/test/msg/PtrPacked.err @@ -1,4 +1,4 @@ -conform/err/PtrPacked.raz:6:14: error: PTR can't take a field of a packed record, which has no address - 6 | p := PTR(r.words); - | ^^^^^^^ +conform/err/PtrPacked.raz:7:21: error: PTR can't take a field of a packed record, which has no address + 7 | p := SYSTEM.PTR(r.words); + | ^^^^^^^ raz: 1 error diff --git a/test/msg/PtrPointer.err b/test/msg/PtrPointer.err index 17cfdcf..3ccc083 100644 --- a/test/msg/PtrPointer.err +++ b/test/msg/PtrPointer.err @@ -1,9 +1,9 @@ -conform/err/PtrPointer.raz:6:14: error: PTR needs a slice or an array, found ^U8 - 6 | q := PTR(p); - | ^ +conform/err/PtrPointer.raz:7:21: error: PTR needs a slice or an array, found ^U8 + 7 | q := SYSTEM.PTR(p); + | ^ help: p is a pointer already, which is what PTR gives of a slice or an array -conform/err/PtrPointer.raz:7:14: error: PTR needs a slice or an array, found ^[4]U8 - 7 | q := PTR(pa); - | ^^ +conform/err/PtrPointer.raz:8:21: error: PTR needs a slice or an array, found ^[4]U8 + 8 | q := SYSTEM.PTR(pa); + | ^^ help: write PTR(pa^) for the address of the array's first element, a ^U8 raz: 2 errors diff --git a/test/msg/PtrView.err b/test/msg/PtrView.err index b0084fd..84f95b1 100644 --- a/test/msg/PtrView.err +++ b/test/msg/PtrView.err @@ -1,5 +1,5 @@ -conform/err/PtrView.raz:6:14: error: PTR can't take a view - 6 | p := PTR(w.([8]U8)); - | ^^^^^^^^^ +conform/err/PtrView.raz:7:21: error: PTR can't take a view + 7 | p := SYSTEM.PTR(w.([8]U8)); + | ^^^^^^^^^ help: a view has no address, since it may be misaligned: copy it to a variable raz: 1 error diff --git a/test/msg/PtrVolatile.err b/test/msg/PtrVolatile.err index 881ed80..777abd4 100644 --- a/test/msg/PtrVolatile.err +++ b/test/msg/PtrVolatile.err @@ -1,5 +1,5 @@ -conform/err/PtrVolatile.raz:7:14: error: PTR can't take an array through a volatile pointer - 7 | p := PTR(v^); - | ^^ +conform/err/PtrVolatile.raz:8:21: error: PTR can't take an array through a volatile pointer + 8 | p := SYSTEM.PTR(v^); + | ^^ help: ADR(v^[0]) is the address of its first element, a ^VOLATILE U32 raz: 1 error diff --git a/test/msg/SliceLiteralPart.err b/test/msg/SliceLiteralPart.err index 4e4a71c..f9ce8b9 100644 --- a/test/msg/SliceLiteralPart.err +++ b/test/msg/SliceLiteralPart.err @@ -1,4 +1,4 @@ -conform/err/SliceLiteralPart.raz:2:32: error: a constant slice is a string, an array constant or literal of its elements, or [], found 3 - 2 | const Rows: [][]INT = [[1, 2], 3]; - | ^ +conform/err/SliceLiteralPart.raz:2:44: error: a constant slice is a string, an array constant or literal of its elements, or [], found 3 + 2 | const Rows: []const []const INT = [[1, 2], 3]; + | ^ raz: 1 error diff --git a/test/msg/SlicePtrBackwards.stderr b/test/msg/SlicePtrBackwards.stderr index 3427aa6..d828482 100644 --- a/test/msg/SlicePtrBackwards.stderr +++ b/test/msg/SlicePtrBackwards.stderr @@ -1,2 +1,2 @@ -conform/run/SlicePtrBackwards.raz:11:23: slice 2..0 runs backwards - in SlicePtrBackwards.main at conform/run/SlicePtrBackwards.raz:11:23: p = 0x?, hi = 0 +conform/run/SlicePtrBackwards.raz:12:23: slice 2..0 runs backwards + in SlicePtrBackwards.main at conform/run/SlicePtrBackwards.raz:12:23: p = 0x?, hi = 0 diff --git a/test/msg/StmtVarOrProc.err b/test/msg/StmtVarOrProc.err index 2737010..77acce0 100644 --- a/test/msg/StmtVarOrProc.err +++ b/test/msg/StmtVarOrProc.err @@ -1,4 +1,4 @@ -conform/err/StmtVarOrProc.raz:2:8: error: expected "proc" or "var", found a number - 2 | extern 5; +conform/err/StmtVarOrProc.raz:3:8: error: expected "proc" or "var", found a number + 3 | extern 5; | ^ raz: 1 error diff --git a/test/msg/ViewAdr.err b/test/msg/ViewAdr.err index 9bb2893..581b233 100644 --- a/test/msg/ViewAdr.err +++ b/test/msg/ViewAdr.err @@ -1,5 +1,5 @@ -conform/err/ViewAdr.raz:5:14: error: ADR can't take a view - 5 | p := ADR(mem[0].(I64)); - | ^^^^^^^^^^^^ +conform/err/ViewAdr.raz:6:21: error: ADR can't take a view + 6 | p := SYSTEM.ADR(mem[0].(I64)); + | ^^^^^^^^^^^^ help: a view has no address, since it may be misaligned: copy it to a variable raz: 1 error diff --git a/test/msg/Volatile.err b/test/msg/Volatile.err index 718f7f2..59e8034 100644 --- a/test/msg/Volatile.err +++ b/test/msg/Volatile.err @@ -1,4 +1,4 @@ -conform/err/Volatile.raz:6:10: error: can't use ^VOLATILE I64 as ^I64 - 6 | q := p; +conform/err/Volatile.raz:7:10: error: can't use ^VOLATILE I64 as ^I64 + 7 | q := p; | ^ raz: 1 error diff --git a/test/run/Alloc.raz b/test/run/Alloc.raz index 4eadc05..a8bf468 100644 --- a/test/run/Alloc.raz +++ b/test/run/Alloc.raz @@ -1,5 +1,6 @@ module Alloc; import Out, Mem, Arena, Heap; +import SYSTEM; type Node = record next: ^Node; val: I64; pad: [5]I64; end; @@ -52,12 +53,12 @@ Out.int(b^.data[999] + b^.data[0]); Out.ln; Mem.free(Heap.heap, ^U8(b)); if not Arena.init(ar, 8192) then Out.str("no arena"); end; - l := build(ADR(ar.base), 100); + l := build(SYSTEM.ADR(ar.base), 100); Out.int(sum(l)); Out.ln; - l := build(ADR(ar.base), 1000); + l := build(SYSTEM.ADR(ar.base), 1000); if l = nil then Out.str("nil "); end; Arena.reset(ar); - NEW(again, ADR(ar.base)); + NEW(again, SYSTEM.ADR(ar.base)); if again # nil then Out.str("again "); Out.int(again^.val); end; Out.ln; Arena.done(ar); diff --git a/test/run/ArenaRelease.raz b/test/run/ArenaRelease.raz index b80d676..207f713 100644 --- a/test/run/ArenaRelease.raz +++ b/test/run/ArenaRelease.raz @@ -2,12 +2,13 @@ (* a mark from before the arena's present position is released; one past where the arena stands stops the program *) import Arena, Mem, Rt; +import SYSTEM; proc main*; var ar: Arena.Arena; m: INT; begin if not Arena.init(ar, 4096) then Rt.stop("no arena"); end; - _ := Mem.alloc(ADR(ar.base), 10, 1); + _ := Mem.alloc(SYSTEM.ADR(ar.base), 10, 1); m := Arena.mark(ar); Arena.release(ar, 0); Arena.release(ar, m); diff --git a/test/run/Asm.raz b/test/run/Asm.raz index 5ee265f..4396275 100644 --- a/test/run/Asm.raz +++ b/test/run/Asm.raz @@ -2,6 +2,7 @@ (* Code procedures in assembly: the instructions the assembler knows, each checked by what it computes *) import Out; +import SYSTEM; const Seven = 7; @@ -154,10 +155,10 @@ begin Out.int(tens(4, 2)); Out.ln; a := [1, 20, 300, 4000]; - Out.int(sum(ADR(a[0]), 4)); Out.str(" "); Out.int(sum(ADR(a[0]), 0)); Out.str(" "); - Out.int(around(ADR(a[0]), 1)); Out.ln; + Out.int(sum(SYSTEM.ADR(a[0]), 4)); Out.str(" "); Out.int(sum(SYSTEM.ADR(a[0]), 0)); Out.str(" "); + Out.int(around(SYSTEM.ADR(a[0]), 1)); Out.ln; s := "abc"; - Out.int(swapByte(ADR(s[0]), 1, 'z')); Out.str(" "); Out.str(s[0..3]); Out.ln; + Out.int(swapByte(SYSTEM.ADR(s[0]), 1, 'z')); Out.str(" "); Out.str(s[0..3]); Out.ln; q, r := udivmod(1000, 7); Out.int(I64(q)); Out.str(" "); Out.int(I64(r)); Out.ln; Out.int(max(-5, 3)); Out.str(" "); Out.int(max(9, 3)); Out.str(" "); @@ -166,7 +167,7 @@ Out.int(I64(real(1.0, 3.0))); Out.ln; Out.int(mix(5)); Out.ln; c := 40; - Out.int(fetchAdd(ADR(c), 2)); Out.str(" "); Out.int(c); Out.ln; + Out.int(fetchAdd(SYSTEM.ADR(c), 2)); Out.str(" "); Out.int(c); Out.ln; Out.int(I64(two() * 21.0)); Out.str(" "); Out.int(answer()); Out.ln; Out.int(through(answer)); Out.ln; t := "abcdef"; diff --git a/test/run/AsmKernel.raz b/test/run/AsmKernel.raz index f9f420f..8b5ec89 100644 --- a/test/run/AsmKernel.raz +++ b/test/run/AsmKernel.raz @@ -3,10 +3,11 @@ back from the procedure they are made in, since they can't run in user mode. Each was checked against GNU as. *) import Out; +import SYSTEM; const Count = 36; - Names: [Count][]U8 = ["cli", "sti", "iretq", "swapgs", + Names: [Count][]const U8 = ["cli", "sti", "iretq", "swapgs", "rdmsr", "wrmsr", "wbinvd", "lgdt [rdi]", "lidt [rsi + 8]", "invlpg [rax]", "invlpg [r12 + rcx * 8 + 400]", "xsave [rdi]", "xrstor [r9]", "ltr ax", "ltr r10w", "mov cr0, rax", diff --git a/test/run/Atomic.raz b/test/run/Atomic.raz index c4be7f6..e1ab2b5 100644 --- a/test/run/Atomic.raz +++ b/test/run/Atomic.raz @@ -1,5 +1,6 @@ module Atomic; import Out; +import SYSTEM; var counter: INT; flag: UINT; p: ^INT; @@ -13,24 +14,24 @@ proc main*; var old: INT; ok: BOOL; v: ^VOLATILE INT; x: INT; begin - old := XADD(ADR(counter), 5); - old := XADD(ADR(counter), 2); + old := XADD(counter, 5); + old := XADD(counter, 2); Out.int(old); Out.str(" "); Out.int(counter); Out.ln; - ok := CAS(ADR(counter), 7, 100); + ok := CAS(counter, 7, 100); if ok then Out.str("cas1 "); end; - ok := CAS(ADR(counter), 7, 200); + ok := CAS(counter, 7, 200); if not ok then Out.str("cas2 "); end; Out.int(counter); Out.ln; - Out.int(I64(XCHG(ADR(flag), 9))); Out.str(" "); - Out.int(I64(XCHG(ADR(flag), 3))); Out.ln; + Out.int(I64(XCHG(flag, 9))); Out.str(" "); + Out.int(I64(XCHG(flag, 3))); Out.ln; FENCE; FENCE(); Out.int(add3(1, 20, 300)); Out.ln; - v := ADR(x); + v := SYSTEM.ADR(x); v^ := 5; v^ := v^ + 1; Out.int(x); Out.ln; - v := ^VOLATILE INT(ADR(counter)); + v := ^VOLATILE INT(SYSTEM.ADR(counter)); Out.int(v^); Out.ln; end; diff --git a/test/run/BufFull.raz b/test/run/BufFull.raz index 097fa87..ce7a7c4 100644 --- a/test/run/BufFull.raz +++ b/test/run/BufFull.raz @@ -2,12 +2,13 @@ (* a Buf whose allocator runs out stops the program, with the calls under way, rather than dropping what it was given *) import Buf, Arena, Rt; +import SYSTEM; proc main*; var ar: Arena.Arena; b: Buf.Buf; big: [10000]U8; begin if not Arena.init(ar, 4096) then Rt.stop("no arena"); end; - Buf.init(b, ADR(ar.base)); + Buf.init(b, SYSTEM.ADR(ar.base)); Buf.str(b, big); end; diff --git a/test/run/BufFull.stderr b/test/run/BufFull.stderr index 38ced9d..34672bc 100644 --- a/test/run/BufFull.stderr +++ b/test/run/BufFull.stderr @@ -1,4 +1,4 @@ Buf: out of memory in Buf.need at lib/Buf.raz:51:9: n = 10000 in Buf.str at lib/Buf.raz:67:5 - in BufFull.main at test/run/BufFull.raz:11:5 + in BufFull.main at test/run/BufFull.raz:12:5 diff --git a/test/run/CheckOff.raz b/test/run/CheckOff.raz index 08001c8..87404d8 100644 --- a/test/run/CheckOff.raz +++ b/test/run/CheckOff.raz @@ -3,12 +3,13 @@ Unchecked reads past an array, into the field after it, and makes a slice past its string's end; then this module's own index fails *) import Out, Unchecked; +import SYSTEM; proc main*; var p: Unchecked.Pair; i: INT; begin p.b := 42; - Out.int(Unchecked.get(ADR(p), 2)); Out.str(" "); + Out.int(Unchecked.get(SYSTEM.ADR(p), 2)); Out.str(" "); Out.int(Unchecked.width("abc", 1, 5)); Out.ln; Out.flush; i := 2; diff --git a/test/run/CheckOff.stderr b/test/run/CheckOff.stderr index ed23828..c964716 100644 --- a/test/run/CheckOff.stderr +++ b/test/run/CheckOff.stderr @@ -1,2 +1,2 @@ -test/run/CheckOff.raz:15:17: index 2 is out of range for a length of 2 - in CheckOff.main at test/run/CheckOff.raz:15:17: i = 2 +test/run/CheckOff.raz:16:17: index 2 is out of range for a length of 2 + in CheckOff.main at test/run/CheckOff.raz:16:17: i = 2 diff --git a/test/run/ConstOfConst.raz b/test/run/ConstOfConst.raz index 76426bd..47bda03 100644 --- a/test/run/ConstOfConst.raz +++ b/test/run/ConstOfConst.raz @@ -3,7 +3,7 @@ module ConstOfConst; import Sys; -type R = record a: INT; s: []U8; end; +type R = record a: INT; s: []const U8; end; const X: R = {a: 1, s: "one"}; const Row: [2]INT = [3, 4]; diff --git a/test/run/Data.raz b/test/run/Data.raz index 34c1e56..715f127 100644 --- a/test/run/Data.raz +++ b/test/run/Data.raz @@ -1,5 +1,6 @@ module Data; import Out; +import SYSTEM; type Cell = record ch: U8; attr: U8; end; @@ -40,15 +41,15 @@ Out.int(I64(cells[2].ch)); Out.str(" "); Out.int(I64(cells[2].attr)); Out.ln; for i := 0 to 4 do nodes[i].val := i * i; - if i < 4 then nodes[i].next := ADR(nodes[i + 1]); end; + if i < 4 then nodes[i].next := SYSTEM.ADR(nodes[i + 1]); end; end; - Out.int(sum(ADR(nodes[0]))); Out.ln; + Out.int(sum(SYSTEM.ADR(nodes[0]))); Out.ln; for i := 0 to 2 do for j := 0 to 3 do grid[i][j] := I32(i * 10 + j); end; end; Out.int(I64(grid[2][3])); Out.str(" "); Out.int(I64(grid[1][0])); Out.ln; for i := 0 to 7 do arr[i] := i * 100; end; - p := ADR(arr[0]); + p := SYSTEM.ADR(arr[0]); q := p + 5; Out.int(q^); Out.str(" "); Out.int(q - p); Out.str(" "); Out.int(p[3]); Out.ln; s := arr[2..6]; @@ -65,8 +66,8 @@ Out.int(gp.x); Out.str(" "); Out.int(gp.y); Out.ln; m.a := 1; m.b := -2; m.c := 65535; Out.int(m.b); Out.str(" "); Out.int(I64(m.c)); Out.ln; - bp := ^U8(ADR(m)); - Out.int(INT(ADR(m.c)) - INT(bp)); Out.ln; + bp := ^U8(SYSTEM.ADR(m)); + Out.int(INT(SYSTEM.ADR(m.c)) - INT(bp)); Out.ln; end; end Data. diff --git a/test/run/Deep.raz b/test/run/Deep.raz index f5262ff..dc52632 100644 --- a/test/run/Deep.raz +++ b/test/run/Deep.raz @@ -1,5 +1,6 @@ module Deep; import Out; +import SYSTEM; (* Expressions deeper than the registers of the stack, with calls, and, or, constants on the left and system calls among them. *) @@ -48,10 +49,10 @@ u := 250; u := u + U8(c * 5) + U8(d); Out.int(I64(u)); Out.ln; (* array elements and pointers among deep values *) for d := 0 to 7 do s[d] := d * d; end; - p := ADR(s[3]); + p := SYSTEM.ADR(s[3]); Out.int(s[a] + (s[c] * (s[e] - (p^ + s[s[2]] * (s[7] - s[6]))))); Out.ln; (* a system call under values *) - Out.int(a + (c * n(SYSCALL(39) > 0) + d)); Out.ln; + Out.int(a + (c * n(SYSTEM.SYSCALL(39) > 0) + d)); Out.ln; end; end Deep. diff --git a/test/run/Edge.raz b/test/run/Edge.raz index cb84a64..3ce2984 100644 --- a/test/run/Edge.raz +++ b/test/run/Edge.raz @@ -1,8 +1,9 @@ module Edge; import Out; +import SYSTEM; type - Inner = record vals: [4]I64; name: []U8; end; + Inner = record vals: [4]I64; name: []const U8; end; Outer = record items: [3]Inner; n: I64; end; var g: Outer; calls: I64; @@ -55,7 +56,7 @@ o.items[0].vals[0] := -1; Out.int(g.items[0].vals[0]); Out.str(" "); Out.int(o.items[0].vals[0]); Out.ln; Out.int(sumInner(g.items)); Out.str(" "); Out.int(sumInner(g.items[1..3])); Out.ln; - pa := ADR(a); + pa := SYSTEM.ADR(a); pa^[4] := 44; Out.int(a[4]); Out.str(" "); Out.int(LEN(pa^)); Out.ln; i := 2; diff --git a/test/run/Extern.raz b/test/run/Extern.raz index 568ccee..61464ea 100644 --- a/test/run/Extern.raz +++ b/test/run/Extern.raz @@ -2,6 +2,7 @@ C variables, raz procedures as C's callbacks. *) module Extern; import Out, C; +import SYSTEM; link "libm.so.6"; extern proc strlen(s: ^U8): U64; @@ -36,13 +37,13 @@ Out.int(I64(sqrt(2.0) * 1000.0)); Out.ln; a := [5, -3, 9, 0, 12, 1]; - qsort(^U8(ADR(a)), 6, 8, cmp); + qsort(^U8(SYSTEM.ADR(a)), 6, 8, cmp); for i := 0 to 5 do Out.int(a[i]); Out.char(' '); end; Out.ln; if calls > 0 then Out.str("cmp called\n"); end; (* nine arguments after the format: some go on the stack *) - n := snprintf(ADR(buf[0]), 64, "%d %d %d %d %d %d %d %s|%.3f %g", + n := snprintf(SYSTEM.ADR(buf[0]), 64, "%d %d %d %d %d %d %d %s|%.3f %g", 1, 2, 3, 4, 5, 6, 7, "eight", 3.14159, 0.5); Out.str(buf[0..I64(n)]); Out.ln; diff --git a/test/run/HeapCheck.raz b/test/run/HeapCheck.raz index 94a8b56..d30bf8a 100644 --- a/test/run/HeapCheck.raz +++ b/test/run/HeapCheck.raz @@ -2,6 +2,7 @@ when a block is freed twice. *) module HeapCheck; import Out, Heap, Mem; +import SYSTEM; proc show(p: ^U8); begin diff --git a/test/run/HeapDebugEnd.raz b/test/run/HeapDebugEnd.raz index d437c29..20ecf2f 100644 --- a/test/run/HeapDebugEnd.raz +++ b/test/run/HeapDebugEnd.raz @@ -2,6 +2,7 @@ (* in debug mode, a write one byte past a block's end is found when the block is freed, and stops the program *) import Heap, Mem; +import SYSTEM; proc main*; var p: ^U8; diff --git a/test/run/HeapDebugEnd.stderr b/test/run/HeapDebugEnd.stderr index 40052a2..d88acb8 100644 --- a/test/run/HeapDebugEnd.stderr +++ b/test/run/HeapDebugEnd.stderr @@ -4,4 +4,4 @@ in Heap.freeDebug at lib/Heap.raz:221:31: h = 0x?, out = nil, p = nil, i = 0, size = 0, b = nil in Heap.free at lib/Heap.raz:253:42: _a = 0x?, p = 0x?, h = 0x?, b = nil, c = 0 in Mem.free at lib/Mem.raz:40:5: a = 0x?, p = 0x? - in HeapDebugEnd.main at test/run/HeapDebugEnd.raz:12:5: p = 0x? + in HeapDebugEnd.main at test/run/HeapDebugEnd.raz:13:5: p = 0x? diff --git a/test/run/HeapDebugFree.raz b/test/run/HeapDebugFree.raz index f1bf2d7..3193800 100644 --- a/test/run/HeapDebugFree.raz +++ b/test/run/HeapDebugFree.raz @@ -2,6 +2,7 @@ (* in debug mode, a write to a freed block is found when the block leaves the quarantine, 1,024 frees later, and stops the program *) import Heap, Mem; +import SYSTEM; proc main*; var p, q: ^U8; i: INT; diff --git a/test/run/HeapDebugFree.stderr b/test/run/HeapDebugFree.stderr index 4e7cc5a..769823c 100644 --- a/test/run/HeapDebugFree.stderr +++ b/test/run/HeapDebugFree.stderr @@ -4,4 +4,4 @@ in Heap.freeDebug at lib/Heap.raz:235:36: h = 0x?, out = 0x?, p = 0x?, i = 0, size = 20, b = nil in Heap.free at lib/Heap.raz:253:42: _a = 0x?, p = 0x?, h = 0x?, b = nil, c = 0 in Mem.free at lib/Mem.raz:40:5: a = 0x?, p = 0x? - in HeapDebugFree.main at test/run/HeapDebugFree.raz:15:9: p = 0x?, q = 0x?, i = 1023 + in HeapDebugFree.main at test/run/HeapDebugFree.raz:16:9: p = 0x?, q = 0x?, i = 1023 diff --git a/test/run/HeapStray.raz b/test/run/HeapStray.raz index c8f69f9..ed28298 100644 --- a/test/run/HeapStray.raz +++ b/test/run/HeapStray.raz @@ -1,13 +1,14 @@ (* Freeing what the heap never gave out stops the program. *) module HeapStray; import Out, Heap, Mem; +import SYSTEM; var a: [4]I64; proc main*; begin Out.str("freeing a stray pointer\n"); - Mem.free(Heap.heap, ^U8(ADR(a[2]))); + Mem.free(Heap.heap, ^U8(SYSTEM.ADR(a[2]))); Out.str("not reached\n"); end; diff --git a/test/run/KeptNil.raz b/test/run/KeptNil.raz index 570631e..d9b89fe 100644 --- a/test/run/KeptNil.raz +++ b/test/run/KeptNil.raz @@ -2,6 +2,7 @@ procedure that keeps it. *) module KeptNil; import Out; +import SYSTEM; type Rec = record x: INT; end; @@ -16,7 +17,7 @@ begin r.x := 1; f := get; - Out.int(f(ADR(r), 2)); Out.ln; + Out.int(f(SYSTEM.ADR(r), 2)); Out.ln; Out.int(f(nil, 5)); Out.ln; end; diff --git a/test/run/KeptNil.stderr b/test/run/KeptNil.stderr index 28c861b..0e423f3 100644 --- a/test/run/KeptNil.stderr +++ b/test/run/KeptNil.stderr @@ -1,3 +1,3 @@ -test/run/KeptNil.raz:10:5: stopped by a nil pointer - in KeptNil.get at test/run/KeptNil.raz:10:5: p = nil, k = 5 - in KeptNil.main at test/run/KeptNil.raz:20:5: f = 0x? +test/run/KeptNil.raz:11:5: stopped by a nil pointer + in KeptNil.get at test/run/KeptNil.raz:11:5: p = nil, k = 5 + in KeptNil.main at test/run/KeptNil.raz:21:5: f = 0x? diff --git a/test/run/MapDone.raz b/test/run/MapDone.raz index 8206d6d..7d939b3 100644 --- a/test/run/MapDone.raz +++ b/test/run/MapDone.raz @@ -2,6 +2,7 @@ counts its blocks; the map empty after, and used again. *) module MapDone; import Fmt, Heap, Mem, Str, Names := Map([]const U8, INT, Str.hash, Str.eq); +import SYSTEM; var counting: Mem.Allocator; live: INT; @@ -18,11 +19,11 @@ end; proc main*; -var m: Names.Map; i, v: INT; found, _ok: BOOL; keys: [3][]U8; +var m: Names.Map; i, v: INT; found, _ok: BOOL; keys: [3][]const U8; begin counting := {alloc: alloc, free: free}; keys := ["node_modules", "target", "build"]; - Names.init(m, ADR(counting)); + Names.init(m, SYSTEM.ADR(counting)); Names.done(m); (* nothing taken yet *) for i := 0 to 99 do _ok := Names.put(m, keys[i mod 3], i); end; Fmt.print("{} entries, {} block\n", [Fmt.int(m.len), Fmt.int(live)]); diff --git a/test/run/PtrPlaces.raz b/test/run/PtrPlaces.raz index 454bae7..6af3f85 100644 --- a/test/run/PtrPlaces.raz +++ b/test/run/PtrPlaces.raz @@ -4,6 +4,7 @@ registers in a loop gives its pointer's register. *) module PtrPlaces; import Out; +import SYSTEM; proc main*; var a: [4]U8; s, e: []U8; p: ^U8; i, n: INT; @@ -11,11 +12,11 @@ a := [1, 2, 3, 4]; s := a[0..4]; e := s[2..2]; - if PTR(e) = PTR(s) + 2 then Out.str("cut empty: at its place\n"); end; - p := PTR(""); + if SYSTEM.PTR(e) = SYSTEM.PTR(s) + 2 then Out.str("cut empty: at its place\n"); end; + p := SYSTEM.PTR(""); if p # nil then Out.str("\"\": not nil\n"); end; n := 0; - for i := 0 to 3 do s := a[i..4]; n := n + INT(PTR(s) - PTR(a)); end; + for i := 0 to 3 do s := a[i..4]; n := n + INT(SYSTEM.PTR(s) - SYSTEM.PTR(a)); end; Out.int(n); Out.str("\n"); end; diff --git a/test/run/Results.raz b/test/run/Results.raz index 8cd791f..4ef5562 100644 --- a/test/run/Results.raz +++ b/test/run/Results.raz @@ -1,5 +1,6 @@ module Results; import Out; +import SYSTEM; const NotFound*: ERROR = "not found"; @@ -24,7 +25,7 @@ return -1, NotFound; end; -proc mixed(x: F64): (F64, []U8, Pair, BOOL); +proc mixed(x: F64): (F64, []const U8, Pair, BOOL); var p: Pair; begin p.a := 1; p.b := 2; @@ -48,7 +49,7 @@ end; proc main*; -var q, r, i: I64; e: ERROR; x: F64; s: []U8; p: Pair; ok: BOOL; a: [3]I64; u: U8; +var q, r, i: I64; e: ERROR; x: F64; s: []const U8; p: Pair; ok: BOOL; a: [3]I64; u: U8; begin q, r := divmod(17, 5); Out.int(q); Out.str(" "); Out.int(r); Out.ln; diff --git a/test/run/Shapes.raz b/test/run/Shapes.raz index e4ba610..1be1f16 100644 --- a/test/run/Shapes.raz +++ b/test/run/Shapes.raz @@ -5,7 +5,7 @@ Shape* = variant circle(r: F64); rect(w, h: F64); - label(text: []U8; size: I64); + label(text: []const U8; size: I64); dot; end; diff --git a/test/run/Simd.raz b/test/run/Simd.raz index c1f661d..a8a799e 100644 --- a/test/run/Simd.raz +++ b/test/run/Simd.raz @@ -2,6 +2,7 @@ (* Code procedures with SSE2 and the bit scans: a search sixteen bytes at a time, and the counts of bits *) import Out; +import SYSTEM; (* the first place of b in s, or -1: its address in rdi, its length in rsi, b in dl *) proc index(s: []U8; b: U8): INT; diff --git a/test/run/Single.raz b/test/run/Single.raz index 57acc76..4c0574d 100644 --- a/test/run/Single.raz +++ b/test/run/Single.raz @@ -2,6 +2,7 @@ that take either type, calls to C and to code. *) module Single; import Out, C; +import SYSTEM; link "libm.so.6"; const diff --git a/test/run/Spawn.raz b/test/run/Spawn.raz index 00b8b62..4dcc123 100644 --- a/test/run/Spawn.raz +++ b/test/run/Spawn.raz @@ -2,6 +2,7 @@ every thread at once, and join. *) module Spawn; import Out, Thread, Heap, Mem; +import SYSTEM; const Workers = 8; @@ -21,7 +22,7 @@ Thread.lock(m); INC(count); Thread.unlock(m); - _ := XADD(ADR(atomic), 1); + _ := XADD(atomic, 1); NEW(p, Heap.heap); p^.next := list; list := p; diff --git a/test/run/SpawnC.raz b/test/run/SpawnC.raz index c47014b..9c74de9 100644 --- a/test/run/SpawnC.raz +++ b/test/run/SpawnC.raz @@ -3,6 +3,7 @@ every thread at once, and join. *) module SpawnC; import Out, Thread, Heap, Mem, C; +import SYSTEM; const Workers = 8; @@ -22,7 +23,7 @@ Thread.lock(m); INC(count); Thread.unlock(m); - _ := XADD(ADR(atomic), 1); + _ := XADD(atomic, 1); NEW(p, Heap.heap); p^.next := list; list := p; diff --git a/test/run/TaskTest.raz b/test/run/TaskTest.raz index 0c387e6..5d2eb9f 100644 --- a/test/run/TaskTest.raz +++ b/test/run/TaskTest.raz @@ -2,6 +2,7 @@ its job at once after spawn, and the threads' copies are not changed. *) module TaskTest; import Check, Jobs := Task(Job), Rt, Thread; +import SYSTEM; const Threads = 8; @@ -21,11 +22,11 @@ var t: [Threads]^Thread.Thread; j: Job; i: INT; err: ERROR; begin for i := 0 to Threads - 1 do - j := {n: i + 1, out: ADR(results[i])}; + j := {n: i + 1, out: SYSTEM.ADR(results[i])}; t[i], err := Jobs.spawn(work, j); if err # nil then Rt.stop("Task.spawn failed"); end; j.n := 1000; (* the thread must not see this *) - j.out := ADR(results[0]); + j.out := SYSTEM.ADR(results[0]); end; for i := 0 to Threads - 1 do Thread.join(t[i]); end; for i := 0 to Threads - 1 do diff --git a/test/run/ThreadSignal.raz b/test/run/ThreadSignal.raz index 3086f44..48fc591 100644 --- a/test/run/ThreadSignal.raz +++ b/test/run/ThreadSignal.raz @@ -3,6 +3,7 @@ handled: the read fails with -4. A thread that has ended, not yet joined, is -3. ThreadSignalC is the same, over C. *) import Thread, Sys, Fmt; +import SYSTEM; var r, got, done: INT; @@ -11,7 +12,7 @@ var buf: [16]U8; begin got := Sys.read(r, buf); - _ := XCHG(ADR(done), 1); + _ := XCHG(done, 1); end; proc quick(_arg: ^U8); @@ -26,7 +27,7 @@ t, e := Thread.spawn(reader, nil); if e # nil then Fmt.print("no thread\n", []); return; end; (* again until it lands: the first may come before the read begins *) - while (XADD(ADR(done), 0) = 0) and (tries < 1000) do + while (XADD(done, 0) = 0) and (tries < 1000) do k := Thread.signal(t, Sys.sigUsr1); if k # 0 then Fmt.print("signal: {}\n", [Fmt.int(k)]); end; Sys.sleep(5); diff --git a/test/run/ThreadSignalC.raz b/test/run/ThreadSignalC.raz index e8a5caa..f89a8c3 100644 --- a/test/run/ThreadSignalC.raz +++ b/test/run/ThreadSignalC.raz @@ -3,6 +3,7 @@ handled: the read fails with -4. A thread that has ended, not yet joined, is -3. ThreadSignal is the same, without C. *) import Thread, Sys, Fmt, C; +import SYSTEM; var r, got, done: INT; @@ -11,7 +12,7 @@ var buf: [16]U8; begin got := Sys.read(r, buf); - _ := XCHG(ADR(done), 1); + _ := XCHG(done, 1); end; proc quick(_arg: ^U8); @@ -27,7 +28,7 @@ t, e := Thread.spawn(reader, nil); if e # nil then Fmt.print("no thread\n", []); return; end; (* again until it lands: the first may come before the read begins *) - while (XADD(ADR(done), 0) = 0) and (tries < 1000) do + while (XADD(done, 0) = 0) and (tries < 1000) do k := Thread.signal(t, Sys.sigUsr1); if k # 0 then Fmt.print("signal: {}\n", [Fmt.int(k)]); end; Sys.sleep(5); diff --git a/test/run/VecFull.raz b/test/run/VecFull.raz index 44c2df9..ebdb123 100644 --- a/test/run/VecFull.raz +++ b/test/run/VecFull.raz @@ -2,12 +2,13 @@ (* a Vec whose allocator runs out stops the program, with the calls under way, rather than dropping what it was given *) import Arena, Rt, Ints := Vec(INT); +import SYSTEM; proc main*; var ar: Arena.Arena; v: Ints.Vec; i: INT; begin if not Arena.init(ar, 4096) then Rt.stop("no arena"); end; - Ints.init(v, ADR(ar.base)); + Ints.init(v, SYSTEM.ADR(ar.base)); for i := 1 to 10000 do Ints.push(v, i); end; end; diff --git a/test/run/VecFull.stderr b/test/run/VecFull.stderr index 516c2bf..ce3b83c 100644 --- a/test/run/VecFull.stderr +++ b/test/run/VecFull.stderr @@ -1,4 +1,4 @@ Vec: out of memory in Vec(INT).need at lib/Vec.raz:57:9: n = 1 in Vec(INT).push at lib/Vec.raz:65:5: x = 257 - in VecFull.main at test/run/VecFull.raz:11:28: i = 257 + in VecFull.main at test/run/VecFull.raz:12:28: i = 257 diff --git a/test/run/VecTest.raz b/test/run/VecTest.raz index c92dec7..38684d4 100644 --- a/test/run/VecTest.raz +++ b/test/run/VecTest.raz @@ -3,7 +3,7 @@ module VecTest; import Fmt, Heap, Ints := Vec(INT), Pts := Vec(Point); -type Point = record x, y: INT; name: []U8; end; +type Point = record x, y: INT; name: []const U8; end; proc main*; var v: Ints.Vec; w: Pts.Vec; i, sum, top: INT; ok: BOOL; p: ^Point; s: []INT; diff --git a/test/run/VecTry.raz b/test/run/VecTry.raz index 672f310..8de5838 100644 --- a/test/run/VecTry.raz +++ b/test/run/VecTry.raz @@ -2,12 +2,13 @@ array as it was, and the program going on. *) module VecTry; import Arena, Fmt, Rt, Ints := Vec(INT); +import SYSTEM; proc main*; var ar: Arena.Arena; v: Ints.Vec; n: INT; p: ^INT; ok: BOOL; begin if not Arena.init(ar, 4096) then Rt.stop("no arena"); end; - Ints.init(v, ADR(ar.base)); + Ints.init(v, SYSTEM.ADR(ar.base)); n := 0; while Ints.tryPush(v, n) do INC(n); end; p, ok := Ints.tryAdd(v); diff --git a/test/run/mods/IndexParamOff.raz b/test/run/mods/IndexParamOff.raz index 7dc18a3..e3819ad 100644 --- a/test/run/mods/IndexParamOff.raz +++ b/test/run/mods/IndexParamOff.raz @@ -2,6 +2,7 @@ parameter of 1, 2, 4 or 8 bytes is read and written as the operand [pointer + index * size], where the index comes with no check. *) module IndexParamOff; +import SYSTEM; check off; const N = 8; diff --git a/test/run/mods/Unchecked.raz b/test/run/mods/Unchecked.raz index ead9ee6..5120682 100644 --- a/test/run/mods/Unchecked.raz +++ b/test/run/mods/Unchecked.raz @@ -1,4 +1,5 @@ module Unchecked; +import SYSTEM; (* A module without index and slice checks *) check off; @@ -9,7 +10,7 @@ return p^.a[i]; end; -proc width*(s: []U8; lo, hi: INT): INT; +proc width*(s: []const U8; lo, hi: INT): INT; begin return LEN(s[lo..hi]); end;