Esempio n. 1
0
ast_t* program_load(const char* path, pass_opt_t* options)
{
  ast_t* program = ast_blank(TK_PROGRAM);
  ast_scope(program);

  options->program_pass = PASS_PARSE;

  // Always load builtin package first, then the specified one.
  if(package_load(program, stringtab("builtin"), options) == NULL ||
    package_load(program, path, options) == NULL)
  {
    ast_free(program);
    return NULL;
  }

  // Reorder packages so specified package is first.
  ast_t* builtin = ast_pop(program);
  ast_append(program, builtin);

  if(!ast_passes_program(program, options))
  {
    ast_free(program);
    return NULL;
  }

  return program;
}
Esempio n. 2
0
ast_t* program_load(const char* path, pass_opt_t* options)
{
  ast_t* program = ast_blank(TK_PROGRAM);
  ast_scope(program);

  options->type_catchup_pass = PASS_PARSE;

  if(package_load(program, path, options) == NULL ||
    !ast_passes_program(program, options))
  {
    ast_free(program);
    return NULL;
  }

  return program;
}
Esempio n. 3
0
ast_t* program_load(const char* path, pass_opt_t* options)
{
  ast_t* program = ast_blank(TK_PROGRAM);
  ast_scope(program);

  if(package_load(program, path, options) == NULL)
  {
    ast_free(program);
    return NULL;
  }

  if(!program_passes(program, options))
  {
    ast_free(program);
    return NULL;
  }

  return program;
}
Esempio n. 4
0
bool use_package(ast_t* ast, const char* path, ast_t* name,
  pass_opt_t* options)
{
  assert(ast != NULL);
  assert(path != NULL);

  ast_t* package = package_load(ast, path, options);

  if(package == NULL)
  {
    ast_error(ast, "can't load package '%s'", path);
    return false;
  }

  if(name != NULL && ast_id(name) == TK_ID) // We have an alias
    return set_scope(NULL, ast, name, package);

  // Store the package so we can import it later without having to look it up
  // again
  ast_setdata(ast, (void*)package);
  return true;
}
Esempio n. 5
0
static int _load(lua_State *l) {
    stringid64_t package_name = stringid64_from_string(luasys_to_string(l, 1));
    package_load(package_name);
    return 0;
}