Package com.dragome.compiler.ast

Examples of com.dragome.compiler.ast.TypeDeclaration


      clazz.setResolved(true);

      new FieldUnit(getSignature("length"), clazz);

      TypeDeclaration typeDecl= new TypeDeclaration(new ObjectType(clazz.getName()), 0, new HashMap<String, String>());//revisar annotations
      typeDecl.setSuperType(Type.OBJECT);
      typeDecl.visit(DragomeJsCompiler.compiler.generator);
    }
    else
    {
      TypeResolver resolver= new TypeResolver(this, DragomeJsCompiler.compiler.generator);
      visitSuperTypes(clazz, resolver);
View Full Code Here


    Log.getLogger().debug("Cross-Compiling " + classUnit);

    Log.getLogger().infoSameLine(".");

    TypeDeclaration typeDecl= null;
    try
    {
      typeDecl= parse(classUnit);
    }
    catch (Exception e)
    {
        Log.getLogger().debug("parse error:" + e.getMessage(), e);
    }

    {
      typeDecl.visit(generator);

      if (!classUnit.getNotReversibleMethods().isEmpty())
      {
        File file= classUnit.getClassFile().getFile();
        classUnit.setAlternativeCompilation(ClassToJs.transformClassFileToJs(file != null ? file.getName() : "", classUnit.getBytecode()));
View Full Code Here

  }

  private TypeDeclaration parse(ClassUnit classUnit)
  {
    Parser parser= new Parser(classUnit);
    TypeDeclaration typeDecl= parser.parse();

    return typeDecl;
  }
View Full Code Here

    org.apache.bcel.classfile.Method[] bcelMethods= jc.getMethods();

    ObjectType type= new ObjectType(jc.getClassName());
    Map<String, String> annotationsValues= getAnnotationsValues(jc.getAttributes());
    TypeDeclaration typeDecl= new TypeDeclaration(type, jc.getAccessFlags(), annotationsValues);
    Project.singleton.addTypeAnnotations(typeDecl);

    fileUnit.isInterface= Modifier.isInterface(typeDecl.getAccess());
    fileUnit.isAbstract= Modifier.isAbstract(typeDecl.getAccess());

    fileUnit.setAnnotations(annotationsValues);

    if (!type.getClassName().equals("java.lang.Object"))
    {

      ObjectType superType= new ObjectType(jc.getSuperclassName());
      typeDecl.setSuperType(superType);
      ClassUnit superUnit= Project.getSingleton().getOrCreateClassUnit(superType.getClassName());
      fileUnit.setSuperUnit(superUnit);

      String[] interfaceNames= jc.getInterfaceNames();
      for (int i= 0; i < interfaceNames.length; i++)
      {
        ObjectType interfaceType= new ObjectType(interfaceNames[i]);
        ClassUnit interfaceUnit= Project.getSingleton().getOrCreateClassUnit(interfaceType.getClassName());
        fileUnit.addInterface(interfaceUnit);
      }
    }

    Field[] fields= jc.getFields();
    for (int i= 0; i < fields.length; i++)
    {
      Field field= fields[i];
      VariableDeclaration variableDecl= new VariableDeclaration(VariableDeclaration.NON_LOCAL);
      variableDecl.setName(field.getName());
      variableDecl.setModifiers(field.getModifiers());
      variableDecl.setType(field.getType());

      typeDecl.addField(variableDecl);
    }

    for (int i= 0; i < bcelMethods.length; i++)
    {
      Method method= bcelMethods[i];

      Attribute[] attributes= method.getAttributes();

      Map<String, String> methodAnnotationsValues= getAnnotationsValues(attributes);

      MethodBinding binding= MethodBinding.lookup(jc.getClassName(), method.getName(), method.getSignature());

      String genericSignature= method.getGenericSignature();
      if (genericSignature != null && !genericSignature.equals(method.getSignature()))
      {
        Signature signature= Project.getSingleton().getSignature(binding.toString()).relative();
        String normalizedSignature= DragomeJavaScriptGenerator.normalizeExpression(signature);
        String normalizedClassname= DragomeJavaScriptGenerator.normalizeExpression(type.getClassName());
        Project.getSingleton().addGenericSignature(normalizedClassname + "|" + normalizedSignature + "|" + genericSignature);
        //    System.out.println(genericSignature);
      }

      if (DragomeJsCompiler.compiler.getSingleEntryPoint() != null)
      {
        Signature signature= Project.getSingleton().getSignature(binding.toString());
        String singleSignature= DragomeJsCompiler.compiler.getSingleEntryPoint();
        if (!signature.toString().equals(singleSignature))
          continue;
      }

      MethodDeclaration methodDecl= new MethodDeclaration(binding, method.getAccessFlags(), method.getCode(), methodAnnotationsValues);
      typeDecl.addMethod(methodDecl);

      parseMethod(typeDecl, methodDecl, method);
    }

    return typeDecl;
View Full Code Here

    Project.createSingleton(null);
    ClassUnit classUnit= new ClassUnit(Project.singleton, Project.singleton.getSignature(className));
    classUnit.setClassFile(new FileObject(new File(args[1])));
    Parser parser= new Parser(classUnit);
    TypeDeclaration typeDecl= parser.parse();
    DragomeJavaScriptGenerator dragomeJavaScriptGenerator= new DragomeJavaScriptGenerator(Project.singleton);
    dragomeJavaScriptGenerator.setOutputStream(new PrintStream(new FileOutputStream(new File("/tmp/webapp.js"))));
    dragomeJavaScriptGenerator.visit(typeDecl);

    FileInputStream fis= new FileInputStream(new File("/tmp/webapp.js"));
View Full Code Here

TOP

Related Classes of com.dragome.compiler.ast.TypeDeclaration

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.