prop-dot-obj-val-from-eval.js (1465B)
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: Value of reference returned by SuperProperty (from eval code) 7 info: | 8 1. Let propertyKey be StringValue of IdentifierName. 9 2. 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 3. 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 26 var fromA, fromB; 27 var A = { fromA: 'a', fromB: 'a' }; 28 var B = { fromB: 'b' }; 29 Object.setPrototypeOf(B, A); 30 31 var obj = { 32 fromA: 'c', 33 fromB: 'c', 34 method() { 35 fromA = eval('super.fromA;'); 36 fromB = eval('super.fromB;'); 37 } 38 }; 39 40 Object.setPrototypeOf(obj, B); 41 42 obj.method(); 43 44 assert.sameValue(fromA, 'a'); 45 assert.sameValue(fromB, 'b'); 46 47 reportCompare(0, 0);