You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/javascript/10_ClassReader.js
+29-4Lines changed: 29 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -53,9 +53,12 @@ var ClassReader = function(name, bytes)
53
53
Logger.debug("Constant pool size: "+constant_pool_size);
54
54
55
55
varpos=10;
56
-
varcp_count=0;
56
+
/**
57
+
* Constants array
58
+
*/
59
+
varconstants=newArray();
57
60
58
-
while(cp_count<constant_pool_size-1)
61
+
while(constants.length<constant_pool_size-1)
59
62
{
60
63
vartag=this.getU1(pos++);
61
64
Logger.debug("Tag: "+tag);
@@ -72,36 +75,51 @@ var ClassReader = function(name, bytes)
72
75
*/
73
76
varstrlen=this.getU2(pos);
74
77
78
+
pos+=2;
79
+
75
80
Logger.debug("String constant: "+strlen);
76
81
77
-
pos+=strlen+2;
82
+
varstr="";
83
+
for(vari=0;i<strlen;i++)
84
+
{
85
+
str+=String.fromCharCode(this.getU1(pos+i));
86
+
}
87
+
88
+
Logger.debug(" String: "+str);
89
+
90
+
constants.push(0);//TODO
91
+
pos+=strlen;
78
92
}
79
93
elseif(tag==3)
80
94
{
81
95
/*
82
96
* 4 bytes Integer: a signed 32-bit two's complement number in big-endian format
83
97
*/
98
+
constants.push(0);//TODO
84
99
pos+=4;
85
100
}
86
101
elseif(tag==4)
87
102
{
88
103
/*
89
104
* 4 bytes Float: a 32-bit single-precision IEEE 754 floating-point number
90
105
*/
106
+
constants.push(0);//TODO
91
107
pos+=4;
92
108
}
93
109
elseif(tag==5)
94
110
{
95
111
/*
96
112
* 8 bytes Long: a signed 64-bit two's complement number in big-endian format (takes two slots in the constant pool table)
97
113
*/
114
+
constants.push(0);//TODO
98
115
pos+=8;
99
116
}
100
117
elseif(tag==6)
101
118
{
102
119
/*
103
120
* 8 bytes Double: a 64-bit double-precision IEEE 754 floating-point number (takes two slots in the constant pool table)
104
121
*/
122
+
constants.push(0);//TODO
105
123
pos+=8;
106
124
}
107
125
elseif(tag==7)
@@ -111,34 +129,39 @@ var ClassReader = function(name, bytes)
111
129
*/
112
130
varref=this.getU2(pos);
113
131
Logger.debug("Class reference: "+ref);
132
+
constants.push(0);//TODO
114
133
pos+=2;
115
134
}
116
135
elseif(tag==8)
117
136
{
118
137
/*
119
138
* 2 bytes String reference: an index within the constant pool to a UTF-8 string
120
139
*/
140
+
constants.push(0);//TODO
121
141
pos+=2;
122
142
}
123
143
elseif(tag==9)
124
144
{
125
145
/*
126
146
* 4 bytes Field reference: two indexes within the constant pool, the first pointing to a Class reference, the second to a Name and Type descriptor.
127
147
*/
148
+
constants.push(0);//TODO
128
149
pos+=4;
129
150
}
130
151
elseif(tag==10)
131
152
{
132
153
/*
133
154
* 4 bytes Method reference: two indexes within the constant pool, the first pointing to a Class reference, the second to a Name and Type descriptor.
134
155
*/
156
+
constants.push(0);//TODO
135
157
pos+=4;
136
158
}
137
159
elseif(tag==11)
138
160
{
139
161
/*
140
162
* 4 bytes Interface method reference: two indexes within the constant pool, the first pointing to a Class reference, the second to a Name and Type descriptor.
141
163
*/
164
+
constants.push(0);//TODO
142
165
pos+=4;
143
166
}
144
167
elseif(tag==12)
@@ -147,13 +170,15 @@ var ClassReader = function(name, bytes)
147
170
* 4 bytes Name and type descriptor: two indexes to UTF-8 strings within the constant pool, the first representing a name (identifier)
148
171
* and the second a specially encoded type descriptor.
0 commit comments