Skip to content

Commit bcd421b

Browse files
Restore compatibility with haxe prior to 4.1 (#148)
1 parent eed530b commit bcd421b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

hscript/Interp.hx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@ class Interp {
658658
isAllObject = isAllObject && Reflect.isObject(key);
659659
isAllEnum = isAllEnum && Reflect.isEnumValue(key);
660660
}
661+
662+
#if (haxe_ver >= 4.1)
661663
if( isAllInt ) {
662664
var m = new Map<Int,Dynamic>();
663665
for( i => key in keys )
@@ -682,6 +684,20 @@ class Interp {
682684
m.set(key, values[i]);
683685
return m;
684686
}
687+
#else
688+
var m:Dynamic = {
689+
if ( isAllInt ) new haxe.ds.IntMap<Dynamic>();
690+
else if ( isAllString ) new haxe.ds.StringMap<Dynamic>();
691+
else if ( isAllEnum ) new haxe.ds.EnumValueMap<Dynamic, Dynamic>();
692+
else if ( isAllObject ) new haxe.ds.ObjectMap<Dynamic, Dynamic>();
693+
else null;
694+
}
695+
if( m != null ) {
696+
for ( n in 0...keys.length )
697+
setMapValue(m, keys[n], values[n]);
698+
return m;
699+
}
700+
#end
685701
error(ECustom("Invalid map keys "+keys));
686702
return null;
687703
}

0 commit comments

Comments
 (0)