On Mon, Sep 17, 2001 at 10:33:35AM -0400, Gregor N. Purdy wrote:
> as *word* counts not *byte* counts -- D'Oh!)
Isn't assembly programming fun? :)
> */
>
> static int
> -check_magic(void** program_code) {
> +check_magic(void** program_code, long* program_size) {
> + program_size -= sizeof(IV);
> return (GRAB_IV(program_code) == PARROT_MAGIC);
> }
And to think, just above that "*/" is a load of lovely documentation
you haven't touched...
> +#ifdef TRACE_OPS
> + fprintf(stderr, "PC=%ld; OP=%ld (%s)\n", code - code_start, *code,
>op_names[*code]);
> +#endif /* TRACE_OPS */
That's neat.
> +#ifdef TRACE_OPS
> + if (code >= code_start && code < (code_start + code_size)) {
> + fprintf(stderr, "PC=%ld; OP=%ld (%s)", code - code_start, *code,
>op_names[*code]);
> + if (op_args[*code]) {
> + fprintf(stderr, "; ARGS=(");
> + for(i = 0; i < op_args[*code]; i++) {
> + if (i) { fprintf(stderr, ", "); }
> + fprintf(stderr, "%ld", *(code + i + 1));
> + }
> + fprintf(stderr, ")");
> + }
> + fprintf(stderr, "\n");
> + } else {
> + fprintf(stderr, "PC=%ld; OP=<err>\n", code - code_start);
> + }
> +#endif /* TRACE_OPS */
That's less than neat, but I can't think of a better way to do it.
> + if (code < code_start || code >= (code_start + code_size)) {
> + fprintf(stderr, "Error: Control left bounds of byte-code block (now at
>location %d)!\n", code - code_start);
> + exit(1);
I don't like this check in every iteration.
Simon
--
Heh, heh, heh, heh... the NOISE of a bursar CHEWING Proctors' Memoranda.
- Henry Braun is Oxford Zippy