@@ -950,6 +950,75 @@ class Writer
950950 writeExpr (e );
951951 }
952952
953+ function writeEArray (e : Expr , index : Expr ) {
954+ // write("/* EArray ("+Std.string(e)+","+Std.string(index)+") " + Std.string(getExprType(e, true)) + " */ ");
955+ var old = inArrayAccess ;
956+ inArrayAccess = true ;
957+ // this test can be generalized to any array[]->get() translation
958+ var etype = getExprType (e );
959+ var itype = getExprType (index );
960+ if (etype == " FastXML" || etype == " FastXMLList" ) {
961+ writeExpr (e );
962+ inArrayAccess = old ;
963+ write (" .get(" );
964+ writeExpr (index );
965+ write (" )" );
966+ } else if (isMapType (etype )) {
967+ writeExpr (e );
968+ inArrayAccess = old ;
969+ var oldInLVA = inLvalAssign ;
970+ inLvalAssign = false ;
971+ if (oldInLVA ) {
972+ write (" .set(" );
973+ } else {
974+ write (" .get(" );
975+ }
976+ writeExpr (index );
977+ if (oldInLVA ) {
978+ write (" , " );
979+ writeExpr (rvalue );
980+ rvalue = null ;
981+ }
982+ inLvalAssign = oldInLVA ;
983+ write (" )" );
984+ } else {
985+ // write("/*!!!" + etype + "!!!*/");
986+ if (isDynamicType (etype ) || ((isArrayType (etype ) || e .match (EIdent (_ ))) && itype != null && itype != " Int" && itype != " UInt" )) {
987+ if (cfg .debugInferredType ) {
988+ write (" /* etype: " + etype + " itype: " + itype + " */" );
989+ }
990+ var isString = (itype == " String" );
991+ var oldInLVA = inLvalAssign ;
992+ inLvalAssign = false ;
993+ if (oldInLVA )
994+ write (" Reflect.setField(" );
995+ else
996+ write (" Reflect.field(" );
997+ writeExpr (e );
998+ inArrayAccess = old ;
999+ write (" , " );
1000+ if (! isString )
1001+ write (" Std.string(" );
1002+ writeExpr (index );
1003+ if (! isString )
1004+ write (" )" );
1005+ if (oldInLVA ) {
1006+ write (" , " );
1007+ writeExpr (rvalue );
1008+ rvalue = null ;
1009+ }
1010+ inLvalAssign = oldInLVA ;
1011+ write (" )" );
1012+ } else {
1013+ writeExpr (e );
1014+ inArrayAccess = old ;
1015+ write (" [" );
1016+ writeExpr (index );
1017+ write (" ]" );
1018+ }
1019+ }
1020+ }
1021+
9531022 function writeLoop (incrs : Array <Expr >, f : Void -> Void ) {
9541023 var old = loopIncrements ;
9551024 loopIncrements = incrs .slice (0 );
@@ -1122,73 +1191,7 @@ class Writer
11221191 case EContinue : rv = writeEContinue ();
11231192 case EFunction (f , name ): writeFunction (f , false , false , false , name );
11241193 case EReturn (e ): writeEReturn (e );
1125- case EArray (e , index ):
1126- // write("/* EArray ("+Std.string(e)+","+Std.string(index)+") " + Std.string(getExprType(e, true)) + " */ ");
1127- var old = inArrayAccess ;
1128- inArrayAccess = true ;
1129- // this test can be generalized to any array[]->get() translation
1130- var etype = getExprType (e );
1131- var itype = getExprType (index );
1132- if (etype == " FastXML" || etype == " FastXMLList" ) {
1133- writeExpr (e );
1134- inArrayAccess = old ;
1135- write (" .get(" );
1136- writeExpr (index );
1137- write (" )" );
1138- } else if (isMapType (etype )) {
1139- writeExpr (e );
1140- inArrayAccess = old ;
1141- var oldInLVA = inLvalAssign ;
1142- inLvalAssign = false ;
1143- if (oldInLVA ) {
1144- write (" .set(" );
1145- } else {
1146- write (" .get(" );
1147- }
1148- writeExpr (index );
1149- if (oldInLVA ) {
1150- write (" , " );
1151- writeExpr (rvalue );
1152- rvalue = null ;
1153- }
1154- inLvalAssign = oldInLVA ;
1155- write (" )" );
1156- } else {
1157- // write("/*!!!" + etype + "!!!*/");
1158- if (isDynamicType (etype ) || (isArrayType (etype ) && itype != null && itype != " Int" && itype != " UInt" )) {
1159- if (cfg .debugInferredType ) {
1160- write (" /* etype: " + etype + " itype: " + itype + " */" );
1161- }
1162- var isString = (itype == " String" );
1163- var oldInLVA = inLvalAssign ;
1164- inLvalAssign = false ;
1165- if (oldInLVA )
1166- write (" Reflect.setField(" );
1167- else
1168- write (" Reflect.field(" );
1169- writeExpr (e );
1170- inArrayAccess = old ;
1171- write (" , " );
1172- if (! isString )
1173- write (" Std.string(" );
1174- writeExpr (index );
1175- if (! isString )
1176- write (" )" );
1177- if (oldInLVA ) {
1178- write (" , " );
1179- writeExpr (rvalue );
1180- rvalue = null ;
1181- }
1182- inLvalAssign = oldInLVA ;
1183- write (" )" );
1184- } else {
1185- writeExpr (e );
1186- inArrayAccess = old ;
1187- write (" [" );
1188- writeExpr (index );
1189- write (" ]" );
1190- }
1191- }
1194+ case EArray (e , index ): writeEArray (e , index );
11921195 case EArrayDecl (e ):
11931196 var enl = false ;
11941197 write (" [" );
@@ -3043,7 +3046,7 @@ class Writer
30433046 * Checks if 'e' represents a numerical constant value
30443047 * @return true if so
30453048 */
3046- static inline function isNumericConst (e : Expr ) : Bool return switch (e ) {
3049+ static inline function isNumericConst (e : Expr ): Bool return switch (e ) {
30473050 case EConst (c ): c .match (CInt (_ )) || c .match (CFloat (_ ));
30483051 default : false ;
30493052 }
0 commit comments