[torque] Allow indexed field access in length expressions
In some objects, the length field for an indexed field might itself be conditionally included depending on some previous field's value. The module-related stuff at the end of ScopeInfo is a good example. Torque can represent that case, with a minor change allowing indexed field access from within the length expression for another indexed field. Bug: v8:7793 Change-Id: I9ff5c9cea2b9423f28004beba05a9a24b22c8e3e Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2360328 Reviewed-by: Tobias Tebbi <tebbi@chromium.org> Commit-Queue: Seth Brenith <seth.brenith@microsoft.com> Cr-Commit-Position: refs/heads/master@{#69457}
This commit is contained in:
parent
2638328dc9
commit
0f4b9cefc0
@ -136,6 +136,9 @@ Convert<Number, int32>(i: int32): Number {
|
||||
Convert<intptr, int32>(i: int32): intptr {
|
||||
return ChangeInt32ToIntPtr(i);
|
||||
}
|
||||
Convert<intptr, int31>(i: int31): intptr {
|
||||
return ChangeInt32ToIntPtr(i);
|
||||
}
|
||||
Convert<intptr, uint32>(i: uint32): intptr {
|
||||
return Signed(ChangeUint32ToWord(i));
|
||||
}
|
||||
|
@ -1381,12 +1381,18 @@ VisitResult ImplementationVisitor::GenerateArrayLength(VisitResult object,
|
||||
StackScope stack_scope(this);
|
||||
const ClassType* class_type = *object.type()->ClassSupertype();
|
||||
std::map<std::string, LocalValue> bindings;
|
||||
bool before_current = true;
|
||||
for (Field f : class_type->ComputeAllFields()) {
|
||||
if (f.index) break;
|
||||
if (field.name_and_type.name == f.name_and_type.name) {
|
||||
before_current = false;
|
||||
}
|
||||
bindings.insert(
|
||||
{f.name_and_type.name,
|
||||
f.const_qualified
|
||||
? LocalValue{GenerateFieldReference(object, f, class_type)}
|
||||
? (before_current
|
||||
? LocalValue{GenerateFieldReference(object, f, class_type)}
|
||||
: LocalValue("Array lengths may only refer to fields "
|
||||
"defined earlier"))
|
||||
: LocalValue(
|
||||
"Non-const fields cannot be used for array lengths.")});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user