Package weasel.interpreter

Examples of weasel.interpreter.WeaselGenericClassInfo


    }catch(WeaselNativeException e){}
    if(wc==null){
      genericID = parentClass.getGenericID(realClassName);
      wc = parentClass.getGenericInformation(genericID).genericInfo.genericClass;
    }
    return new WeaselGenericClassInfo(wc, genericID, generic==null?new WeaselGenericClassInfo[0]:generic.getGenericClassInfo(parentClass));
  }
View Full Code Here


      token = iterator.next();
    }else{
      if(name.equals("Object")){
        ids.method = 1;
      }else{
        genericSuperClass = new WeaselGenericClassInfo(interpreter.baseTypes.getObjectClass(), -1, new WeaselGenericClassInfo[0]);
        compiler.compileEasy(genericSuperClass.genericClass);
        ids.method = genericSuperClass.genericClass.getIDS().method;
        ids.easyType = genericSuperClass.genericClass.getIDS().easyType;
        ids.objectRef = genericSuperClass.genericClass.getIDS().objectRef;
      }
    }
    if(token.param==WeaselKeyWord.IMPLEMENTS){
      List<WeaselGenericClassInfo> interfaceGenericList = new ArrayList<WeaselGenericClassInfo>();
      do{
        ListIterator<WeaselToken> iterator = tokenParser.listIterator();
        WeaselGenericClassInfo interfa = readGenericClass(iterator.next(), iterator);
        compiler.compileEasy(interfa.genericClass);
        interfaceGenericList.add(interfa);
        WeaselChecks.checkInterface(interfa.genericClass);
        token = iterator.next();
      }while(token.tokenType==WeaselTokenType.COMMA);
View Full Code Here

  private WeaselToken readInterfaceHead(WeaselToken token) throws WeaselCompilerException{
    if(token.param==WeaselKeyWord.EXTENDS){
      List<WeaselGenericClassInfo> interfaceGenericList = new ArrayList<WeaselGenericClassInfo>();
      do{
        ListIterator<WeaselToken> iterator = tokenParser.listIterator();
        WeaselGenericClassInfo interfa = readGenericClass(iterator.next(), iterator);
        compiler.compileEasy(interfa.genericClass);
        interfaceGenericList.add(interfa);
        WeaselChecks.checkInterface2(interfa.genericClass, this);
        token = iterator.next();
      }while(token.tokenType==WeaselTokenType.COMMA);
View Full Code Here

    }
    return token;
  }
 
  private WeaselToken readEnumHead(WeaselToken token) throws WeaselCompilerException{
    genericSuperClass = new WeaselGenericClassInfo(interpreter.baseTypes.getEnumClass(), -1, new WeaselGenericClassInfo[]{new WeaselGenericClassInfo(this, -1, new WeaselGenericClassInfo[0])});
    compiler.compileEasy(genericSuperClass.genericClass);
    ids.method = genericSuperClass.genericClass.getIDS().method;
    ids.easyType = genericSuperClass.genericClass.getIDS().easyType;
    ids.objectRef = genericSuperClass.genericClass.getIDS().objectRef;
    if(token.param==WeaselKeyWord.IMPLEMENTS){
      List<WeaselGenericClassInfo> interfaceGenericList = new ArrayList<WeaselGenericClassInfo>();
      do{
        ListIterator<WeaselToken> iterator = tokenParser.listIterator();
        WeaselGenericClassInfo interfa = readGenericClass(iterator.next(), iterator);
        compiler.compileEasy(interfa.genericClass);
        interfaceGenericList.add(interfa);
        WeaselChecks.checkInterface(interfa.genericClass);
        token = iterator.next();
      }while(token.tokenType==WeaselTokenType.COMMA);
View Full Code Here

    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

    staticMethodBodys = new WeaselMethodBody[ids.staticMethod];
    if(!isInterface())
      methodBodys = new WeaselMethodBody[ids.method];
    fields = new WeaselField[0];
   
    methods[0] = createMethod("<staticInit>", WeaselModifier.STATIC, this, new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]), new WeaselGenericClassInfo[0], new WeaselGenericInformation[0], ids.staticMethod-1);
    staticMethodBodys[ids.staticMethod-1] = new WeaselMethodBodyCompilerV2(methods[0], this, classStaticInit, new ArrayList<String>(), new ArrayList<Integer>(), compiler);
    if(!isInterface()){
      methods[1] = createMethod("<preInit>", 0, this, new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]), new WeaselGenericClassInfo[0], new WeaselGenericInformation[0], 0);
      methodBodys[0] = new WeaselMethodBodyCompilerV2(methods[1], this, classPreInit, new ArrayList<String>(), new ArrayList<Integer>(), compiler);
    }
   
    if(isEnum){
      try {
        token = readEnumConstants(token);
      } catch (WeaselCompilerException e) {
        onException(e);
        while(getNextToken().tokenType!=WeaselTokenType.SEMICOLON);
      }
    }
   
    while(token.tokenType!=WeaselTokenType.CLOSEBLOCK&&token.tokenType!=WeaselTokenType.NONE){
      try{
        setNextToken(token);
        modifiers = readModifier();
        token = getNextToken();
       
        //WeaselGenericInformation[] genericInformations = makeGenericInformations(token);
        //token = getNextToken();
        String name;
        boolean isConstructor=token.tokenType == WeaselTokenType.IDENT && token.param.equals(this.name);
        if(isConstructor){
          WeaselToken token2 = getNextToken();
          if(token2.tokenType!=WeaselTokenType.OPENBRACKET){
            isConstructor = false;
          }
          setNextToken(token2);
        }
        WeaselGenericClassInfo typeInfo;
        if(isConstructor){
          if(isInterface)
            onException(token.line, "Interface can't have a constructor");
          //if(genericInformations.length>0)
            //onException(token.line, "Constructor can't have generic informations");
          typeInfo = new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]);
          name = "<init>";
          typeInfo = new WeaselGenericClassInfo(interpreter.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]);
        }else{
          ListIterator<WeaselToken> iterator;
          typeInfo = readGenericClass(token, iterator=tokenParser.listIterator());
          WeaselCompiler.expect(token = iterator.next(), WeaselTokenType.IDENT);
          name = (String)token.param;
          if(name.equals("operator")){
            WeaselCompiler.expect(token = getNextToken(), WeaselTokenType.OPERATOR, WeaselTokenType.COMMA);
            name += ((Properties)token.param).operator;
          }
        }
        token = getNextToken();
        if(isConstructor){
          WeaselCompiler.expect(token, WeaselTokenType.OPENBRACKET);
          try{
            compileMethod(modifiers, typeInfo, name, token, new WeaselGenericInformation[0]);
          }catch(WeaselCompilerException e){
            onException(e);
          }
        }else{
          if(token.tokenType==WeaselTokenType.OPENBRACKET){
            try{
              compileMethod(modifiers, typeInfo, name, token, new WeaselGenericInformation[0]);
            }catch(WeaselCompilerException e){
              onException(e);
            }
          }else{
            //if(genericInformations.length>0)
            //  onException(token.line, "Fields can't have generic informations");
            try{
              compileField(modifiers, typeInfo, name, token);
            }catch(WeaselCompilerException e){
              onException(e);
            }
          }
        }
        token = getNextToken();
      }catch(WeaselCompilerException e){
        onException(e);
        token = getNextToken();
      }
    }
   
    try {
      WeaselCompiler.expect(token, WeaselTokenType.CLOSEBLOCK);
      WeaselCompiler.expect(getNextToken(), WeaselTokenType.NONE);
    } catch (WeaselCompilerException e) {
      onException(e);
    }
    tokenParser = null;
   
    if(!isInterface()){
      boolean hasConstructor = false;
      for(int i=0; i<methods.length; i++){
        if(methods[i].getName().equals("<init>")){
          hasConstructor = true;
          break;
        }
      }
     
      if(!hasConstructor){
        System.out.println("ADDCONSTRUCTOR to "+name);
        int id = ids.method++;
        WeaselMethod method = createMethod("<init>", isEnum?0:WeaselModifier.PUBLIC, this, new WeaselGenericClassInfo(compiler.baseTypes.voidClass, -1, new WeaselGenericClassInfo[0]), new WeaselGenericClassInfo[0], new WeaselGenericInformation[0], id);
        System.out.println(method);
        WeaselMethod[] newMethods = new WeaselMethod[methods.length+1];
        for(int i=0; i<methods.length; i++){
          newMethods[i] = methods[i];
        }
View Full Code Here

      token = getNextToken();
      WeaselCompiler.expect(token, WeaselTokenType.CLOSEINDEX);
      token = getNextToken();
      stype = "["+stype;
    }
    token = compileField2(modifier, new WeaselGenericClassInfo(getWeaselClass(token.line, stype), typeInfo.genericID, typeInfo.generics), name, token);
    while(token.tokenType==WeaselTokenType.COMMA){
      stype = typeInfo.genericClass.getByteName();
      token = getNextToken();
      WeaselCompiler.expect(token, WeaselTokenType.IDENT);
      name = (String)token.param;
      token = getNextToken();
      while(token.tokenType==WeaselTokenType.OPENINDEX){
        token = getNextToken();
        WeaselCompiler.expect(token, WeaselTokenType.CLOSEINDEX);
        token = getNextToken();
        stype = "["+stype;
      }
      token = compileField2(modifier, new WeaselGenericClassInfo(getWeaselClass(token.line, stype), typeInfo.genericID, typeInfo.generics), name, token);
    }
    WeaselCompiler.expect(token, WeaselTokenType.SEMICOLON);
  }
View Full Code Here

        if(method==null){
          int id = ids.method++;
          WeaselClass[] params = methods[i].getParamClasses();
          WeaselGenericClassInfo[] wgci = new WeaselGenericClassInfo[params.length];
          for(int j=0; j<params.length; j++){
            wgci[j] = new WeaselGenericClassInfo(params[i], -1, new WeaselGenericClassInfo[0]);
          }
          method = createMethod(name, modifier, this, new WeaselGenericClassInfo(methods[i].getReturnClasses(), -1, new WeaselGenericClassInfo[0]), wgci, new WeaselGenericInformation[0], id);
          WeaselMethod[] newMethods = new WeaselMethod[this.methods.length+1];
          for(int j=0; j<this.methods.length; j++){
            newMethods[j] = this.methods[j];
          }
          newMethods[methods.length] = method;
View Full Code Here

      try{
        weaselClass = interpreter.getWeaselClass(className);
      }catch(WeaselNativeException e){
        throw new WeaselCompilerException(token.line, e.getMessage());
      }
      return new WeaselGenericClassInfo(weaselClass, -1, genericObjects.toArray(new WeaselGenericClassInfo[0]));
    }else{
      while(className.charAt(0)=='['){
        weaselClass = new WeaselClass(interpreter, weaselClass, className, null);
        className = className.substring(1);
      }
      return new WeaselGenericClassInfo(weaselClass, genericID, genericObjects.toArray(new WeaselGenericClassInfo[0]));
    }
  }
View Full Code Here

    while(token.tokenType==WeaselTokenType.MODIFIER){
      modifiers.add(token);
    }
    int modifier = getModifier(modifiers, WeaselModifier.FINAL);
    WeaselClassCompiler wcc = compilerHelper.getClassCompiler();
    WeaselGenericClassInfo wgci = wcc.readGenericClass(token, iterator);
    WeaselGenericClass wgc = wgci.getGenericClass(wcc.getGenericClass());
    iterator.previous();
    WeaselInstructionList instructions = new WeaselInstructionList();
    do{
      iterator.next();
      instructions.addAll(compileVar(modifier, wgc, compiler, compilerHelper, iterator));
View Full Code Here

TOP

Related Classes of weasel.interpreter.WeaselGenericClassInfo

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.