"src/harmony-array.js",
"src/harmony-array-includes.js",
"src/harmony-typedarray.js",
- "src/harmony-classes.js",
"src/harmony-tostring.js",
"src/harmony-templates.js",
"src/harmony-regexp.js",
static const char* harmony_proxies_natives[] = {"native proxy.js", NULL};
static const char* harmony_strings_natives[] = {"native harmony-string.js",
NULL};
- static const char* harmony_classes_natives[] = {"native harmony-classes.js",
- NULL};
+ static const char* harmony_classes_natives[] = {NULL};
static const char* harmony_modules_natives[] = {NULL};
static const char* harmony_scoping_natives[] = {NULL};
static const char* harmony_object_literals_natives[] = {NULL};
+++ /dev/null
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// This file relies on the fact that the following declarations have been made
-// in runtime.js:
-// var $Function = global.Function;
-// var $Array = global.Array;
-
-"use strict";
-
-function FunctionToMethod(homeObject) {
- if (!IS_SPEC_FUNCTION(this)) {
- throw MakeTypeError('toMethod_non_function',
- [%ToString(this), typeof this]);
-
- }
-
- if (!IS_SPEC_OBJECT(homeObject)) {
- throw MakeTypeError('toMethod_non_object',
- [%ToString(homeObject)]);
- }
-
- return %ToMethod(this, homeObject);
-}
-
-function SetupHarmonyClasses() {
- %CheckIsBootstrapping();
-
- InstallFunctions($Function.prototype, DONT_ENUM, $Array(
- "toMethod", FunctionToMethod
- ));
-}
-
-SetupHarmonyClasses();
no_setter_in_callback: ["Cannot set property ", "%0", " of ", "%1", " which has only a getter"],
apply_non_function: ["Function.prototype.apply was called on ", "%0", ", which is a ", "%1", " and not a function"],
apply_wrong_args: ["Function.prototype.apply: Arguments list has wrong type"],
- toMethod_non_function: ["Function.prototype.toMethod was called on ", "%0", ", which is a ", "%1", " and not a function"],
- toMethod_non_object: ["Function.prototype.toMethod: home object ", "%0", " is not an object"],
flags_getter_non_object: ["RegExp.prototype.flags getter called on non-object ", "%0"],
invalid_in_operator_use: ["Cannot use 'in' operator to search for '", "%0", "' in ", "%1"],
instanceof_function_expected: ["Expecting a function in instanceof check, but got ", "%0"],
TEST(SuperAccessControl) {
+ i::FLAG_allow_natives_syntax = true;
i::FLAG_harmony_classes = true;
+ i::FLAG_harmony_object_literals = true;
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
v8::Handle<v8::ObjectTemplate> obj_template =
{
v8::TryCatch try_catch;
CompileRun(
- "function f() { return super.hasOwnProperty; };"
- "var m = f.toMethod(prohibited);"
+ "var f = { m() { return super.hasOwnProperty; } }.m;"
+ "var m = %ToMethod(f, prohibited);"
"m();");
CHECK(try_catch.HasCaught());
}
{
v8::TryCatch try_catch;
CompileRun(
- "function f() { return super[42]; };"
- "var m = f.toMethod(prohibited);"
+ "var f = {m() { return super[42]; } }.m;"
+ "var m = %ToMethod(f, prohibited);"
"m();");
CHECK(try_catch.HasCaught());
}
{
v8::TryCatch try_catch;
CompileRun(
- "function f() { super.hasOwnProperty = function () {}; };"
- "var m = f.toMethod(prohibited);"
+ "var f = {m() { super.hasOwnProperty = function () {}; } }.m;"
+ "var m = %ToMethod(f, prohibited);"
"m();");
CHECK(try_catch.HasCaught());
}
v8::TryCatch try_catch;
CompileRun(
"Object.defineProperty(Object.prototype, 'x', { set : function(){}});"
- "function f() { "
- " 'use strict';"
- " super.x = function () {}; "
- "};"
- "var m = f.toMethod(prohibited);"
+ "var f = {"
+ " m() { "
+ " 'use strict';"
+ " super.x = function () {};"
+ " }"
+ "}.m;"
+ "var m = %ToMethod(f, prohibited);"
"m();");
CHECK(try_catch.HasCaught());
}
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Flags: --harmony-classes
+// Flags: --harmony-classes --allow-natives-syntax
(function TestSuperNamedLoads() {
function Base() { }
(function TestSuperKeyedLoads() {
+ 'use strict';
+
var x = 'x';
var derivedDataProperty = 'derivedDataProperty';
var f = 'f';
- function Base() { }
- function fBase() { return "Base " + this.toString(); }
- Base.prototype[f] = fBase.toMethod(Base.prototype);
+ class Base {
+ f() {
+ return "Base " + this.toString();
+ }
+ toString() {
+ return "this is Base";
+ }
+ }
+
Base.prototype[x] = 15;
- Base.prototype.toString = function() { return "this is Base"; };
function Derived() {
this[derivedDataProperty] = "xxx";
function Base() { }
function fBase() { return "Base " + this.toString(); }
- Base.prototype[f] = fBase.toMethod(Base.prototype);
+ Base.prototype[f] = %ToMethod(fBase, Base.prototype);
Base.prototype[x] = 15;
Base.prototype.toString = function() { return "this is Base"; };
function ClassD() { }
assertEquals(1, f(1));
- var g = f.toMethod(ClassD.prototype);
+ var g = %ToMethod(f, ClassD.prototype);
assertEquals(1, g(1));
assertEquals(undefined, f[%HomeObjectSymbol()]);
assertEquals(ClassD.prototype, g[%HomeObjectSymbol()]);
var q = f(0);
assertEquals(2, q(1));
assertEquals(3, q(1));
- var g = q.toMethod(Derived.prototype);
+ var g = %ToMethod(q, Derived.prototype);
assertFalse(g === q);
assertEquals(4, g(1));
assertEquals(5, q(1));
}());
-(function TestErrorCases() {
- var sFun = Function.prototype.toMethod;
- assertThrows(function() { sFun.call({}); }, TypeError);
- assertThrows(function() { sFun.call({}, {}); }, TypeError);
- function f(){};
- assertThrows(function() { f.toMethod(1); }, TypeError);
-}());
-
-
(function TestPrototypeChain() {
var o = {};
var o1 = {};
function g() { }
- var fMeth = f.toMethod(o);
+ var fMeth = %ToMethod(f, o);
assertEquals(o, fMeth[%HomeObjectSymbol()]);
g.__proto__ = fMeth;
assertEquals(undefined, g[%HomeObjectSymbol()]);
- var gMeth = g.toMethod(o1);
+ var gMeth = %ToMethod(g, o1);
assertEquals(fMeth, gMeth.__proto__);
assertEquals(o, fMeth[%HomeObjectSymbol()]);
assertEquals(o1, gMeth[%HomeObjectSymbol()]);
}
var fBound = f.bind(o, 1, 2, 3);
- var fMeth = fBound.toMethod(p);
+ var fMeth = %ToMethod(fBound, p);
assertEquals(10, fMeth(4));
assertEquals(10, fMeth.call(p, 4));
var fBound1 = fBound.bind(o, 4);
assertEquals(15, f(o));
%OptimizeFunctionOnNextCall(f);
assertEquals(15, f(o));
- var g = f.toMethod({});
+ var g = %ToMethod(f, {});
var o1 = {y : 1024, x : "abc"};
assertEquals("abc", f(o1));
assertEquals("abc", g(o1));
function f() {}
Object.preventExtensions(f);
assertFalse(Object.isExtensible(f));
- var m = f.toMethod({});
+ var m = %ToMethod(f, {});
assertTrue(Object.isExtensible(m));
}());
'../../src/harmony-array-includes.js',
'../../src/harmony-tostring.js',
'../../src/harmony-typedarray.js',
- '../../src/harmony-classes.js',
'../../src/harmony-templates.js',
'../../src/harmony-regexp.js'
],