Package xscript.runtime.clazz

Examples of xscript.runtime.clazz.XClass


  public XNativeMethod removeNativeMethod(String name) {
    return nativeMethods.remove(name);
  }

  public void addNativeMethod(String classname, String name, XNativeMethod nativeMethod){
    XClass xClass = virtualMachine.getClassProvider().getLoadedXClass(classname);
    XMethod method = xClass==null?null:xClass.getMethod(name);
    if(method==null){
      if(nativeMethod==null){
        nativeMethods.remove(classname+"."+name);
      }else{
        nativeMethods.put(classname+"."+name, nativeMethod);
View Full Code Here


  public XGenericClass getReturnType(XGenericClass genericClass, XGenericMethodProvider methodExecutor){
    return returnType.getXClass(getDeclaringClass().getVirtualMachine(), genericClass, methodExecutor);
  }
 
  public int getReturnTypePrimitive(){
    XClass xClass = returnType.getXClass(getDeclaringClass().getVirtualMachine());
    if(xClass==null)
      return XPrimitive.OBJECT;
    return XPrimitive.getPrimitiveID(xClass);
  }
View Full Code Here

 
  public XMethod getMethod(XObject object){
    if(XModifier.isStatic(modifier)){
      return this;
    }
    XClass xClass = object.getXClass().getXClass();
    XClassTable classTable = getDeclaringClass().getClassTable(xClass);
    if(classTable==null){
      throw new XRuntimeException("Can't cast %s to %s", xClass, getDeclaringClass());
    }
    int i = classTable.getMethodID(index);
    return xClass.getVirtualMethod(i);
  }
View Full Code Here

  public static void checkAccess(XClass xClass, XClass xClass2){
    if(xClass.getVirtualMachine()!=xClass2.getVirtualMachine()){
      throw new XRuntimeException("%s has a diferent VM than %s", xClass, xClass2);
    }
    int modifier = xClass2.getModifier();
    XClass checkClass1 = xClass;
    while(checkClass1.getOuterClass()!=null){
      checkClass1 = checkClass1.getOuterClass();
    }
    XClass checkClass2 = xClass2;
    while(checkClass2.getOuterClass()!=null){
      checkClass2 = checkClass2.getOuterClass();
    }
    boolean sameOuterClass = checkClass1==checkClass2;
    if(XModifier.isPrivate(modifier)){
      if(!sameOuterClass){
        throw new XRuntimeException("%s can't access %s", xClass, xClass2);
View Full Code Here

    if(!xClass.canCastTo(to))
      throw new XRuntimeException("Can't cast %s to %s", xClass, to);
  }

  public static void checkAccess(XClass xClass, XField field) {
    XClass xClass2 = field.getDeclaringClass();
    if(xClass.getVirtualMachine()!=xClass2.getVirtualMachine()){
      throw new XRuntimeException("%s has a diferent VM than %s", xClass, xClass2);
    }
    int modifier = xClass2.getModifier();
    int fModifier = field.getModifier();
    XClass checkClass1 = xClass;
    while(checkClass1.getOuterClass()!=null){
      checkClass1 = checkClass1.getOuterClass();
    }
    XClass checkClass2 = xClass2;
    while(checkClass2.getOuterClass()!=null){
      checkClass2 = checkClass2.getOuterClass();
    }
    boolean sameOuterClass = checkClass1==checkClass2;
    if(XModifier.isPrivate(modifier) || XModifier.isPrivate(fModifier)){
      if(!sameOuterClass){
        throw new XRuntimeException("%s can't access %s", xClass, field);
View Full Code Here

      }
    }
  }

  public static void checkAccess(XClass xClass, XMethod method) {
    XClass xClass2 = method.getDeclaringClass();
    if(xClass.getVirtualMachine()!=xClass2.getVirtualMachine()){
      throw new XRuntimeException("%s has a diferent VM than %s", xClass, xClass2);
    }
    int modifier = xClass2.getModifier();
    int fModifier = method.getModifier();
    XClass checkClass1 = xClass;
    while(checkClass1.getOuterClass()!=null){
      checkClass1 = checkClass1.getOuterClass();
    }
    XClass checkClass2 = xClass2;
    while(checkClass2.getOuterClass()!=null){
      checkClass2 = checkClass2.getOuterClass();
    }
    boolean sameOuterClass = checkClass1==checkClass2;
    if(XModifier.isPrivate(modifier) || XModifier.isPrivate(fModifier)){
      if(!sameOuterClass){
        throw new XRuntimeException("%s can't access %s", xClass, method);
View Full Code Here

    thread.call(xMethod, solvedGenerics, params);
  }

  private void resolve(XVirtualMachine vm, XMethodExecutor methodExecutor){
    if(method==null){
      XClass xClass = vm.getClassProvider().getXClass(className);
      method = xClass.getMethod(methodName, methodParams, methodReturn);
      XChecks.checkAccess(methodExecutor.getMethod().getDeclaringClass(), method);
      if(generics==null){
        if(method.getGenericParams()!=0)
          throw new XRuntimeException("Can't create a generic method %s without generic params, need %s generic params", method, method.getGenericParams());
      }else if(generics.length!=method.getGenericParams()){
View Full Code Here

    long value = field.get(object);
    methodExecutor.push(value, getPrimitiveID(vm));
  }

  private int getPrimitiveID(XVirtualMachine vm){
    XClass xClass = fieldType.getXClass(vm);
    if(xClass==null)
      return XPrimitive.OBJECT;
    return XPrimitive.getPrimitiveID(xClass);
  }
View Full Code Here

    return XPrimitive.getPrimitiveID(xClass);
  }
 
  private void resolve(XVirtualMachine vm, XMethodExecutor methodExecutor){
    if(field==null){
      XClass xClass = vm.getClassProvider().getXClass(className);
      field = xClass.getField(fieldName);
      XChecks.checkAccess(methodExecutor.getMethod().getDeclaringClass(), field);
      if(!field.getType().equals(fieldType)){
        throw new XRuntimeException("Type of field %s has changed", field);
      }
      if(XModifier.isStatic(field.getModifier())){
View Full Code Here

      field.set(null, value);
    }
  }

  private int getPrimitiveID(XVirtualMachine vm){
    XClass xClass = fieldType.getXClass(vm);
    if(xClass==null)
      return XPrimitive.OBJECT;
    return XPrimitive.getPrimitiveID(xClass);
  }
View Full Code Here

TOP

Related Classes of xscript.runtime.clazz.XClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.