groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Sun <realblue...@hotmail.com>
Subject Re: About the native-lambda branch
Date Mon, 15 Jan 2018 14:57:15 GMT
Hi Jochen,

      I still have a quesiton: How can I load variables via Groovy
utilities? Here[1] is my current way to load varaibles, it is not correct
though it can compile and run(i.e. the related test can not pass[2]):

       I tried the following way, but error occurred[3]...
```
        int newRegister = 0;
        Parameter[] lambdaSharedVariableParameters =
syntheticLambdaMethodNode.getNodeMetaData(LAMBDA_SHARED_VARIABLES);
        for (Parameter parameter : lambdaSharedVariableParameters) {
            ClassNode type = parameter.getType();
            operandStack.load(parameter.getType(), newRegister);
            // increment to next register, double/long are using two places
            newRegister++;
            if (type == ClassHelper.double_TYPE || type ==
ClassHelper.long_TYPE) newRegister++;
        }
        operandStack.remove(lambdaSharedVariableParameters.length);
```

        Could you tell me how to load variables properly?

Cheers,
Daniel.Sun

[1]
https://github.com/apache/groovy/blob/fb8e3d10b9bcce46ebb474657d67036b14c2bffc/src/main/java/org/codehaus/groovy/classgen/asm/sc/StaticTypesLambdaWriter.java#L104-L109
[2]
https://github.com/apache/groovy/blob/fb8e3d10b9bcce46ebb474657d67036b14c2bffc/src/test/groovy/transform/stc/LambdaTest.groovy#L201-L222
[3]
```
java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    Test1.p()V @81: invokedynamic
  Reason:
    Type 'groovy/lang/Reference' (current frame, stack[2]) is not assignable
to 'java/lang/String'
  Current Frame:
    bci: @81
    flags: { }
    locals: { 'groovy/lang/Reference',
'org/codehaus/groovy/runtime/powerassert/ValueRecorder' }
    stack: { 'java/util/List', 'java/util/stream/Stream',
'groovy/lang/Reference' }
  Bytecode:
    0x0000000: 1222 bb00 245a 5fb7 0027 4b2a 57bb 0029
    0x0000010: 59b7 002a 4c06 bd00 0459 0312 2c53 5904
    0x0000020: 122e 5359 0512 3053 b800 3606 bd00 0459
    0x0000030: 0304 b800 3c53 5904 05b8 003c 5359 0506
    0x0000040: b800 3c53 b800 4259 2b5f 1243 b600 4757
    0x0000050: 2aba 005d 0000 b900 6102 0059 2b5f 1262
    0x0000060: b600 4757 b800 6859 2b5f 1269 b600 4757
    0x0000070: b900 6d02 0059 2b5f 126e b600 4757 b800
    0x0000080: 7259 b800 772b 5f12 78b6 0047 5799 000a
    0x0000090: 2bb6 007b a700 1512 7d2b b800 8301 b800
    0x00000a0: 87a7 0008 2bb6 007b bfb1               
  Exception Handler Table:
    bci [21, 161] => handler: 164
  Stackmap Table:
    append_frame(@151,Object[#36],Object[#41])
    same_locals_1_stack_item_frame(@164,Object[#139])
    same_frame(@169)

```



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

Mime
View raw message