Skip to content

Commit b8141aa

Browse files
committed
Use class to parse message.
1 parent 2c42832 commit b8141aa

File tree

5 files changed

+270
-51
lines changed

5 files changed

+270
-51
lines changed

src/client-en.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ window.load_screen_timeout = window.setTimeout(function()
361361

362362
<script src="./ecma-debugger/helpers.js"/>
363363
<script src="./ecma-debugger/tabs.js"/>
364+
<script src="./ecma-debugger/ecmascriptdebugger.6.14.responses.getbacktrace.js"/>
364365

365366
<script src="./ecma-debugger/templates.js"/>
366367
<script src="./ecma-debugger/newscript.js"/>
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
// Autogenerated by hob
2+
window.cls || (window.cls = {});
3+
cls.EcmascriptDebugger || (cls.EcmascriptDebugger = {});
4+
cls.EcmascriptDebugger["6.14"] || (cls.EcmascriptDebugger["6.14"] = {});
5+
6+
/**
7+
* Frames are in innermost-first order.
8+
*/
9+
cls.EcmascriptDebugger["6.14"].BacktraceFrameList = function(arr)
10+
{
11+
this.frameList = (arr[0] || []).map(function(item)
12+
{
13+
return new cls.EcmascriptDebugger["6.14"].BacktraceFrame(item);
14+
});
15+
/**
16+
* The list of return values that were returned from the most recent
17+
* function calls. List is cleared upon calling a function.
18+
* Most recently returned value is first in the list.
19+
*
20+
* @since 6.10
21+
*/
22+
this.returnValueList = (arr[1] || []).map(function(item)
23+
{
24+
return new cls.EcmascriptDebugger["6.14"].ReturnValue(item);
25+
});
26+
};
27+
28+
cls.EcmascriptDebugger["6.14"].BacktraceFrame = function(arr)
29+
{
30+
this.functionID = arr[0];
31+
this.argumentObject = arr[1];
32+
this.variableObject = arr[2];
33+
this.thisObject = arr[3];
34+
/**
35+
* TODO: Spec says repeated, while the code only assumes one (required)
36+
*/
37+
this.objectValue = arr[4] ? new cls.EcmascriptDebugger["6.14"].ObjectValue(arr[4], this) : null;
38+
this.scriptID = arr[5];
39+
this.lineNumber = arr[6];
40+
/**
41+
* The variable objects in the scope chain of the function. The first
42+
* element in the list is the innermost scope (the scope of the function
43+
* itself). The list includes the global scope.
44+
*
45+
* @since 6.1
46+
*/
47+
this.scopeList = arr[7] || [];
48+
/**
49+
* The full value of the 'arguments' object.
50+
*
51+
* @since 6.2
52+
*/
53+
this.argumentValue = arr[8] ? new cls.EcmascriptDebugger["6.14"].ObjectValue(arr[8], this) : null;
54+
/**
55+
* The full value of the 'this' object.
56+
*
57+
* @since 6.2
58+
*/
59+
this.thisValue = arr[9] ? new cls.EcmascriptDebugger["6.14"].ObjectValue(arr[9], this) : null;
60+
};
61+
62+
cls.EcmascriptDebugger["6.14"].ObjectValue = function(arr)
63+
{
64+
this.objectID = arr[0];
65+
this.isCallable = arr[1];
66+
/**
67+
* type, function or object
68+
*/
69+
this.type = arr[2];
70+
this.prototypeID = arr[3];
71+
/**
72+
* The class of the object.
73+
*/
74+
this.className = arr[4];
75+
/**
76+
* If the object is a function, this is the name of
77+
* the variable associated with that function (if any).
78+
*/
79+
this.functionName = arr[5];
80+
};
81+
82+
/**
83+
* The object representing return value of a function. Includes context
84+
* information indicating where from and where to the value was returned (script
85+
* id, line number), returned value and function object itself that returned
86+
* the value.
87+
*
88+
* @since 6.10
89+
*/
90+
cls.EcmascriptDebugger["6.14"].ReturnValue = function(arr)
91+
{
92+
/**
93+
* The value that was returned.
94+
*/
95+
this.value = arr[0] ? new cls.EcmascriptDebugger["6.14"].Value(arr[0], this) : null;
96+
/**
97+
* The function object from which the value was returned.
98+
*/
99+
this.functionFrom = arr[1] ? new cls.EcmascriptDebugger["6.14"].ObjectValue(arr[1], this) : null;
100+
/**
101+
* The position where the value was returned from.
102+
*/
103+
this.positionFrom = arr[2] ? new cls.EcmascriptDebugger["6.14"].Position(arr[2], this) : null;
104+
/**
105+
* The position where the value was returned to.
106+
*/
107+
this.positionTo = arr[3] ? new cls.EcmascriptDebugger["6.14"].Position(arr[3], this) : null;
108+
};
109+
110+
/**
111+
* Represents an ECMAScript value, a value is either one of the primitives
112+
* like string or boolean or an object.
113+
*/
114+
cls.EcmascriptDebugger["6.14"].Value = function(arr)
115+
{
116+
/**
117+
* The type of value.
118+
*
119+
* @note Booleans are encoded as either TRUE or FALSE to shorten the number
120+
* fields in use.
121+
*/
122+
// cls.EcmascriptDebugger["6.14"].Value.Type
123+
this.type = arr[0];
124+
/**
125+
* The numeric value, set if type = NUMBER.
126+
*/
127+
this.number = arr[1];
128+
/**
129+
* The string, set if type = STRING.
130+
*/
131+
this.str = arr[2];
132+
/**
133+
* Object information, set if type = OBJECT.
134+
*/
135+
this.object = arr[3] ? new cls.EcmascriptDebugger["6.14"].ObjectValue(arr[3], this) : null;
136+
};
137+
cls.EcmascriptDebugger["6.14"].Value.Type =
138+
{
139+
/**
140+
* The undefined type, returned when no value was found or "undefined"
141+
* was referenced.
142+
*/
143+
0: "UNDEFINED",
144+
/**
145+
* A null value.
146+
*/
147+
1: "NULL",
148+
/**
149+
* Boolean value true.
150+
*/
151+
2: "TRUE",
152+
/**
153+
* Boolean value false.
154+
*/
155+
3: "FALSE",
156+
/**
157+
* NaN value which cannot be exported to JSON directly.
158+
* Should be treated like a number.
159+
*
160+
* ECMAScript users should use this code to get the value natively::
161+
*
162+
* parseFloat("NaN")
163+
*/
164+
4: "NAN",
165+
/**
166+
* Plus infinity value which cannot be export to JSON directly.
167+
* Should be treated like a number.
168+
*
169+
* ECMAScript users should use this code to get the value natively::
170+
*
171+
* parseFloat("Infinity")
172+
*/
173+
5: "PLUS_INFINITY",
174+
/**
175+
* Minus infinity value which cannot be export to JSON directly.
176+
* Should be treated like a number.
177+
*
178+
* ECMAScript users should use this code to get the value natively::
179+
*
180+
* parseFloat("-Infinity")
181+
*/
182+
6: "MINUS_INFINITY",
183+
/**
184+
* A number, use the field 'number' for the actual value.
185+
*/
186+
7: "NUMBER",
187+
/**
188+
* A string, use the field 'str' for the actual string data.
189+
*/
190+
8: "STRING",
191+
/**
192+
* An object, the field 'object' contains object details.
193+
*/
194+
9: "OBJECT",
195+
};
196+
197+
/**
198+
* Defines the position in a script. The position is identified by the ID of
199+
* the script and the line number in the script.
200+
*/
201+
cls.EcmascriptDebugger["6.14"].Position = function(arr)
202+
{
203+
/**
204+
* ID of the script which contains the position.
205+
* The ID will be set in the ScriptInfo message when a new script appears.
206+
*/
207+
this.scriptID = arr[0];
208+
/**
209+
* The line number in the script.
210+
*/
211+
this.lineNumber = arr[1];
212+
};
213+

src/ecma-debugger/stop_at.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ cls.EcmascriptDebugger["6.0"].StopAt = function()
6161
var runtime_id = '';
6262

6363
var callstack = [];
64-
var return_values = [];
64+
var return_values = {};
6565

6666
var __script_ids_in_callstack = [];
6767

@@ -257,19 +257,14 @@ cls.EcmascriptDebugger["6.0"].StopAt = function()
257257
__script_ids_in_callstack[i] = frame[SCRIPT_ID];
258258
}
259259

260-
var return_value_list = message[RETURN_VALUE_LIST];
260+
var backtrace_frame_list = new cls.EcmascriptDebugger["6.14"].BacktraceFrameList(message);
261+
var return_value_list = backtrace_frame_list && backtrace_frame_list.returnValueList;
261262
if (return_value_list)
262263
{
263-
return_values = return_value_list.map(function(retval) {
264-
return {
265-
value: retval[0],
266-
function_from: retval[1],
267-
position_from: retval[2],
268-
position_to: retval[3],
269-
rt_id: stop_at.runtime_id,
270-
model: null
271-
};
272-
});
264+
return_values = {
265+
rt_id: stop_at.runtime_id,
266+
return_value_list: return_value_list
267+
};
273268
}
274269

275270
if( cur_inspection_type != 'frame' )
@@ -333,7 +328,7 @@ cls.EcmascriptDebugger["6.0"].StopAt = function()
333328
{
334329
this._clear_stop_at_error();
335330
callstack = [];
336-
return_values = [];
331+
return_values = {};
337332
__script_ids_in_callstack = [];
338333
runtimes.setObserve(stopAt.runtime_id, mode != 'run');
339334
messages.post('frame-selected', {frame_index: -1});
@@ -355,7 +350,7 @@ cls.EcmascriptDebugger["6.0"].StopAt = function()
355350
{
356351
this._clear_stop_at_error();
357352
callstack = [];
358-
return_values = [];
353+
return_values = {};
359354
__script_ids_in_callstack = [];
360355
messages.post('frame-selected', {frame_index: -1});
361356
__controls_enabled = false;

0 commit comments

Comments
 (0)