|
@@ -3358,7 +3358,8 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
|
3358
|
3358
|
javaWriter.label(end);
|
3359
|
3359
|
return;
|
3360
|
3360
|
}
|
3361
|
|
- case ARRAY_CONSTRUCTOR_PROJECTED: {
|
|
3361
|
+ case ARRAY_CONSTRUCTOR_PROJECTED:
|
|
3362
|
+ case ARRAY_CONSTRUCTOR_PROJECTED_INDEXED: {
|
3362
|
3363
|
ArrayTypeID type = (ArrayTypeID) expression.type.type;
|
3363
|
3364
|
|
3364
|
3365
|
//Labels
|
|
@@ -3373,7 +3374,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
|
3373
|
3374
|
javaWriter.storeObject(originArrayLocation);
|
3374
|
3375
|
Type destinationArrayType = context.getType(expression.type);
|
3375
|
3376
|
|
3376
|
|
-
|
|
3377
|
+ final boolean indexed = builtin == BuiltinID.ARRAY_CONSTRUCTOR_PROJECTED_INDEXED;
|
3377
|
3378
|
final boolean canBeInLined = ArrayInitializerHelper.canBeInLined(expression.arguments.arguments[1]);
|
3378
|
3379
|
if (canBeInLined) {
|
3379
|
3380
|
//We can inline, so do it
|
|
@@ -3392,6 +3393,14 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
|
3392
|
3393
|
JavaExpressionVisitor visitor = new JavaExpressionVisitor(context, module, javaWriter) {
|
3393
|
3394
|
@Override
|
3394
|
3395
|
public Void visitGetFunctionParameter(GetFunctionParameterExpression expression) {
|
|
3396
|
+ if(indexed) {
|
|
3397
|
+ final JavaParameterInfo parameterInfo = module.getParameterInfo(expression.parameter);
|
|
3398
|
+ if (parameterInfo != null && parameterInfo.index <= type.dimension) {
|
|
3399
|
+ javaWriter.loadInt(counterLocations[parameterInfo.index - 1]);
|
|
3400
|
+ return null;
|
|
3401
|
+ }
|
|
3402
|
+ }
|
|
3403
|
+
|
3395
|
3404
|
javaWriter.load(projectedElementType, projectedElementLocal);
|
3396
|
3405
|
return null;
|
3397
|
3406
|
}
|
|
@@ -3403,8 +3412,10 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
|
3403
|
3412
|
}
|
3404
|
3413
|
|
3405
|
3414
|
if (funcExpression instanceof FunctionExpression && ((FunctionExpression) funcExpression).body instanceof ReturnStatement) {
|
|
3415
|
+ CompilerUtils.tagMethodParameters(context, module, ((FunctionExpression) funcExpression).header, false);
|
3406
|
3416
|
((ReturnStatement) ((FunctionExpression) funcExpression).body).value.accept(visitor);
|
3407
|
3417
|
javaWriter.addVariableInfo(new JavaLocalVariableInfo(projectedElementType, projectedElementLocal, inlineBegin, ((FunctionExpression) funcExpression).header.parameters[0].name, inlineEnd));
|
|
3418
|
+
|
3408
|
3419
|
} else throw new IllegalStateException("Trying to inline a non-inlineable expression");
|
3409
|
3420
|
|
3410
|
3421
|
|
|
@@ -3424,6 +3435,13 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
|
3424
|
3435
|
javaWriter.loadObject(functionLocation);
|
3425
|
3436
|
javaWriter.swap();
|
3426
|
3437
|
|
|
3438
|
+ if(indexed) {
|
|
3439
|
+ for (int counterLocation : counterLocations) {
|
|
3440
|
+ javaWriter.loadInt(counterLocation);
|
|
3441
|
+ javaWriter.swap();
|
|
3442
|
+ }
|
|
3443
|
+ }
|
|
3444
|
+
|
3427
|
3445
|
javaWriter.invokeInterface(context.getFunctionalInterface(expression.arguments.arguments[1].type));
|
3428
|
3446
|
});
|
3429
|
3447
|
}
|
|
@@ -3433,26 +3451,6 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
|
3433
|
3451
|
return;
|
3434
|
3452
|
|
3435
|
3453
|
}
|
3436
|
|
- case ARRAY_CONSTRUCTOR_PROJECTED_INDEXED: {
|
3437
|
|
- ArrayTypeID type = (ArrayTypeID) expression.type.type;
|
3438
|
|
-
|
3439
|
|
- if (type.dimension == 1) {
|
3440
|
|
- // original = arguments[0] (this is an array)
|
3441
|
|
- // projector = arguments[1] (this is a lambda with 2 parameters)
|
3442
|
|
- // array = new T[original.length]
|
3443
|
|
- // for (int i = 0; i < array.length; i++)
|
3444
|
|
- // array[i] = projector(i, original[i]);
|
3445
|
|
- //
|
3446
|
|
- // NOTE: arguments[1] can be a FunctionExpression; this can be optimized by running it inline
|
3447
|
|
-
|
3448
|
|
- // TODO: implement in bytecode
|
3449
|
|
-
|
3450
|
|
- return;
|
3451
|
|
- } else {
|
3452
|
|
- // TODO: implement
|
3453
|
|
- throw new UnsupportedOperationException("Not yet supported!");
|
3454
|
|
- }
|
3455
|
|
- }
|
3456
|
3454
|
case ARRAY_INDEXGET:
|
3457
|
3455
|
break;
|
3458
|
3456
|
case ARRAY_INDEXSET:
|