1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var $float32x4ToString;
7 (function(global, utils) {
11 %CheckIsBootstrapping();
13 // -------------------------------------------------------------------
16 var GlobalSIMD = global.SIMD;
17 var GlobalFloat32x4 = GlobalSIMD.Float32x4;
19 //-------------------------------------------------------------------
21 function Float32x4Constructor(x, y, z, w) {
22 if (%_IsConstructCall()) throw MakeTypeError(kNotConstructor, "Float32x4");
23 if (!IS_NUMBER(x) || !IS_NUMBER(y) || !IS_NUMBER(z) || !IS_NUMBER(w)) {
24 throw MakeTypeError(kInvalidArgument);
26 return %CreateFloat32x4(x, y, z, w);
29 function Float32x4Splat(s) {
30 return %CreateFloat32x4(s, s, s, s);
33 function Float32x4CheckJS(a) {
34 return %Float32x4Check(a);
37 function Float32x4ToString() {
38 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) {
39 throw MakeTypeError(kIncompatibleMethodReceiver,
40 "Float32x4.prototype.toString", this);
42 var value = %_ValueOf(this);
43 var w = GlobalFloat32x4.extractLane(value, 0),
44 x = GlobalFloat32x4.extractLane(value, 1),
45 y = GlobalFloat32x4.extractLane(value, 2),
46 z = GlobalFloat32x4.extractLane(value, 3);
47 return "Float32x4(" + w + ", " + x + ", " + y + ", " + z + ")";
50 function Float32x4ValueOf() {
51 if (!(IS_FLOAT32X4(this) || IS_FLOAT32X4_WRAPPER(this))) {
52 throw MakeTypeError(kIncompatibleMethodReceiver,
53 "Float32x4.prototype.valueOf", this);
55 return %_ValueOf(this);
58 //-------------------------------------------------------------------
60 function Float32x4ExtractLaneJS(value, lane) {
61 return %Float32x4ExtractLane(value, lane);
64 // -------------------------------------------------------------------
66 %AddNamedProperty(GlobalSIMD, symbolToStringTag, 'SIMD', READ_ONLY | DONT_ENUM);
67 %AddNamedProperty(GlobalSIMD, 'float32x4', GlobalFloat32x4, DONT_ENUM);
69 %SetCode(GlobalFloat32x4, Float32x4Constructor);
70 %FunctionSetPrototype(GlobalFloat32x4, {});
72 GlobalFloat32x4.prototype, 'constructor', GlobalFloat32x4, DONT_ENUM);
74 GlobalFloat32x4, symbolToStringTag, 'Float32x4', DONT_ENUM | READ_ONLY);
76 utils.InstallFunctions(GlobalFloat32x4.prototype, DONT_ENUM, [
77 'valueOf', Float32x4ValueOf,
78 'toString', Float32x4ToString,
81 utils.InstallFunctions(GlobalFloat32x4, DONT_ENUM, [
82 'splat', Float32x4Splat,
83 'check', Float32x4CheckJS,
84 'extractLane', Float32x4ExtractLaneJS,
87 $float32x4ToString = Float32x4ToString;