Package com.dragome.compiler.type

Examples of com.dragome.compiler.type.Signature


    //  {
    //      println("/* " + unit.getAbsoluteSignature() + " */");
    //  }

    String closingString;
    Signature signature= Project.getSingleton().getSignature(methodBinding.toString()).relative();
    String signatureReplaced= normalizeExpression(signature);

    if (typeDecl.getClassName().equals("java.lang.String") && method.isInstanceConstructor())
    {

View Full Code Here


  }
  public static String normalizeExpression(Object object)
  {
    if (object instanceof Signature)
    {
      Signature signature= (Signature) object;
      String string= signature.toString();

      string= string.replaceAll("\\[\\]", "_ARRAYTYPE");
      String result= string.replaceAll("\\(\\)", "\\$");
      result= result.replaceAll("\\)", "\\$").replaceAll("\\(", "___").replaceAll("\\.", "_").replaceAll(",", "__").replaceAll("<", "").replaceAll(">", "").replaceAll("\\[", "_").replaceAll("\\]", "_").replaceAll(";", "\\$");

      if (signature.isMethod() || signature.isConstructor())
      {
        result= "$" + result;

        if (signature.isConstructor())
        {
          result= result.replaceAll("___$", "");
          result= result.replace("$init", "$init_");
          return "$" + result;
        }
View Full Code Here

  public void visit(InstanceofExpression node)
  {
    print("dragomeJs.isInstanceof (");
    node.getLeftOperand().visit(this);
    print(", ");
    Signature signature= Project.getSingleton().getArraySignature(node.getRightOperand());
    print(normalizeExpression(signature.toString()));
    print(")");

    //  print ("true");
  }
View Full Code Here

      throw new IllegalArgumentException("Cannot handle method " + name);
  }

  private void generateArguments(MethodInvocation invocation)
  {
    Signature signature= getSignatureOfInvocation(invocation);
    print(normalizeExpression(signature));

    print("(");
    generateList(invocation.getArguments());
    print(")");
View Full Code Here

  }

  private static Signature getSignatureOfInvocation(MethodInvocation invocation)
  {
    MethodBinding methodBinding= invocation.getMethodBinding();
    Signature signature= Project.getSingleton().getSignature(methodBinding.getDeclaringClass().getClassName());
    signature= Project.getSingleton().getSignature(methodBinding.getRelativeSignature());
    return signature;
  }
View Full Code Here

      else
      {
        assert expression instanceof ClassInstanceCreation;
      }

      Signature signature= Project.getSingleton().getSignature(methodBinding.toString()).relative();
      String signatureReplaced= normalizeExpression(signature);

      print("dragomeJs.StringInit" + signatureReplaced + "(");
      //      print("dragomeJs.StringInit" + signature.getId() + "(");
      generateList(invocation.getArguments());
      print(")");
      return;
    }

    if (invocation.isSuper(typeDecl.getClassName()))
    {
      //      print(prefix);
      //      print(INVOKESUPER);
      //      print("(");
     
      String string= "arguments.callee.self.superclass.prototype.{methodName}.call(this";

      if (methodBinding.getDeclaringClass().referencesInterface())
      {
        String invokeClassName= normalizeExpression(methodBinding.getDeclaringClass());
        string= invokeClassName+ ".$$members.{methodName}.call(this";
      }

      if (Modifier.isStatic(invocation.methodDecl.getAccess()))
        string= "this.superclass.prototype.{methodName}.call(arguments[0]";

      Signature signature= getSignatureOfInvocation(invocation);
      String methodName= normalizeExpression(signature);
      string= string.replace("{methodName}", methodName);

      if (invocation.getArguments().isEmpty())
      {
        print(string);
        print(")");
      }
      else
      {
        print(string);
        print(", ");
        generateList(invocation.getArguments());
        print(")");
      }

      //      print("this.");
      //      String declaringClass= normalizeExpression(methodBinding.getDeclaringClass().getClassName());
      //      print(declaringClass);
      //      print("_");
      //      //      generateArguments(invocation);
      //      generateList(invocation.getArguments());
      //      print(")");
      //      superMethods.add(invocation);

      //      if (expression == null)
      //      {
      //    print("null");
      //      }
      //      else
      //      {
      //    expression.visit(this);
      //      }
      //      print(", ");
    }
    else if (invocation.isSpecial)
    {
      // print(getSignatureReference(Signature.getSignature(className)));
      // print(", ");

      if (methodBinding.isConstructor() && expression instanceof ThisExpression && !"java.lang.String".equals(className))
      {
        String normalizeExpression= normalizeExpression(className);
        print(normalizeExpression);
        print(".prototype.");
        Signature signature= getSignatureOfInvocation(invocation);
        print(normalizeExpression(signature));
        print(".call(this");
        if (!invocation.getArguments().isEmpty())
          print(",");
        generateList(invocation.getArguments());
        print(")");
      }
      else
      {
        expression.visit(this);
        print(".");
        generateArguments(invocation);
      }

    }
    else if (expression == null)
    {
      boolean isStatic= true;//Modifier.isStatic(invocation.methodDecl.getAccess());

      Signature signature= Project.getSingleton().getSignature(methodBinding.getDeclaringClass().getClassName());
//      if (isStatic)
//        print("_getClassForStatic(");
      print(normalizeExpression(signature));
//      if (isStatic)
//      {
View Full Code Here

      ac.getInitializer().visit(this);
    }
    else
    {
      print("dragomeJs.newArray('");
      Signature signature= Project.getSingleton().getArraySignature(ac.getTypeBinding());
      print(signature.toString());
      print("', [");
      for (int i= 0; i < ac.getDimensions().size(); i++)
      {
        print(i == 0 ? "" : ", ");
        ac.getDimensions().get(i).visit(this);
View Full Code Here

      // Static access.
      String normalizeExpression= normalizeExpression(Project.getSingleton().getSignature(fr.getType().getClassName()));
      boolean sameType= currentMethodDeclaration.getMethodBinding().getDeclaringClass().equals(fr.getType());
      if (true || "<clinit>".equals(currentMethodDeclaration.getMethodBinding().getName()) && !sameType)
      {
        String clinitExpression= normalizeExpression(new Signature("<clinit>()void", 0));
        print("" + normalizeExpression + "." + clinitExpression + "()");
      }
      else
        print(normalizeExpression);
    }
View Full Code Here

    project.currentGeneratedMethods= 0;

    if (DragomeJsCompiler.compiler.getSingleEntryPoint() != null)
    {
      Signature signature= project.getSignature(DragomeJsCompiler.compiler.getSingleEntryPoint());
      ClassUnit clazz= project.getClassUnit(signature.className());
      clazz.write(0, writer);
    }
    else
    {
      ClassUnit object= project.getJavaLangObject();
      object.write(0, writer);

      do
      {
        ClassUnit.oneWritten= false;
        for (ClassUnit cu : project.getClasses())
        {
          //    if (cu.isInterface)
          {
            cu.write(0, writer);
          }
        }
      }
      while (ClassUnit.oneWritten);

    }

    ClassUnit stringClazz= project.getClassUnit(String.class.getName());
    ClassUnit stringSuperClazz= stringClazz.getSuperUnit();

    Collection<MemberUnit> declaredMembers= new ArrayList<MemberUnit>(stringClazz.getDeclaredMembers());
    declaredMembers.addAll(stringSuperClazz.getDeclaredMembers());

    for (MemberUnit memberUnit : declaredMembers)
    {
      Signature signature= memberUnit.getSignature();
      String normalizeExpression= DragomeJavaScriptGenerator.normalizeExpression(signature);
      writer.write("String.prototype." + normalizeExpression + "= java_lang_String.prototype." + normalizeExpression + ";\n");
    }

    writer.write("String.prototype.classname= \"java_lang_String\";\n");
View Full Code Here

    for (MemberUnit member : clazz.getDeclaredMembers())
    {
      for (ClassUnit superType : clazz.getSupertypes())
      {
        Signature signature= Project.getSingleton().getSignature(superType.getName(), member.getSignature().toString());
        //if (taintedSignatures.contains(signature))
        {
          taint(member);
        }
      }
View Full Code Here

TOP

Related Classes of com.dragome.compiler.type.Signature

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.