wcc/ww: def-dim array .len field-reads resolve the dimension from the type table
buf.len on a [MAX]u8 returned 0 — the cgdot len arms (local/global/ def) and letemitsize only read an N_INTLIT dimension. Route a non-literal dimension through tichase().alen (the #21 fix mirrored into the field-read consumers; .ptr arms are dim-independent). Review-era task #56.
This commit is contained in:
@@ -26664,8 +26664,19 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (streq(fld, "len")) {
|
||||
let lenn: *node = tn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) { alen = lenn.uval: i64; };
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim — resolve from the
|
||||
// stamped array tinfo (rule-13), the field-
|
||||
// read twin of the #21 cgslice fix. The dim
|
||||
// node is an N_IDENT(def), not N_INTLIT, so
|
||||
// the literal read above defaults 0; cstage
|
||||
// reads the resolved bu->alen.
|
||||
let abt: *tinfo = tichase(tn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
emitint(alen);
|
||||
@@ -26899,9 +26910,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (streq(fld, "len")) {
|
||||
let lenn: *node = gtn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim on a let-global array —
|
||||
// resolve from the stamped array tinfo
|
||||
// (rule-13), twin of the local arm above.
|
||||
let abt: *tinfo = tichase(gtn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
@@ -26943,9 +26960,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (dtn.kind == nkind.N_TARRAY) {
|
||||
let lenn: *node = dtn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim on a def array —
|
||||
// resolve from the stamped array tinfo
|
||||
// (rule-13), twin of the let-global arm above.
|
||||
let abt: *tinfo = tichase(dtn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
@@ -41524,8 +41547,17 @@ fn letemitsize(c: *cgen, d: *node) i32 = {
|
||||
let lenn: *node = t.rhs;
|
||||
let elemn: *node = t.lhs;
|
||||
let alen: i32 = 1;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) { alen = lenn.uval: i32; };
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i32;
|
||||
} else {
|
||||
// #56: def/const dim — resolve from the stamped array
|
||||
// tinfo (rule-13), the letemitsize twin of the cgdot
|
||||
// .len fix. Pre-fix a non-N_INTLIT dim defaulted alen=1
|
||||
// → array global mis-sized (one element's worth).
|
||||
let abt: *tinfo = tichase(t.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i32;
|
||||
};
|
||||
};
|
||||
let esz: i32 = 8;
|
||||
if (elemn != nil) {
|
||||
|
||||
@@ -1004,8 +1004,17 @@ fn letemitsize(c: *cgen, d: *node) i32 = {
|
||||
let lenn: *node = t.rhs;
|
||||
let elemn: *node = t.lhs;
|
||||
let alen: i32 = 1;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) { alen = lenn.uval: i32; };
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i32;
|
||||
} else {
|
||||
// #56: def/const dim — resolve from the stamped array
|
||||
// tinfo (rule-13), the letemitsize twin of the cgdot
|
||||
// .len fix. Pre-fix a non-N_INTLIT dim defaulted alen=1
|
||||
// → array global mis-sized (one element's worth).
|
||||
let abt: *tinfo = tichase(t.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i32;
|
||||
};
|
||||
};
|
||||
let esz: i32 = 8;
|
||||
if (elemn != nil) {
|
||||
|
||||
@@ -3444,8 +3444,19 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (streq(fld, "len")) {
|
||||
let lenn: *node = tn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) { alen = lenn.uval: i64; };
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim — resolve from the
|
||||
// stamped array tinfo (rule-13), the field-
|
||||
// read twin of the #21 cgslice fix. The dim
|
||||
// node is an N_IDENT(def), not N_INTLIT, so
|
||||
// the literal read above defaults 0; cstage
|
||||
// reads the resolved bu->alen.
|
||||
let abt: *tinfo = tichase(tn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
emitint(alen);
|
||||
@@ -3679,9 +3690,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (streq(fld, "len")) {
|
||||
let lenn: *node = gtn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim on a let-global array —
|
||||
// resolve from the stamped array tinfo
|
||||
// (rule-13), twin of the local arm above.
|
||||
let abt: *tinfo = tichase(gtn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
@@ -3723,9 +3740,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (dtn.kind == nkind.N_TARRAY) {
|
||||
let lenn: *node = dtn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim on a def array —
|
||||
// resolve from the stamped array tinfo
|
||||
// (rule-13), twin of the let-global arm above.
|
||||
let abt: *tinfo = tichase(dtn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
|
||||
@@ -26664,8 +26664,19 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (streq(fld, "len")) {
|
||||
let lenn: *node = tn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) { alen = lenn.uval: i64; };
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim — resolve from the
|
||||
// stamped array tinfo (rule-13), the field-
|
||||
// read twin of the #21 cgslice fix. The dim
|
||||
// node is an N_IDENT(def), not N_INTLIT, so
|
||||
// the literal read above defaults 0; cstage
|
||||
// reads the resolved bu->alen.
|
||||
let abt: *tinfo = tichase(tn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
emitint(alen);
|
||||
@@ -26899,9 +26910,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (streq(fld, "len")) {
|
||||
let lenn: *node = gtn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim on a let-global array —
|
||||
// resolve from the stamped array tinfo
|
||||
// (rule-13), twin of the local arm above.
|
||||
let abt: *tinfo = tichase(gtn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
@@ -26943,9 +26960,15 @@ fn cgdot(c: *cgen, n: *node) void = {
|
||||
if (dtn.kind == nkind.N_TARRAY) {
|
||||
let lenn: *node = dtn.rhs;
|
||||
let alen: i64 = 0i64;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i64;
|
||||
} else {
|
||||
// #56: def/const dim on a def array —
|
||||
// resolve from the stamped array tinfo
|
||||
// (rule-13), twin of the let-global arm above.
|
||||
let abt: *tinfo = tichase(dtn.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i64;
|
||||
};
|
||||
};
|
||||
emitline("\tMOVQ\t$");
|
||||
@@ -41524,8 +41547,17 @@ fn letemitsize(c: *cgen, d: *node) i32 = {
|
||||
let lenn: *node = t.rhs;
|
||||
let elemn: *node = t.lhs;
|
||||
let alen: i32 = 1;
|
||||
if (lenn != nil) {
|
||||
if (lenn.kind == nkind.N_INTLIT) { alen = lenn.uval: i32; };
|
||||
if (lenn != nil && lenn.kind == nkind.N_INTLIT) {
|
||||
alen = lenn.uval: i32;
|
||||
} else {
|
||||
// #56: def/const dim — resolve from the stamped array
|
||||
// tinfo (rule-13), the letemitsize twin of the cgdot
|
||||
// .len fix. Pre-fix a non-N_INTLIT dim defaulted alen=1
|
||||
// → array global mis-sized (one element's worth).
|
||||
let abt: *tinfo = tichase(t.type_: *tinfo);
|
||||
if (abt != nil && abt.kind == tykind.TY_ARRAY) {
|
||||
alen = abt.alen: i32;
|
||||
};
|
||||
};
|
||||
let esz: i32 = 8;
|
||||
if (elemn != nil) {
|
||||
|
||||
Reference in New Issue
Block a user