Exemplo n.º 1
0
  DelegateValue createFunctionOverride(
      AstNode node,
      String syntax_id,
      FunctionOverrideBlock block,
      String root_prefix,
      Set<String> owner_externals)
      throws Exception {
    generateId(node);
    String name = root_prefix + "$Override" + id_gen.get(node) + syntax_id;
    if (functions.containsKey(name)) {
      return functions.get(name);
    }
    FunctionGenerator generator =
        createFunctionGenerator(node, name, true, root_prefix, owner_externals);
    block.invoke(
        generator,
        generator.getInitialContainerFrame(),
        generator.getInitialContext(),
        generator.getInitialOriginal(),
        generator.getInitialSelfFrame(),
        generator.getInitialSourceReference());
    generator.generateSwitchBlock(false);
    DelegateValue initialiser = generator.getInitialiser();
    functions.put(name, initialiser);

    return initialiser;
  }
Exemplo n.º 2
0
 /**
  * Generate an empty function with comments.
  *
  * @param function Function prototype
  * @return source code of a empty function
  */
 static String generateEmptyFunction(final Function function) {
   return "public class Solution {\n"
       + FunctionGenerator.generateFunction(function, LanguageType.JAVA, 1)
       + "}\n";
 }