+package org.simantics.scl.compiler.constants.componentaccess;
+
+import org.cojen.classfile.TypeDesc;
+import org.simantics.scl.compiler.constants.generic.MethodRef;
+import org.simantics.scl.compiler.constants.generic.MethodRef.ObjectMethodRef;
+import org.simantics.scl.compiler.internal.codegen.utils.Constants;
+import org.simantics.scl.compiler.internal.codegen.utils.MethodBuilder;
+
+public class MethodComponentAccess implements ComponentAccess {
+ public final String methodName;
+ public final boolean isInterface;
+
+ public MethodComponentAccess(String fieldName, boolean isInterface) {
+ this.methodName = fieldName;
+ this.isInterface = isInterface;
+ }
+
+ @Override
+ public void load(MethodBuilder mb, String baseClass, TypeDesc returnType) {
+ if(isInterface)
+ mb.invokeInterface(baseClass, methodName, returnType, Constants.EMPTY_TYPEDESC_ARRAY);
+ else
+ mb.invokeVirtual(baseClass, methodName, returnType, Constants.EMPTY_TYPEDESC_ARRAY);
+ }
+
+ @Override
+ public MethodRef toMethodRef(String baseClass, TypeDesc returnType) {
+ return new ObjectMethodRef(isInterface, baseClass, methodName, returnType, Constants.EMPTY_TYPEDESC_ARRAY);
+ }
+}