[svn:parrot] r36969 - trunk/examples/embed
jerry gay
jerry.gay at gmail.com
Tue Feb 24 16:46:09 UTC 2009
On Tue, Feb 24, 2009 at 08:27, <NotFound at svn.parrot.org> wrote:
> Author: NotFound
> Date: Tue Feb 24 16:27:36 2009
> New Revision: 36969
> URL: https://trac.parrot.org/parrot/changeset/36969
>
> Log:
> [examples] add several runcore options to lorito
>
> Modified:
> trunk/examples/embed/lorito.c
>
> Modified: trunk/examples/embed/lorito.c
> ==============================================================================
> --- trunk/examples/embed/lorito.c Tue Feb 24 15:44:50 2009 (r36968)
> +++ trunk/examples/embed/lorito.c Tue Feb 24 16:27:36 2009 (r36969)
> @@ -43,17 +43,45 @@
> Parrot_PackFile pf;
> const char * stname = NULL;
> int i;
> + Parrot_Run_core_t runcore = PARROT_FAST_CORE;
>
> - if (argc < 2)
> - fail("no args");
> i = 1;
> +
> +options:
> + if (i >= argc)
> + fail("No file to load");
> +
> if (strcmp(argv[i], "--start") == 0) {
> ++i;
> if (i >= argc)
> fail("Option needs argument");
> stname = argv[i];
> ++i;
> + goto options;
> + }
> + if (strcmp(argv[i], "--runcore") == 0) {
> + ++i;
> + if (i >= argc)
> + fail("Option needs argument");
> + if (strcmp(argv[i], "slow") == 0)
> + runcore = PARROT_SLOW_CORE;
> + else if (strcmp(argv[i], "fast") == 0)
> + runcore = PARROT_FAST_CORE;
> + else if (strcmp(argv[i], "cgoto") == 0)
> + runcore = PARROT_CGOTO_CORE;
> + else if (strcmp(argv[i], "jit") == 0)
> + runcore = PARROT_JIT_CORE;
> + else if (strcmp(argv[i], "gcdebug") == 0)
> + runcore = PARROT_GC_DEBUG_CORE;
> + else
> + fail ("Invalid runcore");
> +
> + ++i;
> + goto options;
> }
> +
> + Parrot_set_run_core(interp, runcore);
> +
> source = argv[i];
>
> pf = Parrot_pbc_read(interp, source, 0);
> @@ -71,7 +99,7 @@
> discard = Parrot_call_sub(interp, start, "");
> }
> else {
> - Parrot_runcode(interp, argc - 1, argv + 1);
> + Parrot_runcode(interp, argc - i, argv + i);
> }
>
> return 0;
we have a STREQ macro for all this strcmp foolishness. is it available
to embedders, and if not, why not?
~jerry
More information about the parrot-dev
mailing list