Beispiel #1
0
  protected void parseParamStrings(String paramString, ExpressionFactory expressionFactory) {
    List paramStrings = Util.tokenizeIgnoringEnclosers(paramString, ',');
    for (Iterator itr = paramStrings.iterator(); itr.hasNext(); ) {
      String nextParam = ((String) itr.next()).trim();
      if (!(nextParam.equals(""))) {
        Debug.logn("Find match for param " + nextParam, this);
        if (CallExpression.isVariable(this.context, nextParam)) {
          DNVariable v = CallExpression.getVariable(this.context, nextParam);
          parameters.add(v);
        } else if (expressionFactory.getExpression(nextParam, this.context) != null) {

          parameters.add(expressionFactory.getExpression(nextParam, this.context));
        }
      }
    }
  }
Beispiel #2
0
 private static List createVBArrayCreationDeclatationsAndSubstituteParams(
     List oldParameters, List newParameters, InterpretationContext context) {
   List arrayCreationDeclarations = new ArrayList();
   String s = ACE_VARIABLE_NAME;
   for (Iterator itr = oldParameters.iterator(); itr.hasNext(); ) {
     Object o = itr.next();
     if (o instanceof ArrayCreationExpression) {
       ArrayCreationExpression ace = (ArrayCreationExpression) o;
       LocalVariableDeclaration ds =
           LocalVariableDeclaration.createVBLocalVariableDeclaration(context, ace, s + aceCounter);
       arrayCreationDeclarations.add(ds);
       newParameters.add(DNVariable.createVBVariable(s + aceCounter, ace.getName() + "()"));
       aceCounter++;
     } else {
       newParameters.add(o);
     }
   }
   return arrayCreationDeclarations;
 }
Beispiel #3
0
  public JavaProgram createJavaProgram(
      List sourceFiles,
      String libraryPath,
      String mainClassname,
      String projectType,
      String policyType)
      throws Exception {
    // Debug.setOn(true);
    long l = Debug.getTime();
    LibraryData libraryData = new LibraryData(new File(libraryPath), projectType, language, false);
    Library library = new Library(libraryData);
    Parser parser =
        Parser.createParser(this.language, sourceFiles, library, new TranslationPolicy(policyType));

    long lll = Debug.getTime();
    System.out.println("Library Loaded in " + (lll - l) + "ms");

    ParseTree tree = parser.parse();
    TranslationReport report = tree.getTranslationReport();

    long ll = Debug.getTime();
    System.out.println("Code parsed in " + (ll - lll) + "ms");
    Debug.setOn(true);

    Translator tt = new Translator(this.language);
    JavaProgram jp = tt.createJavaProgram(tree, mainClassname, projectType);

    if (report.hasTypeResolveErrors() || report.hasTranslationWarnings()) {
      List errors = new ArrayList();
      errors.addAll(report.getTypeResolveExceptions());
      report.doReport(errors, report.getTranslationWarnings());
    }

    l = Debug.getTime();
    System.out.println("Translated in " + (l - ll) + "ms");

    jp.setTypeResolved(!report.hasTypeResolveErrors()); // resolved if no errors

    return jp;
  }
Beispiel #4
0
  public WebProgram createWebProgram(List asps, JavaProgram jp) throws Exception {
    WebProgram wp = new WebProgram(asps, jp);

    for (Iterator itr = asps.iterator(); itr.hasNext(); ) {
      ASP asp = (ASP) itr.next();
      asp.translate();
    }

    // do the WebForm initialisation code
    List javaWebForms = wp.getWebForms();
    Library library = jp.getLibrary();
    for (Iterator itr = javaWebForms.iterator(); itr.hasNext(); ) {
      JavaClass jc = (JavaClass) itr.next();
      WebTranslator.addJavaComponentInitialisation(jc, library);
      doExposePageLoadMethod(jc);
    }

    // do event hookups
    List hookups = jp.getEventHookupClasses();
    for (Iterator itr = hookups.iterator(); itr.hasNext(); ) {
      EventSupport es = (EventSupport) itr.next();
      // System.out.println(es.getVBSender());
      for (Iterator itrr = asps.iterator(); itrr.hasNext(); ) {
        ASP asp = (ASP) itrr.next();
        DNVariable v = asp.getComponent(es.getVBSender().getName());
        if (v != null) {
          asp.addActionListenerFor(v, es.getName());
        }
      }
    }

    return wp;
  }