Skip to content

Commit

Permalink
Fixes for the newer parrot. Doesn't correctly parse code due to nqp-r…
Browse files Browse the repository at this point in the history
…x incompatibilities - but it compiles!!
  • Loading branch information
Jarrod committed Jul 24, 2010
1 parent 3606e26 commit 7b6a72a
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/builtins/builtins.pir
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/builtins/io.pir
Expand Up @@ -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
Expand Down
22 changes: 4 additions & 18 deletions src/builtins/math.pir
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/classes/Continuation.pir
Expand Up @@ -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:
Expand Down Expand Up @@ -246,4 +248,4 @@ null_sub:
die $S0

ignore_error:
.end
.end
2 changes: 1 addition & 1 deletion src/classes/Stack.pir
Expand Up @@ -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()

Expand Down
6 changes: 5 additions & 1 deletion src/fun.pir
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion src/ops/fun.ops
Expand Up @@ -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;
Expand Down
30 changes: 9 additions & 21 deletions src/pmc/char.pmc
Expand Up @@ -2,6 +2,7 @@

pmclass Char
need_ext
auto_attrs
dynpmc
group fun_group
hll fun
Expand All @@ -17,27 +18,6 @@ Class method to construct an Integer from the string representation C<rep>.
=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;
Expand All @@ -54,6 +34,14 @@ Class method to construct an Integer from the string representation C<rep>.
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);
}


}
8 changes: 6 additions & 2 deletions src/pmc/delayedsub.pmc
Expand Up @@ -2,11 +2,16 @@

pmclass DelayedSub
dynpmc
auto_attrs
need_ext
group fun_group
extends String
{

}

/*

=item C<opcode_t* invoke(void* next)>

B<NOT USED AT THE MOMENT-- I DON'T KNOW ENOUGH ABOUT PARROT INTERNALS>
Expand Down Expand Up @@ -48,6 +53,5 @@ Throws an exception if the sub cannot be found.
}
return VTABLE_invoke(INTERP, dispatchsub, next);
}
}
*/

}
3 changes: 2 additions & 1 deletion src/pmc/list.pmc
Expand Up @@ -2,11 +2,12 @@

pmclass List
need_ext
auto_attrs
dynpmc
group fun_group
hll fun
extends ResizablePMCArray
provides array
{

}
}

0 comments on commit 7b6a72a

Please sign in to comment.