[torque][cleanup] Move ToBoolean to base.tq

This CL moves the ToBoolean function from data-view.tq to base.tq.

It used to be in data-view.tq because we couldn't call macros
from one file to the other but this has been fixed now, and it
makes more sense to have it there.

Change-Id: Id201979eacbeb4307ff7d515db48377490d5bed7
Reviewed-on: https://chromium-review.googlesource.com/1104683
Reviewed-by: Michael Stanton <mvstanton@chromium.org>
Commit-Queue: Théotime Grohens <theotime@google.com>
Cr-Commit-Position: refs/heads/master@{#53837}
This commit is contained in:
Théotime Grohens 2018-06-18 18:06:22 +02:00 committed by Commit Bot
parent f5a8352b0f
commit 7b417038b1
2 changed files with 12 additions and 14 deletions

View File

@ -668,3 +668,15 @@ macro NumberIsNaN(number: Number): bool {
let value: float64 = convert<float64>(unsafe_cast<HeapNumber>(number));
return value != value;
}
extern macro BranchIfToBooleanIsTrue(Object): never labels Taken, NotTaken;
macro ToBoolean(obj: Object): bool {
try {
BranchIfToBooleanIsTrue(obj) otherwise Taken, NotTaken;
} label Taken {
return true;
} label NotTaken {
return false;
}
}

View File

@ -59,20 +59,6 @@ module data_view {
return data_view.byte_offset;
}
extern macro BranchIfToBooleanIsTrue(Object): never labels Taken, NotTaken;
// TODO(theotime): This function should be moved to base.tq, we can't call
// functions that were defined in another Torque file for now.
macro ToBoolean(obj: Object): bool {
try {
BranchIfToBooleanIsTrue(obj) otherwise Taken, NotTaken;
} label Taken {
return true;
} label NotTaken {
return false;
}
}
extern macro BitcastInt32ToFloat32(word32): float32;
extern macro BitcastFloat32ToInt32(float32): word32;
extern macro Float64ExtractLowWord32(float64): word32;