Package weasel.interpreter

Examples of weasel.interpreter.WeaselField


    List<String> constants = new ArrayList<String>();
    while(true){
      WeaselCompiler.expect(token, WeaselTokenType.IDENT);
      String constantName = (String)token.param;
      constants.add(constantName);
      WeaselField field = createField(constantName, WeaselModifier.FINAL | WeaselModifier.STATIC | WeaselModifier.PUBLIC, this, new WeaselGenericClassInfo(this, -1, new WeaselGenericClassInfo[0]), ids.staticObjectRef++);
      WeaselField[] newFields = new WeaselField[fields.length+1];
      for(int i=0; i<fields.length; i++){
        newFields[i] = fields[i];
      }
      newFields[fields.length] = field;
      fields = newFields;
      WeaselToken nameToken = token;
      classStaticInit.add(nameToken);
      classStaticInit.add(new WeaselToken(WeaselTokenType.OPERATOR, nameToken.line, WeaselOperator.ASSIGN));
      classStaticInit.add(new WeaselToken(WeaselTokenType.KEYWORD, nameToken.line, WeaselKeyWord.NEW));
      classStaticInit.add(new WeaselToken(WeaselTokenType.IDENT, nameToken.line, name));
      token = getNextToken();
      if(token.tokenType==WeaselTokenType.OPENBRACKET){
        int count = 0;
        classStaticInit.add(token);
        token = getNextToken();
        while(token.tokenType!=WeaselTokenType.NONE){
          classStaticInit.add(token);
          if(token.tokenType==WeaselTokenType.OPENBRACKET)
            count++;
          else if(token.tokenType==WeaselTokenType.CLOSEBRACKET){
            if(count<=0)
              break;
            count--;
          }
          token = getNextToken();
        }
        token = getNextToken();
        classStaticInit.add(new WeaselToken(WeaselTokenType.SEMICOLON, token.line));
      }else{
        classStaticInit.add(new WeaselToken(WeaselTokenType.OPENBRACKET, nameToken.line));
        classStaticInit.add(new WeaselToken(WeaselTokenType.CLOSEBRACKET, nameToken.line));
        classStaticInit.add(new WeaselToken(WeaselTokenType.SEMICOLON, nameToken.line));
      }
      if(token.tokenType!=WeaselTokenType.COMMA)
        break;
      token = getNextToken();
    }
    WeaselField field = createField("values", WeaselModifier.FINAL | WeaselModifier.STATIC | WeaselModifier.PRIVATE, this, new WeaselGenericClassInfo(interpreter.getWeaselClass("["+getByteName()), -1, new WeaselGenericClassInfo[0]), ids.staticObjectRef++);
    WeaselField[] newFields = new WeaselField[fields.length+1];
    for(int i=0; i<fields.length; i++){
      newFields[i] = fields[i];
    }
    newFields[fields.length] = field;
View Full Code Here


          break;
        }
      }
      init.add(new WeaselToken(WeaselTokenType.SEMICOLON, token.line));
    }
    WeaselField field = null;
    try{
      field = getField(name);
    }catch(WeaselNativeException e){}
    if(field!=null && field.getParentClass()==this)
      throw new WeaselCompilerException(nameToken.line, "Duplicated declaration of filed %s", field);
    int id;
    if(WeaselModifier.isStatic(modifier)){
      if(typeInfo.genericClass.isPrimitive()){
        id = ids.staticEasyType++;
View Full Code Here

    StackElement se = thread.pop();
    if(se.value==null){
      WeaselObject object = interpreter.getObject(se.object);
      if(object==null)
        throw new WeaselNativeException("Null pointer");
      WeaselField field = object.getWeaselClass().getField("value");
      switch(primitiveID){
      case WeaselPrimitive.BOOLEAN:
        thread.pushValue(field.getBoolean(object));
        break;
      case WeaselPrimitive.CHAR:
        thread.pushValue(field.getChar(object));
        break;
      case WeaselPrimitive.BYTE:
        thread.pushValue(field.getBoolean(object));
        break;
      case WeaselPrimitive.SHORT:
        thread.pushValue(field.getShort(object));
        break;
      case WeaselPrimitive.INT:
        thread.pushValue(field.getInt(object));
        break;
      case WeaselPrimitive.LONG:
        thread.pushValue(field.getLong(object));
        break;
      case WeaselPrimitive.DOUBLE:
        thread.pushValue(field.getDouble(object));
        break;
      case WeaselPrimitive.FLOAT:
        thread.pushValue(field.getFloat(object));
        break;
      }
    }else{
      Object object = se.value;
      Class<?> c = object.getClass();
View Full Code Here

TOP

Related Classes of weasel.interpreter.WeaselField

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.