prop-expr-obj-ref-this.js (1895B)
1 // Copyright (C) 2016 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 esid: sec-super-keyword 5 es6id: 12.3.5 6 description: SuperProperty's "this" value 7 info: | 8 [...] 9 4. If the code matched by the syntactic production that is being evaluated is 10 strict mode code, let strict be true, else let strict be false. 11 5. Return ? MakeSuperPropertyReference(propertyKey, strict). 12 13 12.3.5.3 Runtime Semantics: MakeSuperPropertyReference 14 15 1. Let env be GetThisEnvironment( ). 16 2. If env.HasSuperBinding() is false, throw a ReferenceError exception. 17 3. Let actualThis be ? env.GetThisBinding(). 18 4. Let baseValue be ? env.GetSuperBase(). 19 5. Let bv be ? RequireObjectCoercible(baseValue). 20 6. Return a value of type Reference that is a Super Reference whose base 21 value component is bv, whose referenced name component is propertyKey, 22 whose thisValue component is actualThis, and whose strict reference flag 23 is strict. 24 25 GetValue (V) 26 27 1. ReturnIfAbrupt(V). 28 2. If Type(V) is not Reference, return V. 29 3. Let base be GetBase(V). 30 4. If IsUnresolvableReference(V) is true, throw a ReferenceError exception. 31 5. If IsPropertyReference(V) is true, then 32 a. If HasPrimitiveBase(V) is true, then 33 i. Assert: In this case, base will never be null or undefined. 34 ii. Let base be ! ToObject(base). 35 b. Return ? base.[[Get]](GetReferencedName(V), GetThisValue(V)). 36 ---*/ 37 38 var viaCall; 39 var viaMember; 40 var parent = { 41 getThis: function() { 42 return this; 43 }, 44 get This() { 45 return this; 46 } 47 }; 48 var obj = { 49 method() { 50 viaCall = super['getThis'](); 51 viaMember = super['This']; 52 } 53 }; 54 Object.setPrototypeOf(obj, parent); 55 56 obj.method(); 57 58 assert.sameValue(viaCall, obj, 'via CallExpression'); 59 assert.sameValue(viaMember, obj, 'via MemberExpression'); 60 61 reportCompare(0, 0);