Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/proxy.js

Issue 7348008: Merge up to 8597 to experimental/gc from the bleeding edge. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.cc ('k') | src/regexp.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 "constructTrap", 53 "constructTrap",
54 ] 54 ]
55 55
56 $Proxy.createFunction = function(handler, callTrap, constructTrap) { 56 $Proxy.createFunction = function(handler, callTrap, constructTrap) {
57 handler.callTrap = callTrap 57 handler.callTrap = callTrap
58 handler.constructTrap = constructTrap 58 handler.constructTrap = constructTrap
59 $Proxy.create(handler) 59 $Proxy.create(handler)
60 } 60 }
61 61
62 $Proxy.create = function(handler, proto) { 62 $Proxy.create = function(handler, proto) {
63 if (!IS_SPEC_OBJECT(proto)) proto = $Object.prototype 63 if (!IS_SPEC_OBJECT(handler))
64 throw MakeTypeError("handler_non_object", ["create"])
65 if (!IS_SPEC_OBJECT(proto)) proto = null // Mozilla does this...
64 return %CreateJSProxy(handler, proto) 66 return %CreateJSProxy(handler, proto)
65 } 67 }
66 68
67 69
68 70
69 71
70 //////////////////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////////////////
71 // Builtins 73 // Builtins
72 //////////////////////////////////////////////////////////////////////////////// 74 ////////////////////////////////////////////////////////////////////////////////
73 75
74 function DerivedGetTrap(receiver, name) { 76 function DerivedGetTrap(receiver, name) {
75 var desc = this.getPropertyDescriptor(name) 77 var desc = this.getPropertyDescriptor(name)
76 if (IS_UNDEFINED(desc)) { return desc; } 78 if (IS_UNDEFINED(desc)) { return desc }
77 if ('value' in desc) { 79 if ('value' in desc) {
78 return desc.value 80 return desc.value
79 } else { 81 } else {
80 if (IS_UNDEFINED(desc.get)) { return desc.get; } 82 if (IS_UNDEFINED(desc.get)) { return desc.get }
81 return desc.get.call(receiver) // The proposal says so... 83 // The proposal says: desc.get.call(receiver)
84 return %_CallFunction(receiver, desc.get)
82 } 85 }
83 } 86 }
87
88 function DerivedSetTrap(receiver, name, val) {
89 var desc = this.getOwnPropertyDescriptor(name)
90 if (desc) {
91 if ('writable' in desc) {
92 if (desc.writable) {
93 desc.value = val
94 this.defineProperty(name, desc)
95 return true
96 } else {
97 return false
98 }
99 } else { // accessor
100 if (desc.set) {
101 // The proposal says: desc.set.call(receiver, val)
102 %_CallFunction(receiver, val, desc.set)
103 return true
104 } else {
105 return false
106 }
107 }
108 }
109 desc = this.getPropertyDescriptor(name)
110 if (desc) {
111 if ('writable' in desc) {
112 if (desc.writable) {
113 // fall through
114 } else {
115 return false
116 }
117 } else { // accessor
118 if (desc.set) {
119 // The proposal says: desc.set.call(receiver, val)
120 %_CallFunction(receiver, val, desc.set)
121 return true
122 } else {
123 return false
124 }
125 }
126 }
127 this.defineProperty(name, {
128 value: val,
129 writable: true,
130 enumerable: true,
131 configurable: true});
132 return true;
133 }
134
135 function DerivedHasTrap(name) {
136 return !!this.getPropertyDescriptor(name)
137 }
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | src/regexp.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698