Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of git://github.com/Alekssasho/parrot into load…

…_language_refactor
  • Loading branch information...
commit 910982f820bd4de885cbe435005aad9e98b128d0 2 parents 9a764f7 + bf40847
@Whiteknight Whiteknight authored
View
2  docs/embed.pod
@@ -908,7 +908,7 @@ The list may also be augmented if additional functionality is required.
=item C<Parrot_load_encoding>
-=item C<Parrot_load_language>
+=item C<Parrot_pf_load_language>
=item C<Parrot_dyn_load_lib>
View
2  src/embed/api.c
@@ -533,7 +533,7 @@ Parrot_api_load_language(Parrot_PMC interp_pmc, ARGIN(Parrot_String lang))
{
ASSERT_ARGS(Parrot_api_load_language)
EMBED_API_CALLIN(interp_pmc, interp)
- Parrot_load_language(interp, lang);
+ Parrot_pf_load_language(interp, lang);
EMBED_API_CALLOUT(interp_pmc, interp);
}
View
2  src/ops/core.ops
@@ -132,7 +132,7 @@ locate the main compiler file in the standard locations.
=cut
inline op load_language(in STR) :load_file {
- Parrot_load_language(interp, $1);
+ Parrot_pf_load_language(interp, $1);
}
=back
View
4 src/ops/core_ops.c
@@ -13384,13 +13384,13 @@ Parrot_load_bytecode_p_sc(opcode_t *cur_opcode, PARROT_INTERP) {
opcode_t *
Parrot_load_language_s(opcode_t *cur_opcode, PARROT_INTERP) {
- Parrot_load_language(interp, SREG(1));
+ Parrot_pf_load_language(interp, SREG(1));
return (opcode_t *)cur_opcode + 2;
}
opcode_t *
Parrot_load_language_sc(opcode_t *cur_opcode, PARROT_INTERP) {
- Parrot_load_language(interp, SCONST(1));
+ Parrot_pf_load_language(interp, SCONST(1));
return (opcode_t *)cur_opcode + 2;
}
View
149 src/packfile/api.c
@@ -37,9 +37,9 @@ format of bytecode.
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
static void base_path_module(PARROT_INTERP,
- ARGIN(STRING *found_ext),
ARGIN(STRING *lang_name),
- ARGIN(STRING *path))
+ ARGIN(STRING *path),
+ ARGIN(STRING *pbc))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
__attribute__nonnull__(3)
@@ -54,13 +54,16 @@ static void check_bytecode_or_source_file(PARROT_INTERP,
__attribute__nonnull__(3)
__attribute__nonnull__(4);
-PARROT_WARN_UNUSED_RESULT
-static int check_lang_load(PARROT_INTERP,
- ARGIN(PMC *is_loaded_hash),
- ARGIN(STRING *wo_ext))
+static void check_lang_load(PARROT_INTERP,
+ ARGIN(STRING *wo_ext),
+ ARGIN(STRING *file_str),
+ ARGIN(STRING *lang_name),
+ ARGIN(STRING *pbc))
__attribute__nonnull__(1)
__attribute__nonnull__(2)
- __attribute__nonnull__(3);
+ __attribute__nonnull__(3)
+ __attribute__nonnull__(4)
+ __attribute__nonnull__(5);
static void compile_file(PARROT_INTERP, ARGIN(STRING *path), INTVAL is_pasm)
__attribute__nonnull__(1)
@@ -105,16 +108,9 @@ static INTVAL find_pf_ann_idx(
__attribute__nonnull__(1)
__attribute__nonnull__(2);
-static void full_path_name(PARROT_INTERP,
- ARGIN(STRING *wo_ext),
- ARGIN(STRING *file_str),
- ARGIN(STRING *pbc),
- ARGIN(STRING *lang_name))
+static void full_path_name(PARROT_INTERP, ARGIN(STRING *lang_name))
__attribute__nonnull__(1)
- __attribute__nonnull__(2)
- __attribute__nonnull__(3)
- __attribute__nonnull__(4)
- __attribute__nonnull__(5);
+ __attribute__nonnull__(2);
static void load_file(PARROT_INTERP, ARGIN(STRING *path))
__attribute__nonnull__(1)
@@ -200,9 +196,9 @@ static int sub_pragma(PARROT_INTERP,
#define ASSERT_ARGS_base_path_module __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(found_ext) \
, PARROT_ASSERT_ARG(lang_name) \
- , PARROT_ASSERT_ARG(path))
+ , PARROT_ASSERT_ARG(path) \
+ , PARROT_ASSERT_ARG(pbc))
#define ASSERT_ARGS_check_bytecode_or_source_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(found_ext) \
@@ -210,8 +206,10 @@ static int sub_pragma(PARROT_INTERP,
, PARROT_ASSERT_ARG(path))
#define ASSERT_ARGS_check_lang_load __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(is_loaded_hash) \
- , PARROT_ASSERT_ARG(wo_ext))
+ , PARROT_ASSERT_ARG(wo_ext) \
+ , PARROT_ASSERT_ARG(file_str) \
+ , PARROT_ASSERT_ARG(lang_name) \
+ , PARROT_ASSERT_ARG(pbc))
#define ASSERT_ARGS_compile_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
, PARROT_ASSERT_ARG(path))
@@ -231,9 +229,6 @@ static int sub_pragma(PARROT_INTERP,
, PARROT_ASSERT_ARG(key))
#define ASSERT_ARGS_full_path_name __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
- , PARROT_ASSERT_ARG(wo_ext) \
- , PARROT_ASSERT_ARG(file_str) \
- , PARROT_ASSERT_ARG(pbc) \
, PARROT_ASSERT_ARG(lang_name))
#define ASSERT_ARGS_load_file __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp) \
@@ -2120,8 +2115,7 @@ load_file(PARROT_INTERP, ARGIN(STRING *path))
/*
-=item C<static void full_path_name(PARROT_INTERP, STRING *wo_ext, STRING
-*file_str, STRING *pbc, STRING *lang_name)>
+=item C<static void full_path_name(PARROT_INTERP, STRING *lang_name)>
This function is only for local use of Parrot_pf_load_language();
@@ -2129,22 +2123,27 @@ This function is only for local use of Parrot_pf_load_language();
*/
static void
-full_path_name(PARROT_INTERP, ARGIN(STRING *wo_ext), ARGIN(STRING *file_str),
- ARGIN(STRING *pbc), ARGIN(STRING *lang_name))
+full_path_name(PARROT_INTERP, ARGIN(STRING *lang_name))
{
- ASSERT_ARGS(full_path_name)
+ //ASSERT_ARGS(full_path_name)
+ STRING *wo_ext, *file_str, *pbc;
+ pbc = CONST_STRING(interp, "pbc");
+
/* Full path to language library is "abc/abc.pbc". */
wo_ext = Parrot_str_concat(interp, lang_name, CONST_STRING(interp, "/"));
wo_ext = Parrot_str_concat(interp, wo_ext, lang_name);
file_str = Parrot_str_concat(interp, wo_ext, CONST_STRING(interp, "."));
file_str = Parrot_str_concat(interp, file_str, pbc);
+
+ /* Check if the language is already loaded */
+ check_lang_load(interp, wo_ext, file_str, lang_name, pbc);
}
/*
-=item C<static int check_lang_load(PARROT_INTERP, PMC *is_loaded_hash, STRING
-*wo_ext)>
+=item C<static void check_lang_load(PARROT_INTERP, STRING *wo_ext, STRING
+*file_str, STRING *lang_name, STRING *pbc)>
This function is only for local use of Parrot_pf_load_language();
@@ -2152,25 +2151,44 @@ This function is only for local use of Parrot_pf_load_language();
*/
-PARROT_WARN_UNUSED_RESULT
-static int
-check_lang_load(PARROT_INTERP, ARGIN(PMC *is_loaded_hash), ARGIN(STRING *wo_ext))
+static void
+check_lang_load(PARROT_INTERP, ARGIN(STRING *wo_ext), ARGIN(STRING *file_str),
+ ARGIN(STRING *lang_name), ARGIN(STRING *pbc))
{
- ASSERT_ARGS(check_lang_load)
+ //ASSERT_ARGS(check_lang_load)
+
+ enum_runtime_ft file_type;
+ PMC *is_loaded_hash;
+ STRING *path;
/* Check if the language is already loaded */
is_loaded_hash = VTABLE_get_pmc_keyed_int(interp,
interp->iglobals, IGLOBALS_PBC_LIBS);
if (VTABLE_exists_keyed_str(interp, is_loaded_hash, wo_ext))
- return 1;
- return 0;
+ return;
+
+ file_type = PARROT_RUNTIME_FT_LANG;
+
+ path = Parrot_locate_runtime_file_str(interp, file_str, file_type);
+ if (!path)
+ Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LIBRARY_ERROR,
+ "\"load_language\" couldn't find a compiler module for the language '%Ss'", lang_name);
+
+ /* remember wo_ext => full_path mapping */
+
+ VTABLE_set_string_keyed_str(interp, is_loaded_hash,
+ wo_ext, path);
+
+ /* Add the include and dynext paths to the global search */
+
+ base_path_module(interp, lang_name, path, pbc);
}
/*
-=item C<static void base_path_module(PARROT_INTERP, STRING *found_ext, STRING
-*lang_name, STRING *path)>
+=item C<static void base_path_module(PARROT_INTERP, STRING *lang_name, STRING
+*path, STRING *pbc)>
This function is only for local use of Parrot_pf_load_language();
@@ -2179,14 +2197,14 @@ This function is only for local use of Parrot_pf_load_language();
*/
static void
-base_path_module(PARROT_INTERP, ARGIN(STRING *found_ext), ARGIN(STRING *lang_name),
- ARGIN(STRING *path))
+base_path_module(PARROT_INTERP, ARGIN(STRING *lang_name), ARGIN(STRING *path),
+ ARGIN(STRING *pbc))
{
- ASSERT_ARGS(base_path_module)
+ //ASSERT_ARGS(base_path_module)
- /* Get the base path of the located module */
+ /* Get the base path of the located module */
INTVAL name_length;
- STRING *found_path;
+ STRING *found_ext, *found_path;
parrot_split_path_ext(interp, path, &found_path, &found_ext);
name_length = Parrot_str_length(interp, lang_name);
@@ -2199,6 +2217,10 @@ base_path_module(PARROT_INTERP, ARGIN(STRING *found_ext), ARGIN(STRING *lang_nam
PARROT_LIB_PATH_DYNEXT);
Parrot_lib_add_path(interp, Parrot_str_concat(interp, found_path, CONST_STRING(interp, "library/")),
PARROT_LIB_PATH_LIBRARY);
+
+ /* Check if the file found was actually a bytecode file (.pbc extension) or
+ * a source file (.pir or .pasm extension. */
+ check_bytecode_or_source_file(interp, found_ext, pbc, path);
}
/*
@@ -2215,7 +2237,7 @@ static void
check_bytecode_or_source_file(PARROT_INTERP, ARGIN(STRING *found_ext),
ARGIN(STRING *pbc), ARGIN(STRING *path))
{
- ASSERT_ARGS(check_bytecode_or_source_file)
+ //ASSERT_ARGS(check_bytecode_or_source_file)
push_context(interp);
@@ -2246,50 +2268,13 @@ void
Parrot_pf_load_language(PARROT_INTERP, ARGIN_NULLOK(STRING *lang_name))
{
ASSERT_ARGS(Parrot_pf_load_language)
- STRING *wo_ext, *file_str, *path, *pbc;
- STRING *found_ext;
-
- enum_runtime_ft file_type;
- PMC *is_loaded_hash;
if (STRING_IS_NULL(lang_name))
Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LIBRARY_ERROR,
"\"load_language\" no language name");
- pbc = CONST_STRING(interp, "pbc");
-
- /* Full path to language library is "abc/abc.pbc". */
-
- full_path_name(interp, wo_ext, file_str, pbc, lang_name);
-
- /* Check if the language is already loaded */
-
- if (check_lang_load(interp, is_loaded_hash, wo_ext) == 1)
- return;
-
- file_type = PARROT_RUNTIME_FT_LANG;
-
- path = Parrot_locate_runtime_file_str(interp, file_str, file_type);
- if (!path)
- Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_LIBRARY_ERROR,
- "\"load_language\" couldn't find a compiler module for the language '%Ss'", lang_name);
-
- /* remember wo_ext => full_path mapping */
-
- VTABLE_set_string_keyed_str(interp, is_loaded_hash,
- wo_ext, path);
-
- /* Add the include and dynext paths to the global search */
-
- /* Get the base path of the located module */
-
- base_path_module (interp, found_ext, lang_name, path);
-
-
- /* Check if the file found was actually a bytecode file (.pbc extension) or
- * a source file (.pir or .pasm extension. */
+ full_path_name(interp, lang_name);
- check_bytecode_or_source_file (interp, found_ext, pbc, path);
}
/*
Please sign in to comment.
Something went wrong with that request. Please try again.