mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
Switch the parameter order for lambda expressions
This commit is contained in:
parent
84f2f45d4c
commit
1f045f312d
@ -191,6 +191,9 @@ class LocaleVariableManager {
|
|||||||
}
|
}
|
||||||
resetAddVar( null, i );
|
resetAddVar( null, i );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// in Eclipse for lambda expression only the method parameters has an entry in the variable table. But the not define parameter of the lambda constructor come before.
|
||||||
|
Arrays.sort( variables, 0, size );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -455,7 +458,7 @@ class LocaleVariableManager {
|
|||||||
/**
|
/**
|
||||||
* The state of a single local variable slot.
|
* The state of a single local variable slot.
|
||||||
*/
|
*/
|
||||||
private static class Variable {
|
private static class Variable implements Comparable<Variable> {
|
||||||
|
|
||||||
private AnyType valueType;
|
private AnyType valueType;
|
||||||
|
|
||||||
@ -477,5 +480,13 @@ class LocaleVariableManager {
|
|||||||
public boolean matchCodePosition( int codePosition ) {
|
public boolean matchCodePosition( int codePosition ) {
|
||||||
return startPos <= codePosition && codePosition <= endPos;
|
return startPos <= codePosition && codePosition <= endPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int compareTo( Variable o ) {
|
||||||
|
return Integer.compare( idx, o.idx );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2018 - 2021 Volker Berlin (i-net software)
|
Copyright 2018 - 2022 Volker Berlin (i-net software)
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@ -1208,6 +1208,13 @@ public class TypeManager {
|
|||||||
}
|
}
|
||||||
watParser.reset( null, null, sig.iterator() );
|
watParser.reset( null, null, sig.iterator() );
|
||||||
|
|
||||||
|
// first add the values from the Lambda constructor which is saves in the syntetic class
|
||||||
|
for( int i = 0; i < paramFields.size(); i++ ) {
|
||||||
|
codebuilder.addLoadStoreInstruction( LambdaType.this, true, 0, 0, -1 );
|
||||||
|
codebuilder.addStructInstruction( StructOperator.GET, name, paramFields.get( i ), 0, -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// forward the parameter from the current call without the THIS parameter because the call lambda method is static
|
||||||
for( int i = 1; i < sig.size(); i++ ) {
|
for( int i = 1; i < sig.size(); i++ ) {
|
||||||
AnyType anyType = sig.get( i );
|
AnyType anyType = sig.get( i );
|
||||||
if( anyType == null ) {
|
if( anyType == null ) {
|
||||||
@ -1216,11 +1223,6 @@ public class TypeManager {
|
|||||||
codebuilder.addLoadStoreInstruction( anyType, true, i, 0, -1 );
|
codebuilder.addLoadStoreInstruction( anyType, true, i, 0, -1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
for( int i = 0; i < paramFields.size(); i++ ) {
|
|
||||||
codebuilder.addLoadStoreInstruction( LambdaType.this, true, 0, 0, -1 );
|
|
||||||
codebuilder.addStructInstruction( StructOperator.GET, name, paramFields.get( i ), 0, -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
codebuilder.addCallInstruction( syntheticLambdaFunctionName, false, 0, -1 );
|
codebuilder.addCallInstruction( syntheticLambdaFunctionName, false, 0, -1 );
|
||||||
return watParser;
|
return watParser;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2018 - 2021 Volker Berlin (i-net software)
|
* Copyright 2018 - 2022 Volker Berlin (i-net software)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -19,6 +19,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.DoubleUnaryOperator;
|
||||||
import java.util.function.IntSupplier;
|
import java.util.function.IntSupplier;
|
||||||
import java.util.function.IntUnaryOperator;
|
import java.util.function.IntUnaryOperator;
|
||||||
|
|
||||||
@ -315,11 +316,11 @@ public class StructsNonGC extends AbstractBaseTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Export
|
@Export
|
||||||
static int lambda3() {
|
static double lambda3() {
|
||||||
int v1 = 42;
|
int v1 = 42;
|
||||||
int v2 = 7;
|
int v2 = 7;
|
||||||
IntUnaryOperator val = (x) -> x + v2 + v1;
|
DoubleUnaryOperator val = (x) -> x * v2 + v1;
|
||||||
return val.applyAsInt( 13 );
|
return val.applyAsDouble( 13 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Export
|
@Export
|
||||||
|
Loading…
x
Reference in New Issue
Block a user