@@ -47,7 +47,10 @@ public class Binding {
4747 * frame of method which defined this block
4848 */
4949 private final Frame frame ;
50- private final BacktraceElement backtrace ;
50+
51+ public String method ;
52+ public String filename ;
53+ public int line ;
5154
5255 private Visibility visibility ;
5356 /**
@@ -75,36 +78,42 @@ public class Binding {
7578 * instances.
7679 */
7780 private Binding evalScopeBinding = this ;
78-
81+
7982 public Binding (IRubyObject self , Frame frame ,
80- Visibility visibility , DynamicScope dynamicScope , BacktraceElement backtrace ) {
83+ Visibility visibility , DynamicScope dynamicScope , String method , String filename , int line ) {
8184 this .self = self ;
8285 this .frame = frame ;
8386 this .visibility = visibility ;
8487 this .dynamicScope = dynamicScope ;
85- this .backtrace = backtrace ;
88+ this .method = method ;
89+ this .filename = filename ;
90+ this .line = line ;
8691 }
8792
8893 private Binding (IRubyObject self , Frame frame ,
89- Visibility visibility , DynamicScope dynamicScope , BacktraceElement backtrace , DynamicScope dummyScope ) {
94+ Visibility visibility , DynamicScope dynamicScope , String method , String filename , int line , DynamicScope dummyScope ) {
9095 this .self = self ;
9196 this .frame = frame ;
9297 this .visibility = visibility ;
9398 this .dynamicScope = dynamicScope ;
94- this .backtrace = backtrace ;
99+ this .method = method ;
100+ this .filename = filename ;
101+ this .line = line ;
95102 this .dummyScope = dummyScope ;
96103 }
97104
98- public Binding (Frame frame , DynamicScope dynamicScope , BacktraceElement backtrace ) {
105+ public Binding (Frame frame , DynamicScope dynamicScope , String method , String filename , int line ) {
99106 this .self = frame .getSelf ();
100107 this .frame = frame ;
101108 this .visibility = frame .getVisibility ();
102109 this .dynamicScope = dynamicScope ;
103- this .backtrace = backtrace ;
110+ this .method = method ;
111+ this .filename = filename ;
112+ this .line = line ;
104113 }
105114
106115 private Binding (Binding other ) {
107- this (other .self , other .frame , other .visibility , other .dynamicScope , other .backtrace , other .dummyScope );
116+ this (other .self , other .frame , other .visibility , other .dynamicScope , other .method , other . filename , other . line , other .dummyScope );
108117 }
109118
110119 /**
@@ -173,32 +182,28 @@ public Frame getFrame() {
173182 return frame ;
174183 }
175184
176- public BacktraceElement getBacktrace () {
177- return backtrace ;
178- }
179-
180185 public String getFile () {
181- return backtrace . filename ;
186+ return filename ;
182187 }
183188
184- public void setFile (String file ) {
185- backtrace .filename = file ;
189+ public void setFile (String filename ) {
190+ this .filename = filename ;
186191 }
187192
188193 public int getLine () {
189- return backtrace . line ;
194+ return line ;
190195 }
191196
192197 public void setLine (int line ) {
193- backtrace .line = line ;
198+ this .line = line ;
194199 }
195200
196201 public String getMethod () {
197- return backtrace . method ;
202+ return method ;
198203 }
199204
200205 public void setMethod (String method ) {
201- backtrace .method = method ;
206+ this .method = method ;
202207 }
203208
204209 public boolean equals (Object other ) {
@@ -235,4 +240,32 @@ public final DynamicScope getEvalScope(Ruby runtime) {
235240
236241 return evalScopeBinding .evalScope ;
237242 }
243+
244+ @ Deprecated
245+ public Binding (IRubyObject self , Frame frame ,
246+ Visibility visibility , DynamicScope dynamicScope , BacktraceElement backtrace ) {
247+ this .self = self ;
248+ this .frame = frame ;
249+ this .visibility = visibility ;
250+ this .dynamicScope = dynamicScope ;
251+ this .method = backtrace .method ;
252+ this .filename = backtrace .filename ;
253+ this .line = backtrace .line ;
254+ }
255+
256+ @ Deprecated
257+ public Binding (Frame frame , DynamicScope dynamicScope , BacktraceElement backtrace ) {
258+ this .self = frame .getSelf ();
259+ this .frame = frame ;
260+ this .visibility = frame .getVisibility ();
261+ this .dynamicScope = dynamicScope ;
262+ this .method = backtrace .method ;
263+ this .filename = backtrace .filename ;
264+ this .line = backtrace .line ;
265+ }
266+
267+ @ Deprecated
268+ public BacktraceElement getBacktrace () {
269+ return new BacktraceElement (method , filename , line );
270+ }
238271}
0 commit comments