| | @@ -158,7 +158,7 @@ |
| 158 | 158 | return (t^.form = Sym.fReal) and (t^.size = 4); |
| 159 | 159 | end; |
| 160 | 160 | |
| 161 | | -proc realOf*(x: Item): F64; |
| 161 | +proc realOf*(const x: Item): F64; |
| 162 | 162 | var v: I64; p: ^F64; |
| 163 | 163 | begin |
| 164 | 164 | v := x.val; |
| | @@ -198,7 +198,7 @@ |
| 198 | 198 | |
| 199 | 199 | (* Where the variable x is, for Gen; a slice in registers has two. x is |
| 200 | 200 | a var parameter only so as not to be copied, as it is a whole Item. *) |
| 201 | | -proc adrOf*(x: Item): Gen.Adr; |
| 201 | +proc adrOf*(const x: Item): Gen.Adr; |
| 202 | 202 | var hi: INT; |
| 203 | 203 | begin |
| 204 | 204 | hi := 0; |
| | @@ -409,7 +409,7 @@ |
| 409 | 409 | end; |
| 410 | 410 | |
| 411 | 411 | (* x isn't wanted: what it has on the stack is dropped *) |
| 412 | | -proc discard*(x: Item): ERROR; |
| 412 | +proc discard*(const x: Item): ERROR; |
| 413 | 413 | var y: Item; |
| 414 | 414 | begin |
| 415 | 415 | if x.mode = mCond then |
| | @@ -543,7 +543,7 @@ |
| 543 | 543 | gives a field of one, or of a constant (report sections 7.4 and 8). A |
| 544 | 544 | part reached through a pointer or a slice in it isn't: what they point |
| 545 | 545 | at is the caller's to change, as through a value parameter's. *) |
| 546 | | -proc onlyRead*(x: Item): BOOL; |
| 546 | +proc onlyRead*(const x: Item): BOOL; |
| 547 | 547 | begin |
| 548 | 548 | return (x.mode = mVar) and x.ro and (x.obj # nil) and x.obj^.isConst; |
| 549 | 549 | end; |
| | @@ -551,7 +551,7 @@ |
| 551 | 551 | (* Another module's exported variable can be read, not changed, nor |
| 552 | 552 | handed to anything that could change it (report section 3); nor can |
| 553 | 553 | what is only read, above. *) |
| 554 | | -proc notReadOnly*(x: Item): ERROR; |
| 554 | +proc notReadOnly*(const x: Item): ERROR; |
| 555 | 555 | begin |
| 556 | 556 | if onlyRead(x) then |
| 557 | 557 | return Scan.markHelp(x.pos, say1("{} is only read here, and can't be changed", Diag.source(x.pos)), |
| | @@ -1576,7 +1576,7 @@ |
| 1576 | 1576 | variable itself, as ADR(b) for var b: Buf: an error that says what to |
| 1577 | 1577 | write instead, b for ADR(b) and p^ for a pointer p. Mostly met in |
| 1578 | 1578 | programs written before the library took var (report 2026-10.33). *) |
| 1579 | | -proc givenAddress(a: Item; p: ^Sym.Obj): ERROR; |
| 1579 | +proc givenAddress(const a: Item; p: ^Sym.Obj): ERROR; |
| 1580 | 1580 | var s, kind: []U8; |
| 1581 | 1581 | begin |
| 1582 | 1582 | if (a.typ^.form # Sym.fPtr) or (a.typ^.base = nil) or not Sym.same(a.typ^.base, p^.typ) then |
| | @@ -1749,7 +1749,7 @@ |
| 1749 | 1749 | end; |
| 1750 | 1750 | |
| 1751 | 1751 | (* size bytes, off bytes into the variable x, cleared *) |
| 1752 | | -proc zeroRange*(x: Item; off, size: I64); |
| 1752 | +proc zeroRange*(const x: Item; off, size: I64); |
| 1753 | 1753 | var a: Gen.Adr; |
| 1754 | 1754 | begin |
| 1755 | 1755 | a := adrOf(x); |
| | @@ -1764,7 +1764,7 @@ |
| 1764 | 1764 | Gen.popVar(frameAdr(x.off), 8); |
| 1765 | 1765 | end; |
| 1766 | 1766 | |
| 1767 | | -proc setField*(x: Item; f: ^Sym.Obj; var a: Item): ERROR; |
| 1767 | +proc setField*(const x: Item; f: ^Sym.Obj; var a: Item): ERROR; |
| 1768 | 1768 | var at: Gen.Adr; |
| 1769 | 1769 | begin |
| 1770 | 1770 | at := adrOf(x); |
| | @@ -1865,7 +1865,7 @@ |
| 1865 | 1865 | (* For a for loop: pushes the variable o and the limit lim, a constant or |
| 1866 | 1866 | the slot it was put in, and jumps to L if the one is op the other, as |
| 1867 | 1867 | the type of o compares *) |
| 1868 | | -proc forCmp*(o: ^Sym.Obj; lim: Item; op: Scan.Sym; var L: INT): ERROR; |
| 1868 | +proc forCmp*(o: ^Sym.Obj; const lim: Item; op: Scan.Sym; var L: INT): ERROR; |
| 1869 | 1869 | var v, b: Item; |
| 1870 | 1870 | begin |
| 1871 | 1871 | try makeItem(v, o); |
| | @@ -1887,7 +1887,7 @@ |
| 1887 | 1887 | For another step: v past b goes to past; else b - v (unsigned, as |
| 1888 | 1888 | v <= b) >= |step| goes on to top, and else the loop ends. |
| 1889 | 1889 | Past: v is stepped here and tested, going to body if within b. *) |
| 1890 | | -proc forNext*(o: ^Sym.Obj; lim: Item; step: I64; var exitL: INT; top, body: INT): ERROR; |
| 1890 | +proc forNext*(o: ^Sym.Obj; const lim: Item; step: I64; var exitL: INT; top, body: INT): ERROR; |
| 1891 | 1891 | var v, b: Item; L, pastL: INT; up: BOOL; before, past, within: Scan.Sym; a: I64; |
| 1892 | 1892 | begin |
| 1893 | 1893 | up := step > 0; |
| | @@ -1974,7 +1974,7 @@ |
| 1974 | 1974 | that is one, an array literal or a temporary, or a slice of one, a |
| 1975 | 1975 | field or an element of one included; x.frame says so, set where the |
| 1976 | 1976 | variable is named and kept through fields, elements and slices. *) |
| 1977 | | -proc notOfFrame(x: Item; t: ^Sym.Type): ERROR; |
| 1977 | +proc notOfFrame(const x: Item; t: ^Sym.Type): ERROR; |
| 1978 | 1978 | begin |
| 1979 | 1979 | if (t^.form = Sym.fSlice) and x.frame then |
| 1980 | 1980 | return Scan.markHelp(x.pos, "can't return a slice of the procedure's own frame", |