From 7b6a72ae6d6801bb68317bf97b839750a54b20ba Mon Sep 17 00:00:00 2001 From: Jarrod Date: Sat, 24 Jul 2010 12:46:24 +1000 Subject: [PATCH] Fixes for the newer parrot. Doesn't correctly parse code due to nqp-rx incompatibilities - but it compiles!! --- src/builtins/builtins.pir | 4 ++-- src/builtins/io.pir | 4 ++-- src/builtins/math.pir | 22 ++++------------------ src/classes/Continuation.pir | 6 ++++-- src/classes/Stack.pir | 2 +- src/fun.pir | 6 +++++- src/ops/fun.ops | 2 +- src/pmc/char.pmc | 30 +++++++++--------------------- src/pmc/delayedsub.pmc | 8 ++++++-- src/pmc/list.pmc | 3 ++- 10 files changed, 36 insertions(+), 51 deletions(-) diff --git a/src/builtins/builtins.pir b/src/builtins/builtins.pir index 3b11168..7da9c6a 100644 --- a/src/builtins/builtins.pir +++ b/src/builtins/builtins.pir @@ -465,10 +465,10 @@ Reads a symbol from input and pushes it onto stack. Will only work for individua #Plz dont sue, guys :( lastchar = substr str, -1 if lastchar != "\n" goto done - chopn str, 1 + str = chopn str, 1 lastchar = substr str, -1 if lastchar != "\r" goto done - chopn str, 1 + str = chopn str, 1 done: $P0 = get_global str diff --git a/src/builtins/io.pir b/src/builtins/io.pir index dc13edc..7e8bf0e 100644 --- a/src/builtins/io.pir +++ b/src/builtins/io.pir @@ -77,10 +77,10 @@ Reads a line from stdin. Chomps the trailing newline. #Plz dont sue, guys :( lastchar = substr str, -1 if lastchar != "\n" goto done - chopn str, 1 + str = chopn str, 1 lastchar = substr str, -1 if lastchar != "\r" goto done - chopn str, 1 + str = chopn str, 1 done: .tailcall stack.'push'(str) .end diff --git a/src/builtins/math.pir b/src/builtins/math.pir index 5f9746b..44c6ac9 100644 --- a/src/builtins/math.pir +++ b/src/builtins/math.pir @@ -21,17 +21,7 @@ Pushes a random integer. Will seed the generator if it's not already seeded. .sub 'rand' .local pmc stack stack = get_hll_global ['private'], 'funstack' - - $P0 = get_hll_global ['Math'; 'Rand'], 'rand' - unless null $P0 goto ret_rand - load_bytecode 'library/Math/Rand.pbc' - $P0 = get_hll_global ['Math'; 'Rand'], 'srand' - $I0 = time - $P0($I0) - #Rand should now exist. - $P0 = get_hll_global ['Math'; 'Rand'], 'rand' -ret_rand: - $I0 = $P0 + $I0 = rand .tailcall stack.'push'($I0) .end @@ -44,17 +34,13 @@ Takes an integer to set the random generator seed. =cut .sub 'srand' - .local pmc stack, seed + .local pmc stack + .local int seed stack = get_hll_global ['private'], 'funstack' seed = stack.'pop'('Integer') - $P0 = get_hll_global ['private'], 'srand' - unless null $P0 goto set_rand - load_bytecode 'library/Math/Rand.pbc' - $P0 = get_hll_global ['Math'; 'Rand'], 'srand' -set_rand: - $P0(seed) + srand seed .end =item acos diff --git a/src/classes/Continuation.pir b/src/classes/Continuation.pir index a595eab..17b9faf 100644 --- a/src/classes/Continuation.pir +++ b/src/classes/Continuation.pir @@ -167,7 +167,9 @@ run_error: errstr = "Error in function '" errstr .= $S0 errstr .= "': " - printerr errstr + + $P0 = getstderr + print $P0, errstr exception['type'] = -1 error_exit: @@ -246,4 +248,4 @@ null_sub: die $S0 ignore_error: -.end \ No newline at end of file +.end diff --git a/src/classes/Stack.pir b/src/classes/Stack.pir index e3c2637..f2974e9 100644 --- a/src/classes/Stack.pir +++ b/src/classes/Stack.pir @@ -164,7 +164,7 @@ assign_stack: $P0 = getattribute self, 'topcc' $P0 = $P0.'getparent'() - if_null $P0, no_stack + if null $P0 goto no_stack setattribute self, 'topcc', $P0 .return() diff --git a/src/fun.pir b/src/fun.pir index 023c062..a5882d7 100644 --- a/src/fun.pir +++ b/src/fun.pir @@ -26,7 +26,11 @@ object. .loadlib 'fun_group' .loadlib 'fun_ops' - +.loadlib 'sys_ops' +.loadlib 'io_ops' +.loadlib 'math_ops' +.loadlib 'trans_ops' + .sub 'onload' :anon :load load_bytecode 'PCT.pbc' diff --git a/src/ops/fun.ops b/src/ops/fun.ops index 61b6e58..5c9d45e 100644 --- a/src/ops/fun.ops +++ b/src/ops/fun.ops @@ -3,7 +3,7 @@ #include "parrot/dynext.h" #include "../../../../src/pmc/pmc_object.h" -VERSION = PARROT_VERSION; +/*VERSION = PARROT_VERSION;*/ inline op frexp(out NUM, in NUM, out INT) :base_core { int exp; diff --git a/src/pmc/char.pmc b/src/pmc/char.pmc index 391105f..6b2da2f 100644 --- a/src/pmc/char.pmc +++ b/src/pmc/char.pmc @@ -2,6 +2,7 @@ pmclass Char need_ext + auto_attrs dynpmc group fun_group hll fun @@ -17,27 +18,6 @@ Class method to construct an Integer from the string representation C. =cut */ - VTABLE PMC *instantiate_str(STRING *rep, INTVAL flags) { - const INTVAL type = SELF->vtable->base_type; - PMC * const res = (flags & PObj_constant_FLAG) - ? constant_pmc_new(INTERP, type) - : pmc_new(INTERP, type); - - /* Parrot_str_to_int catches overflow automatically, so we don't need to - worry about it here. */ - VTABLE_set_integer_native(INTERP, res, string_ord(INTERP, rep, 0)); - return res; - } - - VTABLE void set_integer_same(PMC *value) { - /*SELF.set_integer_native(VTABLE_get_integer(INTERP, value));*/ - SET_ATTR_iv(INTERP, SELF, VTABLE_get_integer(INTERP, value)); - } - - - VTABLE void set_integer_native(INTVAL value) { - SET_ATTR_iv(INTERP, SELF, value); - } VTABLE STRING *get_string() { INTVAL iv; @@ -54,6 +34,14 @@ Class method to construct an Integer from the string representation C. VTABLE void set_string_native(STRING *value) { SET_ATTR_iv(INTERP, SELF, string_ord(INTERP, value, 0)); } + + VTABLE void set_number_native(FLOATVAL value) { + SET_ATTR_iv(INTERP, SELF, (INTVAL)value); + } + + VTABLE void set_bool(INTVAL value) { + SET_ATTR_iv(INTERP, SELF, value); + } } diff --git a/src/pmc/delayedsub.pmc b/src/pmc/delayedsub.pmc index 3f9b1d5..69facae 100644 --- a/src/pmc/delayedsub.pmc +++ b/src/pmc/delayedsub.pmc @@ -2,11 +2,16 @@ pmclass DelayedSub dynpmc + auto_attrs need_ext group fun_group extends String { +} + +/* + =item C B @@ -48,6 +53,5 @@ Throws an exception if the sub cannot be found. } return VTABLE_invoke(INTERP, dispatchsub, next); } +} */ - -} \ No newline at end of file diff --git a/src/pmc/list.pmc b/src/pmc/list.pmc index f077fca..a298f41 100644 --- a/src/pmc/list.pmc +++ b/src/pmc/list.pmc @@ -2,6 +2,7 @@ pmclass List need_ext + auto_attrs dynpmc group fun_group hll fun @@ -9,4 +10,4 @@ pmclass List provides array { -} \ No newline at end of file +}