Package xscript.runtime.object

Examples of xscript.runtime.object.XObject


  }

  public void call(XThread thread, XMethodExecutor methodExecutor, XMethod method, XGenericClass[] generics, long[] params) {
    XNativeMethod nativeMethod = method.getNativeMethod();
   
    XObject _this = null;
    int i=0;
    if(!XModifier.isStatic(method.getModifier())){
      _this = virtualMachine.getObjectProvider().getObject(params[0]);
      i=1;
    }
    Object[] oParam = new Object[params.length-i];
    XGenericClass[] genericClasses = method.getParams(_this==null?null:_this.getXClass(), new XGenericMethodProviderImp(method, generics));
    if(oParam.length!=genericClasses.length)
      throw new XRuntimeException("An native call error happened");
    for(int j=0; j<oParam.length; j++){
      long value = params[j+i];
      XGenericClass genericClass = genericClasses[j];
      oParam[j] = XWrapper.getJavaObject(virtualMachine.getObjectProvider(), genericClass, value);
    }
   
    Object ret = invokeNative(nativeMethod, thread, methodExecutor, generics, _this, oParam);
    XGenericClass genericClass  = method.getReturnType(_this==null?null:_this.getXClass(), new XGenericMethodProviderImp(method, generics));
    if(XPrimitive.getPrimitiveID(genericClass.getXClass())!=XPrimitive.VOID){
      long l = XWrapper.getXObject(virtualMachine.getObjectProvider(), genericClass, ret);
      methodExecutor.push(l, XPrimitive.getPrimitiveID(genericClass.getXClass()));
    }
  }
View Full Code Here


    long[] params = new long[paramTypes.length+1];
    for(int i=params.length-1; i>0; i++){
      int pID = XPrimitive.getPrimitiveID(paramTypes[i-1].getXClass());
      params[i] = methodExecutor.pop(pID);
      if(pID==XPrimitive.OBJECT){
        XObject obj = vm.getObjectProvider().getObject(params[i]);
        XChecks.checkCast(obj.getXClass(), paramTypes[i-1]);
      }
    }
    params[0] = methodExecutor.oPop();
    XObject _this = vm.getObjectProvider().getObject(params[0]);
    XMethod xMethod = method.getMethod(_this);
    thread.call(xMethod, solvedGenerics, params);
  }
View Full Code Here

  public void markObjectObjectsVisible(XObject object) {
    for(int i=0; i<fields.length; i++){
      if(!XModifier.isStatic(fields[i].getModifier())){
        if(fields[i].getTypePrimitive()==XPrimitive.OBJECT){
          long pointer = fields[i].get(object);
          XObject obj = virtualMachine.getObjectProvider().getObject(pointer);
          if(obj!=null)
            obj.markVisible();
        }
      }
    }
    for(int i=0; i<superClasses.length; i++){
      superClasses[i].getXClassNonNull(virtualMachine).markObjectObjectsVisible(object);
View Full Code Here

    super.markVisible();
    for(int i=0; i<fields.length; i++){
      if(XModifier.isStatic(fields[i].getModifier())){
        if(fields[i].getTypePrimitive()==XPrimitive.OBJECT){
          long pointer = fields[i].get(null);
          XObject obj = virtualMachine.getObjectProvider().getObject(pointer);
          if(obj!=null)
            obj.markVisible();
        }
      }
    }
  }
View Full Code Here

    super.markObjectObjectsVisible(object);
    if(primitiveID==XPrimitive.OBJECT){
      int size = object.getArrayLength();
      for(int i=0; i<size; i++){
        long pointer = object.getArrayElement(i);
        XObject element = virtualMachine.getObjectProvider().getObject(pointer);
        if(element!=null){
          element.markVisible();
        }
      }
    }
  }
View Full Code Here

 
  @Override
  public void run(XVirtualMachine vm, XThread thread, XMethodExecutor methodExecutor) {
    resolve(vm, methodExecutor);
    long pointer = methodExecutor.oPop();
    XObject object = vm.getObjectProvider().getObject(pointer);
    long value = field.get(object);
    methodExecutor.push(value, getPrimitiveID(vm));
  }
View Full Code Here

  }

  public static XGenericClass getXClass(XVirtualMachine vm, long l, int i) {
    switch (i) {
    case OBJECT:
      XObject obj = vm.getObjectProvider().getObject(l);
      if(obj==null)
        return null;
      return obj.getXClass();
    case BOOL:
      return new XGenericClass(vm.getClassProvider().BOOL);
    case BYTE:
      return new XGenericClass(vm.getClassProvider().BYTE);
    case CHAR:
View Full Code Here

    }else if(generics.length!=method.getGenericParams()){
      throw new XRuntimeException("Can't create a generic method %s with %s generic params, need %s generic params", method, generics.length, method.getGenericParams());
    }
    int pl = params.length;
    if(!XModifier.isStatic(method.getModifier())){
      XObject _this = method.getDeclaringClass().getVirtualMachine().getObjectProvider().getObject(params[0]);
      declaringClass = _this.getXClass();
      pl--;
    }
    if(pl!=method.getParamCount()){
      throw new XRuntimeException("Wrong number of arguments got %s but need %s", method.getParamCount(), pl);
    }
View Full Code Here

  public void markVisible(){
    if(parent!=null){
      parent.markVisible();
    }
    if(method.getReturnTypePrimitive()==XPrimitive.OBJECT){
      XObject obj = method.getDeclaringClass().getVirtualMachine().getObjectProvider().getObject(ret);
      if(obj!=null)
        obj.markVisible();
    }
    for(int i=0; i<stackPointer; i++){
      if(stackType[i] == XPrimitive.OBJECT){
        XObject obj = method.getDeclaringClass().getVirtualMachine().getObjectProvider().getObject(stack[i]);
        if(obj!=null)
          obj.markVisible();
      }
    }
  }
View Full Code Here

  @Override
  public void run(XVirtualMachine vm, XThread thread, XMethodExecutor methodExecutor) {
    resolve(vm, methodExecutor);
    long value = methodExecutor.pop(getPrimitiveID(vm));
    long pointer = methodExecutor.oPop();
    XObject object = vm.getObjectProvider().getObject(pointer);
    if(XModifier.isFinal(field.getModifier())){
      XObject _this = vm.getObjectProvider().getObject(methodExecutor.getLocal(0));
      if(methodExecutor.getMethod().getSimpleName().equals("<init>") && _this==object){
        field.finalSet(object, value);
      }else{
        throw new XRuntimeException("Try to write final field %s", field.getName());
      }
View Full Code Here

TOP

Related Classes of xscript.runtime.object.XObject

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.