Beispiel #1
0
Datei: pass.c Projekt: ozra/ponyc
bool program_passes(ast_t* program, pass_opt_t* options)
{
  bool r;

  if(do_pass(&program, &r, options, PASS_IMPORT, pass_import, NULL))
    return r;

  if(do_pass(&program, &r, options, PASS_NAME_RESOLUTION, NULL, pass_names))
    return r;

  if(do_pass(&program, &r, options, PASS_FLATTEN, NULL, pass_flatten))
    return r;

  if(do_pass(&program, &r, options, PASS_TRAITS, pass_traits, NULL))
    return r;

  if(options->docs)
    generate_docs(program, options);

  if(do_pass(&program, &r, options, PASS_EXPR, pass_pre_expr, pass_expr))
    return r;

  if(!pass_finalisers(program))
    return false;

  return true;
}
Beispiel #2
0
// Peform the AST passes on the given AST up to the speficied last pass
static bool ast_passes(ast_t** astp, pass_opt_t* options, pass_id last)
{
  assert(astp != NULL);
  bool r;

  if(!visit_pass(astp, options, last, &r, PASS_SUGAR, pass_sugar, NULL))
    return r;

  if(options->check_tree)
    check_tree(*astp, options->check.errors);

  if(!visit_pass(astp, options, last, &r, PASS_SCOPE, pass_scope, NULL))
    return r;

  if(!visit_pass(astp, options, last, &r, PASS_IMPORT, pass_import, NULL))
    return r;

  if(!visit_pass(astp, options, last, &r, PASS_NAME_RESOLUTION, NULL,
    pass_names))
    return r;

  if(!visit_pass(astp, options, last, &r, PASS_FLATTEN, NULL, pass_flatten))
    return r;

  if(!visit_pass(astp, options, last, &r, PASS_TRAITS, pass_traits, NULL))
    return r;

  if(!check_limit(astp, options, PASS_DOCS, last))
    return true;

  if(options->docs && ast_id(*astp) == TK_PROGRAM)
    generate_docs(*astp, options);

  if(!visit_pass(astp, options, last, &r, PASS_EXPR, pass_pre_expr, pass_expr))
    return r;

  if(!check_limit(astp, options, PASS_FINALISER, last))
    return true;

  if(!pass_finalisers(*astp, options))
    return false;

  if(options->check_tree)
    check_tree(*astp, options->check.errors);
  return true;
}