Skip to content

Commit ce81886

Browse files
authored
Replace Type.enumIndex with manual index. (HaxeFoundation#145)
1 parent 6f04809 commit ce81886

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

hscript/Bytes.hx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class Bytes {
122122
doEncodeInt(e.line);
123123
var e = e.e;
124124
#end
125-
bout.addByte(Type.enumIndex(e));
125+
bout.addByte(exprIndex(e));
126126
switch( e ) {
127127
case EConst(c):
128128
doEncodeConst(c);
@@ -238,6 +238,39 @@ class Bytes {
238238
}
239239
}
240240

241+
function exprIndex(e):Int {
242+
return switch (e) {
243+
case EConst(_): 0;
244+
case EIdent(_): 1;
245+
case EVar(_): 2;
246+
case EParent(_): 3;
247+
case EBlock(_): 4;
248+
case EField(_): 5;
249+
case EBinop(_): 6;
250+
case EUnop(_): 7;
251+
case ECall(_): 8;
252+
case EIf(_): 9;
253+
case EWhile(_): 10;
254+
case EFor(_): 11;
255+
case EBreak: 12;
256+
case EContinue: 13;
257+
case EFunction(_): 14;
258+
case EReturn(_): 15;
259+
case EArray(_): 16;
260+
case EArrayDecl(_): 17;
261+
case ENew(_): 18;
262+
case EThrow(_): 19;
263+
case ETry(_): 20;
264+
case EObject(_): 21;
265+
case ETernary(_): 22;
266+
case ESwitch(_): 23;
267+
case EDoWhile(_): 24;
268+
case EMeta(_): 25;
269+
case ECheckType(_): 26;
270+
case EForGen(_): 27;
271+
}
272+
}
273+
241274
function doDecode() : Expr {
242275
#if hscriptPos
243276
if (bin.get(pin) == 255) {

0 commit comments

Comments
 (0)