Permalink
Browse files

Unfished work implemented API functions

  • Loading branch information...
1 parent b50f1fc commit 3562b6b4baee0443eb34fb78fd451b82ed4aa198 Mariano Wahlmann committed Dec 6, 2010
Showing with 71 additions and 0 deletions.
  1. +24 −0 include/parrot/api.h
  2. +47 −0 src/embed/api.c
View
24 include/parrot/api.h
@@ -129,6 +129,16 @@ Parrot_Int Parrot_api_flag(
FUNC_MODIFIES(*interp_pmc);
PARROT_API
+Parrot_Int Parrot_api_get_compiler(
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_String *lang),
+ ARGOUT(PMC **compiler))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ __attribute__nonnull__(3)
+ FUNC_MODIFIES(*compiler);
+
+PARROT_API
Parrot_Int Parrot_api_get_result(
ARGMOD(PMC * interp_pmc),
ARGOUT(Parrot_Int *is_error),
@@ -174,6 +184,13 @@ Parrot_Int Parrot_api_load_bytecode_file(
FUNC_MODIFIES(*pbc);
PARROT_API
+Parrot_Int Parrot_api_load_language(
+ ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_String *lang))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2);
+
+PARROT_API
Parrot_Int Parrot_api_make_interpreter(
ARGIN_NULLOK(PMC *parent),
Parrot_Int flags,
@@ -262,6 +279,10 @@ Parrot_Int Parrot_api_set_warnings(
, PARROT_ASSERT_ARG(outfile))
#define ASSERT_ARGS_Parrot_api_flag __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp_pmc))
+#define ASSERT_ARGS_Parrot_api_get_compiler __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(lang) \
+ , PARROT_ASSERT_ARG(compiler))
#define ASSERT_ARGS_Parrot_api_get_result __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp_pmc) \
, PARROT_ASSERT_ARG(is_error) \
@@ -278,6 +299,9 @@ Parrot_Int Parrot_api_set_warnings(
PARROT_ASSERT_ARG(interp_pmc) \
, PARROT_ASSERT_ARG(filename) \
, PARROT_ASSERT_ARG(pbc))
+#define ASSERT_ARGS_Parrot_api_load_language __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
+ PARROT_ASSERT_ARG(interp_pmc) \
+ , PARROT_ASSERT_ARG(lang))
#define ASSERT_ARGS_Parrot_api_make_interpreter __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
PARROT_ASSERT_ARG(interp))
#define ASSERT_ARGS_Parrot_api_run_bytecode __attribute__unused__ int _ASSERT_ARGS_CHECK = (\
View
47 src/embed/api.c
@@ -358,3 +358,50 @@ Parrot_api_set_configuration_hash(Parrot_PMC interp_pmc, Parrot_PMC confighash)
}
+/*
+
+=item C<PARROT_API Parrot_Int Parrot_api_load_language(Parrot_PMC interp_pmc,
+Parrot_String *lang)>
+
+Load the compiler libraries for a given high-level language into the
+interpreter.
+
+=cut
+
+*/
+
+PARROT_API
+Parrot_Int
+Parrot_api_load_language(ARGIN(Parrot_PMC interp_pmc),
+ ARGIN(Parrot_String *lang))
+{
+ ASSERT_ARGS(Parrot_api_load_language)
+ EMBED_API_CALLIN(interp_pmc, interp)
+ STRING * const lang_pmc = Parrot_str_new(interp, lang, strlen(lang));
+ Parrot_load_language(interp, lang_pmc);
+ EMBED_API_CALLOUT(interp_pmc, interp);
+}
+
+
+/*
+
+=item C<PARROT_API Parrot_Int Parrot_api_get_compiler(Parrot_PMC interp_pmc,
+Parrot_String *lang, PMC **compiler) >
+
+=cut
+
+*/
+
+PARROT_API
+Parrot_Int
+Parrot_api_get_compiler(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_String *lang),
+ ARGOUT(PMC **compiler))
+{
+ ASSERT_ARGS(Parrot_api_get_compiler)
+ EMBED_API_CALLIN(interp_pmc, interp)
+ PMC * const compreg_hash = VTABLE_get_pmc_keyed_int(interp,
+ interp->iglobals, IGLOBALS_COMPREG_HASH);
+ STRING * const lang_pmc = Parrot_str_new(interp, lang, strlen(lang));
+ *compiler = VTABLE_get_pmc_keyed_str(interp, compreg_hash, lang_pmc);
+ EMBED_API_CALLOUT(interp_pmc, interp);
+}

0 comments on commit 3562b6b

Please sign in to comment.