aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-19 07:34:12 +0100
committereunhhu <[email protected]>2026-10-19 07:34:12 +0100
commit30eed7886769d838a5d51b70c764c532ca023b1c (patch)
tree38ae2b811d56c217bb4ebf0c843046390d207ecd
parent1c3b2475ca2008b7a68e7fbd6281b59fa84a286c (diff)
downloadaup-30eed7886769d838a5d51b70c764c532ca023b1c.tar.gz
aup-30eed7886769d838a5d51b70c764c532ca023b1c.zip
140's apps written with the frictions gone: inflate's and linebreak's lists declared together, linebreak's 0x2010 and 0x25CC (their modules the same), DNS's records = [] and 0xc000, HTTP's trailers, j = fields(...), RFC 6298's abs and tick.period (G written once), layout's lists together, its boxes and root as targets together, boxes = []; lines 121 to 120, 148 to 146, 176 to 169, 116 to 110; instructions within 0.2%
-rw-r--r--examples/dns.aup4
-rw-r--r--examples/http.aup6
-rw-r--r--examples/inflate.aup3
-rw-r--r--examples/layout.aup16
-rw-r--r--examples/linebreak.aup17
-rw-r--r--examples/rto.aup6
6 files changed, 18 insertions, 34 deletions
diff --git a/examples/dns.aup b/examples/dns.aup
index 8f7239a..81e90db 100644
--- a/examples/dns.aup
+++ b/examples/dns.aup
@@ -67,7 +67,7 @@ fn data(d, i, size, type) {
on read {
let d = read.data
require d.bytes >= 12
- while records.count > 0 { records.remove(records.first) }
+ records = []
let at = 12
for section in 0 .. 4 {
for k in 0 .. word(d, 4 + 2 * section) {
@@ -101,7 +101,7 @@ view wire {
while !done && r.name[k] != 0 {
for s in seen {
if !done && s.name == r.name[k .. r.name.bytes] {
- out = out + two(49152 + s.at) # 0xc000: a pointer
+ out = out + two(0xc000 + s.at) # a pointer
done = true
}
}
diff --git a/examples/http.aup b/examples/http.aup
index e2c2045..863ff9b 100644
--- a/examples/http.aup
+++ b/examples/http.aup
@@ -124,10 +124,8 @@ fn request(d) -> Request, number {
for k in semi .. c { require d[k] != 10 }
require n <= 2147483648 # 2^31 at most: ours, not h11's
if n == 0 {
- let t, after = fields(d, c + 2)
- if after < 0 { return Request {}, -1 }
- for f in t { trailers.append(f) }
- j = after
+ trailers, j = fields(d, c + 2)
+ if j < 0 { return Request {}, -1 }
more = false
} else {
if d.bytes < c + 4 + n { return Request {}, -1 }
diff --git a/examples/inflate.aup b/examples/inflate.aup
index 5144c25..eb84a12 100644
--- a/examples/inflate.aup
+++ b/examples/inflate.aup
@@ -67,8 +67,7 @@ on inflate {
at = (b + 4 + size) * 8
} else {
require kind != 3
- let lengths: list of number
- let distances: list of number
+ let lengths, distances: list of number
if kind == 1 {
for s in 0 .. 288 { lengths.append(if s < 144 { 8 } else if s < 256 { 9 } else if s < 280 { 7 } else { 8 }) }
for s in 0 .. 30 { distances.append(5) }
diff --git a/examples/layout.aup b/examples/layout.aup
index 239abf6..a49bd9a 100644
--- a/examples/layout.aup
+++ b/examples/layout.aup
@@ -33,10 +33,9 @@ fn START = 0; fn END = 1; fn CENTER = 2; fn BETWEEN = 3; fn AROUND = 4; fn EVENL
fn factor(e, growing, base, pad) = if growing { e.grow } else { (base - pad) * e.shrink }
on tree {
- while boxes.count > 0 { boxes.remove(boxes.last) }
+ boxes = []
for d in tree.nodes { boxes.append(Box {}) }
- boxes[0].w = tree.nodes[0].w
- boxes[0].h = tree.nodes[0].h
+ boxes[0].w, boxes[0].h = tree.nodes[0].w, tree.nodes[0].h
for i in 0 .. tree.nodes.count {
let d = tree.nodes[i]
let kids: list of number
@@ -47,10 +46,7 @@ on tree {
if n > 0 {
let inner = (if d.column { boxes[i].h } else { boxes[i].w }) - (if d.column { d.top + d.bottom } else { d.left + d.right })
let line = max((if d.column { boxes[i].w } else { boxes[i].h }) - (if d.column { d.left + d.right } else { d.top + d.bottom }), 0)
- let pads: list of number # each item's padding on the main axis, and on the cross
- let crosses: list of number
- let bases: list of number
- let sizes: list of number
+ let pads, crosses, bases, sizes: list of number # each item's padding on the main axis and on the cross, ...
let frozen: list of bool
let total = 0
for k in kids {
@@ -113,10 +109,8 @@ on tree {
require own >= 0 || d.align == STRETCH # an auto cross size not stretched would be sized by its content
let across = max(if own < 0 { line } else { own }, crosses[x])
let offset = if d.align == END { line - across } else if d.align == CENTER { (line - across) / 2 } else { 0 }
- boxes[k].x = if d.column { d.left + offset } else { at }
- boxes[k].y = if d.column { at } else { d.top + offset }
- boxes[k].w = if d.column { across } else { sizes[x] }
- boxes[k].h = if d.column { sizes[x] } else { across }
+ if d.column { boxes[k].x, boxes[k].y, boxes[k].w, boxes[k].h = d.left + offset, at, across, sizes[x] }
+ else { boxes[k].x, boxes[k].y, boxes[k].w, boxes[k].h = at, d.top + offset, sizes[x], across }
at = at + sizes[x]
}
}
diff --git a/examples/linebreak.aup b/examples/linebreak.aup
index f9735c5..ed1ede3 100644
--- a/examples/linebreak.aup
+++ b/examples/linebreak.aup
@@ -59,7 +59,7 @@ fn next_unit(t, i) {
return j
}
-fn aksara(t, u) = t.eff[u] == AK || t.eff[u] == AS || t.codes[u] == 9676 # U+25CC
+fn aksara(t, u) = t.eff[u] == AK || t.eff[u] == AS || t.codes[u] == 0x25CC
fn pi(t, k) = ranges[t.at[k]].pi
fn pf(t, k) = ranges[t.at[k]].pf
fn east(t, k) = ranges[t.at[k]].east
@@ -111,7 +111,7 @@ fn decide(t, i) {
}
if A == QU && (!east(t, i) || unit == 0 || !east(t, t.start[unit - 1])) { return NONE }
if B == CB || A == CB { return ALLOWED } # LB20
- if (A == HY || base == 8208) && B == AL { # LB20a (U+2010)
+ if (A == HY || base == 0x2010) && B == AL { # LB20a
let w = if unit > 0 { t.eff[unit - 1] } else { SP }
if end(w) || w == SP || w == ZW || w == CB || w == GL { return NONE }
}
@@ -139,7 +139,7 @@ fn decide(t, i) {
if (A == AL || A == HL) && (B == AL || B == HL) { return NONE } # LB28
if A == AP && aksara(t, i) { return NONE } # LB28a
if aksara(t, unit) && (B == VF || B == VI) { return NONE }
- if A == VI && unit > 0 && aksara(t, t.start[unit - 1]) && (B == AK || t.codes[i] == 9676) { return NONE }
+ if A == VI && unit > 0 && aksara(t, t.start[unit - 1]) && (B == AK || t.codes[i] == 0x25CC) { return NONE }
if aksara(t, unit) && aksara(t, i) {
let j = next_unit(t, i)
if j < n && t.eff[j] == VF { return NONE }
@@ -153,15 +153,8 @@ fn decide(t, i) {
}
on line {
- let codes: list of number
- let cls: list of number
- let eff: list of number
- let start: list of number
- let nonspace: list of number
- let ri: list of number
- let at: list of number
- let joined: list of bool
- let numeric: list of bool
+ let codes, cls, eff, start, nonspace, ri, at: list of number
+ let joined, numeric: list of bool
for p in line.points {
let i = codes.count
let r = range(p.code)
diff --git a/examples/rto.aup b/examples/rto.aup
index 1d147eb..55412a7 100644
--- a/examples/rto.aup
+++ b/examples/rto.aup
@@ -23,7 +23,7 @@ input transmit = message { seq: u32 }
input ack = message { seq: u32 }
input tick = every 10 ms
-fn LOWEST = 1000; fn HIGHEST = 60000; fn PERIOD = 10 # milliseconds; the clock's granularity G is the tick's period
+fn LOWEST = 1000; fn HIGHEST = 60000 # milliseconds
on transmit {
outstanding.append(Segment { seq: transmit.seq, sent: now })
@@ -46,10 +46,10 @@ on ack {
if !measured { # 2.2
srtt, rttvar, measured = r, r / 2, true
} else { # 2.3
- rttvar = 0.75 * rttvar + 0.25 * max(srtt - r, r - srtt)
+ rttvar = 0.75 * rttvar + 0.25 * abs(srtt - r)
srtt = 0.875 * srtt + 0.125 * r
}
- rto = min(max(srtt + max(PERIOD, 4 * rttvar), LOWEST), HIGHEST) # 2.4, 2.5
+ rto = min(max(srtt + max(tick.period, 4 * rttvar), LOWEST), HIGHEST) # 2.4, 2.5 (G: the tick's period)
}
deadline = if outstanding.count > 0 { now + rto } else { -1 } # 5.3, 5.2
}