Index: src/embed.c =================================================================== --- src/embed.c (revision 36797) +++ src/embed.c (working copy) @@ -22,6 +22,8 @@ #include "parrot/embed.h" #include "parrot/oplib/ops.h" +#include "../compilers/imcc/imc.h" + /* HEADERIZER HFILE: none */ /* The visible types are different than what we use in here */ /* HEADERIZER BEGIN: static */ @@ -1252,6 +1254,44 @@ /* +=item C + +Compile code string. + +=cut + +*/ + +PARROT_EXPORT +Parrot_PMC +Parrot_compile_string(PARROT_INTERP, Parrot_String type, + const char *code, Parrot_String *error) +{ + + /* For the benefit of embedders that does not load any pbc + * before compiling a string + */ + if (! interp->initial_pf) { + PackFile *pf = PackFile_new_dummy(interp, "compile_string"); + /* Assumption: there is no valid reason to fail to create it. + * If the assumption changes, replace the assertio with a + * runtime check + */ + PARROT_ASSERT(interp->initial_pf); + } + + if (Parrot_str_compare(interp, Parrot_str_new(interp, "PIR", 3), type) == 0) + return IMCC_compile_pir_s(interp, code, error); + + if (Parrot_str_compare(interp, Parrot_str_new(interp, "PASM", 4), type) == 0) + return IMCC_compile_pasm_s(interp, code, error); + + *error = Parrot_str_new(interp, "Invalid interpreter type", 0); + return NULL; +} + +/* + =back =head1 SEE ALSO Index: src/inter_misc.c =================================================================== --- src/inter_misc.c (revision 36797) +++ src/inter_misc.c (working copy) @@ -152,47 +152,6 @@ /* -=item C - -Compile code string. - -=cut - -*/ - -PARROT_EXPORT -PARROT_WARN_UNUSED_RESULT -PARROT_CAN_RETURN_NULL -PMC * -Parrot_compile_string(PARROT_INTERP, ARGIN(STRING *type), - ARGIN(const char *code), ARGOUT(STRING **error)) -{ - ASSERT_ARGS(Parrot_compile_string) - - /* For the benefit of embedders that does not load any pbc - * before compiling a string - */ - if (! interp->initial_pf) { - PackFile *pf = PackFile_new_dummy(interp, "compile_string"); - /* Assumption: there is no valid reason to fail to create it. - * If the assumption changes, replace the assertio with a - * runtime check - */ - PARROT_ASSERT(interp->initial_pf); - } - - if (Parrot_str_compare(interp, CONST_STRING(interp, "PIR"), type) == 0) - return IMCC_compile_pir_s(interp, code, error); - - if (Parrot_str_compare(interp, CONST_STRING(interp, "PASM"), type) == 0) - return IMCC_compile_pasm_s(interp, code, error); - - *error = CONST_STRING(interp, "Invalid interpreter type"); - return NULL; -} - -/* - =item C Compile code file. Index: MANIFEST =================================================================== --- MANIFEST (revision 36797) +++ MANIFEST (working copy) @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Mon Feb 16 07:09:26 2009 UT +# generated by tools/dev/mk_manifest_and_skip.pl Mon Feb 16 19:00:35 2009 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -897,6 +897,7 @@ include/parrot/cclass.h [main]include include/parrot/charset.h [main]include include/parrot/compiler.h [main]include +include/parrot/core_types.h [main]include include/parrot/datatypes.h [main]include include/parrot/debugger.h [main]include include/parrot/dynext.h [main]include Index: MANIFEST.SKIP =================================================================== --- MANIFEST.SKIP (revision 36797) +++ MANIFEST.SKIP (working copy) @@ -1,6 +1,6 @@ # ex: set ro: # $Id$ -# generated by tools/dev/mk_manifest_and_skip.pl Mon Feb 16 06:10:54 2009 UT +# generated by tools/dev/mk_manifest_and_skip.pl Mon Feb 16 19:00:35 2009 UT # # This file should contain a transcript of the svn:ignore properties # of the directories in the Parrot subversion repository. (Needed for @@ -973,8 +973,8 @@ ^lib/Parrot/Config/Generated\.pm$ ^lib/Parrot/Config/Generated\.pm/ # generated from svn:ignore of 'lib/Parrot/Pmc2c/' -^lib/Parrot/Pmc2c/PCCMETHOD_BITS\.pl$ -^lib/Parrot/Pmc2c/PCCMETHOD_BITS\.pl/ +^lib/Parrot/Pmc2c/PCCMETHOD_BITS\.pm$ +^lib/Parrot/Pmc2c/PCCMETHOD_BITS\.pm/ # generated from svn:ignore of 'runtime/parrot/dynext/' ^runtime/parrot/dynext/.*\.bundle$ ^runtime/parrot/dynext/.*\.bundle/ Index: include/parrot/parrot.h =================================================================== --- include/parrot/parrot.h (revision 36797) +++ include/parrot/parrot.h (working copy) @@ -18,6 +18,8 @@ #ifndef PARROT_PARROT_H_GUARD #define PARROT_PARROT_H_GUARD +#include "parrot/core_types.h" + #if defined(INSIDE_GLOBAL_SETUP) # define VAR_SCOPE #else @@ -116,7 +118,6 @@ #define OPCODE_TYPE_JAVA 4871757 #define OPCODE_TYPE_MSNET 0x2e4e4554 -typedef struct PMC PMC; typedef void STRING_FUNCS; typedef struct parrot_interp_t Interp; Index: include/parrot/embed.h =================================================================== --- include/parrot/embed.h (revision 36797) +++ include/parrot/embed.h (working copy) @@ -15,6 +15,7 @@ #ifndef PARROT_EMBED_H_GUARD #define PARROT_EMBED_H_GUARD +#include "parrot/core_types.h" /* types used */ #include "parrot/compiler.h" /* compiler capabilities */ #include "parrot/config.h" /* PARROT_VERSION, PARROT_JIT_CAPABLE... */ #include "parrot/interpreter.h" /* give us the interpreter flags */ @@ -59,6 +60,9 @@ PARROT_EXPORT void Parrot_runcode(Parrot_Interp, int argc, char **argv); +PARROT_EXPORT Parrot_PMC Parrot_compile_string(Parrot_Interp, + Parrot_String type, const char *code, Parrot_String *error); + PARROT_EXPORT void Parrot_destroy(Parrot_Interp); PARROT_EXPORT Parrot_Opcode * Parrot_debug(Parrot_Interp, Parrot_Interp, Parrot_Opcode *pc); Index: include/parrot/core_types.h =================================================================== --- include/parrot/core_types.h (revision 0) +++ include/parrot/core_types.h (revision 0) @@ -0,0 +1,28 @@ +/* core_types.h + * Copyright (C) 2009, Parrot Foundation. + * SVN Info + * $Id: $ + * Overview: + * Forward declaration of the interpreter basic types + */ + +#ifndef PARROT_CORE_TYPES_H_GUARD +#define PARROT_CORE_TYPES_H_GUARD + +typedef struct PMC PMC; +typedef PMC *Parrot_PMC; + +struct parrot_string_t; +typedef struct parrot_string_t *Parrot_String; + +struct parrot_interp_t; +typedef struct parrot_interp_t *Parrot_Interp; + +#endif /* PARROT_CORE_TYPES_H_GUARD */ + +/* + * Local variables: + * c-file-style: "parrot" + * End: + * vim: expandtab shiftwidth=4: + */ Index: include/parrot/string.h =================================================================== --- include/parrot/string.h (revision 36797) +++ include/parrot/string.h (working copy) @@ -13,10 +13,9 @@ #ifndef PARROT_STRING_H_GUARD #define PARROT_STRING_H_GUARD +#include "parrot/core_types.h" #include "parrot/config.h" -struct parrot_string_t; - #ifdef PARROT_IN_CORE #include "parrot/pobj.h" Index: include/parrot/interpreter.h =================================================================== --- include/parrot/interpreter.h (revision 36797) +++ include/parrot/interpreter.h (working copy) @@ -110,13 +110,9 @@ #ifdef PARROT_IN_CORE -#define Parrot_String STRING * -#define Parrot_PMC PMC * #define Parrot_Language Parrot_Int #define Parrot_Vtable struct _vtable* -typedef struct parrot_interp_t *Parrot_Interp; - typedef Parrot_Interp_flag Interp_flags; typedef Parrot_Run_core_t Run_Cores; @@ -610,19 +606,6 @@ FUNC_MODIFIES(*error); PARROT_EXPORT -PARROT_WARN_UNUSED_RESULT -PARROT_CAN_RETURN_NULL -PMC * Parrot_compile_string(PARROT_INTERP, - ARGIN(STRING *type), - ARGIN(const char *code), - ARGOUT(STRING **error)) - __attribute__nonnull__(1) - __attribute__nonnull__(2) - __attribute__nonnull__(3) - __attribute__nonnull__(4) - FUNC_MODIFIES(*error); - -PARROT_EXPORT void Parrot_compreg(PARROT_INTERP, ARGIN(STRING *type), NOTNULL(Parrot_compiler_func_t func)) @@ -675,11 +658,6 @@ PARROT_ASSERT_ARG(interp) \ || PARROT_ASSERT_ARG(fullname) \ || PARROT_ASSERT_ARG(error) -#define ASSERT_ARGS_Parrot_compile_string __attribute__unused__ int _ASSERT_ARGS_CHECK = \ - PARROT_ASSERT_ARG(interp) \ - || PARROT_ASSERT_ARG(type) \ - || PARROT_ASSERT_ARG(code) \ - || PARROT_ASSERT_ARG(error) #define ASSERT_ARGS_Parrot_compreg __attribute__unused__ int _ASSERT_ARGS_CHECK = \ PARROT_ASSERT_ARG(interp) \ || PARROT_ASSERT_ARG(type) \ @@ -728,9 +706,6 @@ #else /* !PARROT_IN_CORE */ -struct Parrot_Interp_; -typedef struct Parrot_Interp_ *Parrot_Interp; - typedef void * *(*native_func_t)(PARROT_INTERP, void *cur_opcode, void *start_code); Index: include/parrot/extend.h =================================================================== --- include/parrot/extend.h (revision 36797) +++ include/parrot/extend.h (working copy) @@ -16,6 +16,7 @@ #define PARROT_EXTEND_H_GUARD #include +#include "parrot/core_types.h" #include "parrot/config.h" /* PARROT_VERSION, PARROT_JIT_CAPABLE... */ #include "parrot/interpreter.h" /* give us the interpreter flags */ #include "parrot/warnings.h" /* give us the warnings flags */ @@ -26,8 +27,6 @@ but that would be really annoying */ #if defined(PARROT_IN_CORE) -#define Parrot_String STRING * -#define Parrot_PMC PMC * #define Parrot_Language Parrot_Int #define Parrot_VTABLE VTABLE * @@ -43,8 +42,6 @@ #else -typedef void * Parrot_String; -typedef void * Parrot_PMC; typedef Parrot_Int Parrot_Language; typedef void * Parrot_Encoding; typedef void * Parrot_CharType; Index: t/src/embed.t =================================================================== --- t/src/embed.t (revision 36797) +++ t/src/embed.t (working copy) @@ -64,7 +64,6 @@ #include "parrot/embed.h" #include "parrot/extend.h" -#include "parrot/interpreter.h" void fail(const char *msg); @@ -79,7 +78,7 @@ Parrot_Interp interp; Parrot_String compiler; Parrot_String errstr; - Parrot_PMC *code; + Parrot_PMC code; /* Create the interprter and show a message using parrot io */ interp = Parrot_new(NULL);