Package weasel.interpreter

Examples of weasel.interpreter.WeaselObject


  }
 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    int index = (Integer)thread.popValue();
    WeaselObject array = interpreter.getObject(thread.popObject());
    switch(primitiveID){
    case WeaselPrimitive.BOOLEAN:
      thread.pushValue(interpreter.baseTypes.getArrayBoolean(array, index));
    case WeaselPrimitive.CHAR:
      thread.pushValue(interpreter.baseTypes.getArrayChar(array, index));
View Full Code Here


  }
 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    resolve(interpreter);
    WeaselObject object = interpreter.getObject(thread.getObject(thread.getStackPointer()-this.method.getParamClasses().length-1));
    WeaselMethodBody methodBody = this.method.getMethodFromClass(object.getWeaselClass());
    if(methodBody.isNative()){
      if(nativeMethod==null){
        nativeMethod = interpreter.getNativeMethod(methodBody.getNameAndDesk());
      }
      Object[] params = new Object[this.method.getParamClasses().length];
      for(int i=0; i<params.length; i++){
        StackElement se = thread.pop();
        if(se.value==null){
          params[i] = interpreter.getObject(se.object);
        }else{
          params[i] = se.value;
        }
      }
      thread.popObject();
      Object ret = nativeMethod.invoke(interpreter, thread, method, methodBody.getNameAndDesk(), object, params);
      WeaselClass rc = this.method.getReturnClasses();
      switch(WeaselPrimitive.getPrimitiveID(rc)){
      case WeaselPrimitive.BOOLEAN:
        thread.pushValue((Boolean)ret);
        break;
      case WeaselPrimitive.CHAR:
        thread.pushValue((Character)ret);
        break;
      case WeaselPrimitive.BYTE:
        thread.pushValue((Byte)ret);
        break;
      case WeaselPrimitive.SHORT:
        thread.pushValue((Short)ret);
        break;
      case WeaselPrimitive.INT:
        thread.pushValue((Integer)ret);
        break;
      case WeaselPrimitive.LONG:
        thread.pushValue((Long)ret);
        break;
      case WeaselPrimitive.FLOAT:
        thread.pushValue((Float)ret);
        break;
      case WeaselPrimitive.DOUBLE:
        thread.pushValue((Double)ret);
        break;
      case WeaselPrimitive.VOID:
        if(ret!=null){
          throw new WeaselNativeException("Got return parameter %s but expect a void value in %s", ret, methodDesk);
        }
        break;
      default:
        if(ret==null){
          thread.pushObject(0);
        }else{
          int objPtr = (Integer)ret;
          WeaselObject obj = interpreter.getObject(objPtr);
          if(!obj.getWeaselClass().canCastTo(rc))
            throw new WeaselNativeException("Got return parameter %s but expect a %s value in %s", ret, rc, methodDesk);
          thread.pushObject(objPtr);
        }
        break;
      }
View Full Code Here

 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    resolve(interpreter);
    StackElement se = thread.pop();
    WeaselObject object = interpreter.getObject(thread.getObject(thread.popObject()));
    thread.push(se);
    switch(WeaselPrimitive.getPrimitiveID(type)){
    case WeaselPrimitive.BOOLEAN:
      field.setBoolean(object, (Boolean)se.value);
      break;
View Full Code Here

      default:
        if(ret==null){
          thread.pushObject(0);
        }else{
          int objPtr = (Integer)ret;
          WeaselObject obj = interpreter.getObject(objPtr);
          if(!obj.getWeaselClass().canCastTo(rc))
            throw new WeaselNativeException("Got return parameter %s but expect a %s value in %s", ret, rc, methodDesk);
          thread.pushObject(objPtr);
        }
        break;
      }
View Full Code Here

  }
 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    resolve(interpreter);
    WeaselObject object = interpreter.getObject(thread.getObject(method.getStackBottom()-pos));
    switch(WeaselPrimitive.getPrimitiveID(type)){
    case WeaselPrimitive.BOOLEAN:
      thread.pushValue(field.getBoolean(object));
      break;
    case WeaselPrimitive.BYTE:
View Full Code Here

  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    if(primitiveID==0){
      int obj2 = thread.popObject();
      int obj1 = thread.popObject();
      WeaselObject o2 = interpreter.getObject(obj2);
      WeaselObject o1 = interpreter.getObject(obj1);
      if(o1==null && o2==null){
        thread.pushValue(true);
      }else if(o1!=null && o2!=null){
        WeaselMethodBody methodBody = interpreter.baseTypes.getlObjectEqualMethod().getMethod(o1);
        if(methodBody.isNative()){
View Full Code Here

 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    resolve(interpreter);
    StackElement se = thread.get(thread.getStackPointer()-1);
    WeaselObject object = interpreter.getObject(thread.getObject(method.getStackBottom()-pos));
    switch(WeaselPrimitive.getPrimitiveID(type)){
    case WeaselPrimitive.BOOLEAN:
      field.setBoolean(object, (Boolean)se.value);
      break;
    case WeaselPrimitive.BYTE:
View Full Code Here

  }
 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    resolve(interpreter);
    WeaselObject obj = interpreter.getObject(thread.popObject());
    if(obj==null){
      thread.pushValue(false);
    }else{
      thread.pushValue(obj.getWeaselClass().canCastTo(weaselClass));
    }
  }
View Full Code Here

 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    StackElement se = thread.pop();
    int index = (Integer)thread.popValue();
    WeaselObject array = interpreter.getObject(thread.popObject());
    thread.push(se);
    switch(primitiveID){
    case WeaselPrimitive.BOOLEAN:
      interpreter.baseTypes.setArrayBoolean(array, index, (Boolean)se.value);
    case WeaselPrimitive.CHAR:
View Full Code Here

  }
 
  @Override
  public void run(WeaselInterpreter interpreter, WeaselThread thread, WeaselMethodExecutor method) {
    resolve(interpreter);
    WeaselObject object = interpreter.getObject(thread.popObject());
    switch(WeaselPrimitive.getPrimitiveID(type)){
    case WeaselPrimitive.BOOLEAN:
      thread.pushValue(field.getBoolean(object));
      break;
    case WeaselPrimitive.BYTE:
View Full Code Here

TOP

Related Classes of weasel.interpreter.WeaselObject

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.