Package org.mule.mvel2.compiler

Examples of org.mule.mvel2.compiler.ExpressionCompiler


    String line4 = "System.out.println( \"a1\" );\n";
    String expr = line1 + line2 + line3 + line4;

    System.out.println(expr);

    ExpressionCompiler compiler = new ExpressionCompiler(expr);

    ParserContext context = new ParserContext();
    context.addImport("System", System.class);
    context.addImport("Cheese", Cheese.class);
    context.setStrictTypeEnforcement(true);
    context.setDebugSymbols(true);
    context.setSourceFile("mysource");

    String s = org.mvel2.debug.DebugTools.decompile(compiler.compile(context));

    System.out.println("output: " + s);

    int fromIndex = 0;
    int count = 0;
View Full Code Here


            "System.out.println('5');\n" +   // 6
            "a = 0;\n" +                     // 7
            "b = 1;\n" +                    // 8
            "a + b";                        // 9

    ExpressionCompiler compiler = new ExpressionCompiler(expression);

    System.out.println("Expression:\n------------");
    System.out.println(expression);
    System.out.println("------------");

    ParserContext ctx = new ParserContext();
    ctx.setSourceFile("test2.mv");
    ctx.setDebugSymbols(true);

    CompiledExpression compiled = compiler.compile(ctx);

    MVELRuntime.registerBreakpoint("test2.mv", 9);

    final Set<Integer> linesEncountered = new HashSet<Integer>();
View Full Code Here

    assertEquals(1, MVEL.executeDebugger(compiled, null, new MapVariableResolverFactory(createTestMap())));
    assertTrue("Debugger did not break at line 9", linesEncountered.contains(9));
  }

  public void testBreakpointsAcrossComments2() {
    ExpressionCompiler compiler = new ExpressionCompiler(
            "// This is a comment\n" +                  // 1
                    "//Second comment line\n" +         // 2
                    "//Third Comment Line\n" +          // 3
                    "\n" +                              // 4
                    "//Test\n" +                        // 5
                    "System.out.println('4');\n" +      // 6
                    "//System.out.println('5'); \n" +    // 7
                    "a = 0;\n" +                        // 8
                    "b = 1;\n" +                        // 9
                    " a + b");                          // 10


    ParserContext ctx = new ParserContext();
    ctx.setSourceFile("test2.mv");
    ctx.setDebugSymbols(true);

    CompiledExpression compiled = compiler.compile(ctx);

    MVELRuntime.registerBreakpoint("test2.mv", 6);
    MVELRuntime.registerBreakpoint("test2.mv", 8);
    MVELRuntime.registerBreakpoint("test2.mv", 9);
    MVELRuntime.registerBreakpoint("test2.mv", 10);
View Full Code Here

      }
    });

    expression = parseMacros(expression, macros);

    ExpressionCompiler compiler = new ExpressionCompiler(expression);

    ParserContext ctx = new ParserContext();
    ctx.setDebugSymbols(true);
    ctx.setSourceFile("test2.mv");
    ctx.addImport("Foo244", Foo.class);
    ctx.setInterceptors(interceptors);

    CompiledExpression compiled = compiler.compile(ctx);

    System.out.println("\nExpression:------------");
    System.out.println(expression);
    System.out.println("------------");
View Full Code Here

    Map<String, Interceptor> interceptors = new HashMap<String, Interceptor>();
    Map<String, Macro> macros = new HashMap<String, Macro>();

    expression = parseMacros(expression, macros);

    ExpressionCompiler compiler = new ExpressionCompiler(expression);

    ParserContext ctx = new ParserContext();
    ctx.setSourceFile("test2.mv");
    ctx.setDebugSymbols(true);
    ctx.addImport("Foo244", Foo.class);
    ctx.setInterceptors(interceptors);

    CompiledExpression compiled = compiler.compile(ctx);

    System.out.println("\nExpression:------------");
    System.out.println(expression);
    System.out.println("------------");
View Full Code Here

    String expr = "   System.out.println( \"a1\" );\r\n" +
            "   System.out.println( \"a2\" );\r\n" +
            "   System.out.println( \"a3\" );\r\n" +
            "   System.out.println( \"a4\" );\r\n";

    ExpressionCompiler compiler = new ExpressionCompiler(expr);

    ParserContext ctx = new ParserContext();
    ctx.setStrictTypeEnforcement(true);
    ctx.setDebugSymbols(true);
    ctx.setSourceFile("mysource");

    String s = org.mvel2.debug.DebugTools.decompile(compiler.compile(ctx));

    System.out.println(s);

    int fromIndex = 0;
    int count = 0;
View Full Code Here

    String expr = "   System.out.println( \"a1\" );\n" +
            "   System.out.println( \"a2\" );\n" +
            "   System.out.println( \"a3\" );\n" +
            "   System.out.println( \"a4\" );\n";

    ExpressionCompiler compiler = new ExpressionCompiler(expr);

    ParserContext ctx = new ParserContext();
    ctx.setStrictTypeEnforcement(true);
    ctx.setDebugSymbols(true);
    ctx.setSourceFile("mysource");

    String s = org.mvel2.debug.DebugTools.decompile(compiler.compile(ctx));

    int fromIndex = 0;
    int count = 0;
    while ((fromIndex = s.indexOf("DEBUG_SYMBOL", fromIndex + 1)) > -1) {
      count++;
View Full Code Here

    String expr = "   System.out.println( \"a1\" );\n" +
            "   System.out.println( \"a2\" );\r\n" +
            "   System.out.println( \"a3\" );\n" +
            "   System.out.println( \"a4\" );\r\n";

    ExpressionCompiler compiler = new ExpressionCompiler(expr);

    ParserContext ctx = new ParserContext();
    ctx.setStrictTypeEnforcement(true);
    ctx.setDebugSymbols(true);
    ctx.setSourceFile("mysource");

    String s = org.mvel2.debug.DebugTools.decompile(compiler.compile(ctx));

    System.out.println(s);

    int fromIndex = 0;
    int count = 0;
View Full Code Here

    String ex = "System.out.println( Cheese.STILTON );";
    ParserContext ctx = new ParserContext();
    ctx.setStrongTyping(true);
    ctx.addImport(Cheese.class);
    try {
      ExpressionCompiler compiler = new ExpressionCompiler(ex);
      CompiledExpression expr = compiler.compile(ctx);

      // executing the following line with a MVEL.executeExpression() works fine
      // but executeDebugger() fails
      MVEL.executeDebugger(expr, null, (VariableResolverFactory) null);
    }
View Full Code Here

      public String doMacro() {
        return "@Modify with";
      }
    });

    ExpressionCompiler compiler = new ExpressionCompiler(parseMacros("modify (foo) { aValue = 'poo = poo', bValue = 'poo, poo' }; mod", macros));

    ParserContext ctx = new ParserContext(null, interceptors, null);
    ctx.setSourceFile("test.mv");
    ctx.setDebugSymbols(true);

    assertEquals("FOOBAR!", executeExpression(compiler.compile(ctx), null, vars));
  }
View Full Code Here

TOP

Related Classes of org.mule.mvel2.compiler.ExpressionCompiler

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.