Search in sources :

Example 1 with Member

use of ceylon.language.serialization.Member in project ceylon by eclipse.

the class Array method $set$.

@Ignore
@Override
public void $set$(ReachableReference reference, java.lang.Object instance) {
    if (reference instanceof Member && getArraySize().equals(((Member) reference).getAttribute())) {
        int size = toSize(((ceylon.language.Integer) instance).value);
        try {
            Lookup lookup = MethodHandles.lookup();
            Util.setter(lookup, "size").invokeExact(this, size);
            java.lang.Object array = createArrayWithElement($reifiedElement, size, null);
            Util.setter(lookup, "array").invokeExact(this, array);
            if (elementType.fieldName != null) {
                MethodHandle fieldSetter = Util.setter(lookup, elementType.fieldName);
                switch(elementType) {
                    case CeylonInteger:
                        fieldSetter.invokeExact(this, (long[]) array);
                        break;
                    case CeylonFloat:
                        fieldSetter.invokeExact(this, (double[]) array);
                        break;
                    case CeylonCharacter:
                        fieldSetter.invokeExact(this, (int[]) array);
                        break;
                    case CeylonByte:
                        fieldSetter.invokeExact(this, (byte[]) array);
                        break;
                    case CeylonBoolean:
                        fieldSetter.invokeExact(this, (boolean[]) array);
                        break;
                    case CeylonString:
                        fieldSetter.invokeExact(this, (java.lang.String[]) array);
                        break;
                    case Other:
                        fieldSetter.invokeExact(this, (java.lang.Object[]) array);
                        break;
                    default:
                        fieldSetter.invoke(this, array);
                        break;
                }
            }
        } catch (java.lang.Throwable t) {
            rethrow_.rethrow(t);
        }
    } else {
        ceylon.language.serialization.Element index = (ceylon.language.serialization.Element) reference;
        set(index.getIndex(), (Element) instance);
    }
}
Also used : Lookup(java.lang.invoke.MethodHandles.Lookup) Member(ceylon.language.serialization.Member) MethodHandle(java.lang.invoke.MethodHandle) Ignore(org.eclipse.ceylon.compiler.java.metadata.Ignore)

Aggregations

Member (ceylon.language.serialization.Member)1 MethodHandle (java.lang.invoke.MethodHandle)1 Lookup (java.lang.invoke.MethodHandles.Lookup)1 Ignore (org.eclipse.ceylon.compiler.java.metadata.Ignore)1