equal
deleted
inserted
replaced
30 import java.lang.invoke.MethodHandle; |
30 import java.lang.invoke.MethodHandle; |
31 import java.lang.invoke.MethodHandles; |
31 import java.lang.invoke.MethodHandles; |
32 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; |
32 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; |
33 import org.dynalang.dynalink.CallSiteDescriptor; |
33 import org.dynalang.dynalink.CallSiteDescriptor; |
34 import org.dynalang.dynalink.linker.GuardedInvocation; |
34 import org.dynalang.dynalink.linker.GuardedInvocation; |
|
35 import org.dynalang.dynalink.linker.LinkRequest; |
35 import org.dynalang.dynalink.support.CallSiteDescriptorFactory; |
36 import org.dynalang.dynalink.support.CallSiteDescriptorFactory; |
36 |
37 |
37 |
38 |
38 /** |
39 /** |
39 * This class supports the handling of scope in a with body. |
40 * This class supports the handling of scope in a with body. |
84 return false; |
85 return false; |
85 } |
86 } |
86 |
87 |
87 |
88 |
88 @Override |
89 @Override |
89 public GuardedInvocation lookup(final CallSiteDescriptor desc, final boolean megaMorphic) { |
90 public GuardedInvocation lookup(final CallSiteDescriptor desc, final LinkRequest request) { |
90 // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of |
91 // With scopes can never be observed outside of Nashorn code, so all call sites that can address it will of |
91 // necessity have a Nashorn descriptor - it is safe to cast. |
92 // necessity have a Nashorn descriptor - it is safe to cast. |
92 final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; |
93 final NashornCallSiteDescriptor ndesc = (NashornCallSiteDescriptor)desc; |
93 FindProperty find = null; |
94 FindProperty find = null; |
94 GuardedInvocation link = null; |
95 GuardedInvocation link = null; |
109 if (isNamedOperation) { |
110 if (isNamedOperation) { |
110 find = self.findProperty(name, true); |
111 find = self.findProperty(name, true); |
111 } |
112 } |
112 |
113 |
113 if (find != null) { |
114 if (find != null) { |
114 link = self.lookup(desc); |
115 link = self.lookup(desc, request); |
115 |
116 |
116 if (link != null) { |
117 if (link != null) { |
117 return fixExpressionCallSite(ndesc, link); |
118 return fixExpressionCallSite(ndesc, link); |
118 } |
119 } |
119 } |
120 } |
123 if (isNamedOperation) { |
124 if (isNamedOperation) { |
124 find = scope.findProperty(name, true); |
125 find = scope.findProperty(name, true); |
125 } |
126 } |
126 |
127 |
127 if (find != null) { |
128 if (find != null) { |
128 return fixScopeCallSite(scope.lookup(desc)); |
129 return fixScopeCallSite(scope.lookup(desc, request)); |
129 } |
130 } |
130 |
131 |
131 // the property is not found - now check for |
132 // the property is not found - now check for |
132 // __noSuchProperty__ and __noSuchMethod__ in expression |
133 // __noSuchProperty__ and __noSuchMethod__ in expression |
133 if (self != null) { |
134 if (self != null) { |
153 if (fallBack != null) { |
154 if (fallBack != null) { |
154 find = self.findProperty(fallBack, true); |
155 find = self.findProperty(fallBack, true); |
155 if (find != null) { |
156 if (find != null) { |
156 switch (operator) { |
157 switch (operator) { |
157 case "getMethod": |
158 case "getMethod": |
158 link = self.noSuchMethod(desc); |
159 link = self.noSuchMethod(desc, request); |
159 break; |
160 break; |
160 case "getProp": |
161 case "getProp": |
161 case "getElem": |
162 case "getElem": |
162 link = self.noSuchProperty(desc); |
163 link = self.noSuchProperty(desc, request); |
163 break; |
164 break; |
164 default: |
165 default: |
165 break; |
166 break; |
166 } |
167 } |
167 } |
168 } |
172 } |
173 } |
173 } |
174 } |
174 |
175 |
175 // still not found, may be scope can handle with it's own |
176 // still not found, may be scope can handle with it's own |
176 // __noSuchProperty__, __noSuchMethod__ etc. |
177 // __noSuchProperty__, __noSuchMethod__ etc. |
177 link = scope.lookup(desc); |
178 link = scope.lookup(desc, request); |
178 |
179 |
179 if (link != null) { |
180 if (link != null) { |
180 return fixScopeCallSite(link); |
181 return fixScopeCallSite(link); |
181 } |
182 } |
182 |
183 |