[svn:parrot] r37553 - in trunk: . lib/Parrot/Ops2pm src/ops t/op t/pmc
coke at svn.parrot.org
coke at svn.parrot.org
Wed Mar 18 19:48:56 UTC 2009
Author: coke
Date: Wed Mar 18 19:48:54 2009
New Revision: 37553
URL: https://trac.parrot.org/parrot/changeset/37553
Log:
Remove all experimental ops and their tests, except for C<trap>
Fixup the ops2pm code a bit to allow for when experimental.ops has no ops.
Modified:
trunk/DEPRECATED.pod
trunk/lib/Parrot/Ops2pm/Base.pm
trunk/src/ops/experimental.ops
trunk/t/op/arithmetics.t
trunk/t/op/string.t
trunk/t/pmc/parrotinterpreter.t
Modified: trunk/DEPRECATED.pod
==============================================================================
--- trunk/DEPRECATED.pod Wed Mar 18 19:41:12 2009 (r37552)
+++ trunk/DEPRECATED.pod Wed Mar 18 19:48:54 2009 (r37553)
@@ -81,7 +81,7 @@
=item experimental ops [eligible in 1.1]
-F<src/ops/experimental.ops>
+F<src/ops/experimental.ops> - only the C<trap> opcode remains
=item myops & dan ops [eligible in 1.1]
Modified: trunk/lib/Parrot/Ops2pm/Base.pm
==============================================================================
--- trunk/lib/Parrot/Ops2pm/Base.pm Wed Mar 18 19:41:12 2009 (r37552)
+++ trunk/lib/Parrot/Ops2pm/Base.pm Wed Mar 18 19:48:54 2009 (r37553)
@@ -148,10 +148,20 @@
my $temp_ops = Parrot::OpsFile->new( [$f], $self->{nolines} );
die "$self->{script}: Could not read ops file '$f'!\n"
unless defined $temp_ops;
- die "OPS invalid for $f" unless ref $temp_ops->{OPS};
my $experimental = $f =~ /experimental/;
+ if (! ref $temp_ops->{OPS}) {
+ my $message = "OPS invalid for $f";
+ if ($experimental) {
+ # empty experimental.ops file is OK.
+ warn $message;
+ next;
+ } else {
+ die $message;
+ }
+ }
+
# mark experimental ops
if ($experimental) {
for my $el ( @{ $temp_ops->{OPS} } ) {
Modified: trunk/src/ops/experimental.ops
==============================================================================
--- trunk/src/ops/experimental.ops Wed Mar 18 19:41:12 2009 (r37552)
+++ trunk/src/ops/experimental.ops Wed Mar 18 19:48:54 2009 (r37553)
@@ -26,167 +26,6 @@
###############################################################################
-=head2 Mathematical operations
-
-Implementations of various mathematical operations
-
-=over 4
-
-=cut
-
-########################################
-
-=item B<gcd>(out INT, in NUM, in NUM)
-
-Greatest Common divisor of $2 and $3.
-
-=item B<gcd>(out INT, out INT, out INT, in INT, in INT)
-
-Given $4 and $5, it calculates $1, $2 and $3 so that
-
-$1 = gcd($4, $5) = $2 * $4 + $3 * $5 (d = gcd(a, b) = x*a + y*b)
-
-=cut
-
-inline op gcd(out INT, in NUM, in NUM) :advanced_math :deprecated {
-
- FLOATVAL q = 0;
- FLOATVAL c = 0;
- FLOATVAL temp2 = fabs($2);
- FLOATVAL temp3 = fabs($3);
-
- while (!FLOAT_IS_ZERO(temp3)) {
- q = floor((FLOATVAL)temp2/temp3);
- c = temp2 - temp3*q;
- temp2 = temp3;
- temp3 = c;
- }
-
- $1 = (INTVAL)temp2;
-}
-
-inline op gcd(out INT, out INT, out INT, in INT, in INT) :advanced_math :deprecated {
- /* r0 = q1*r1 + r2 */
- INTVAL r0 = $4 < 0 ? -$4 : $4;
- INTVAL r1 = $5 < 0 ? -$5 : $5;
- INTVAL r2 = 0;
- INTVAL q1 = 0;
-
- INTVAL xkm1 = 1;
- INTVAL xk = 0;
- INTVAL xkp1 = 0;
-
- INTVAL ykm1 = 0;
- INTVAL yk = 1;
- INTVAL ykp1 = 0;
-
- INTVAL n = 1;
-
- INTVAL x;
- INTVAL y;
-
- while (1) {
- q1 = r0/r1;
- r2 = r0 - q1*r1;
- if (r2 == 0) {
- break;
- }
- r0 = r1;
- r1 = r2;
-
- xkp1 = q1*xk + xkm1;
- xkm1 = xk;
- xk = xkp1;
-
- ykp1 = q1*yk + ykm1;
- ykm1 = yk;
- yk = ykp1;
- }
- $1 = r1;
- $2 = (INTVAL)(xk * pow(-1, n));
- $3 = (INTVAL)(yk * pow(-1, n+1));
-
- x = $2 * $4;
- y = $3 * $5;
-
- /* correct the sign (can be wrong because we used abs($4) and abs($5) */
- if (x + y == r1) {
- /* no correction necessary */
- }
- else if (x + y == -r1) {
- $2 = -$2;
- $3 = -$3;
- }
- else if (x - y == r1) {
- $3 = -$3;
- }
- else if (-x + y == r1) {
- $2 = -$2;
- }
-}
-
-=back
-
-=cut
-
-###############################################################################
-
-=head2 Misc other ops
-
-=over 4
-
-=item B<exec>(in STR)
-
-Execute the passed-in command. Completely tosses the current process
-image and replaces it with the command. Doesn't exit (the program
-ends, after all), though it does throw an exception if something goes
-wrong.
-
-=cut
-
-inline op exec(in STR) :deprecated {
- Parrot_Exec_OS_Command(interp, $1);
-}
-
-
-=item B<classname>(out PMC, invar PMC)
-
-Get the class name for the class in $2 and put it in $1. Note that $1 will be
-a Key PMC that you can use with "new", for example.
-
-=cut
-
-op classname(out PMC, invar PMC) :object_base :deprecated {
- PMC *ns = Parrot_ns_get_name(interp,
- VTABLE_get_namespace(interp, $2));
- if (PMC_IS_NULL(ns) || VTABLE_elements(interp, ns) < 2) {
- opcode_t *handler = Parrot_ex_throw_from_op_args(interp, expr NEXT(),
- EXCEPTION_NO_CLASS,
- "Attempt to get class name of a non-class.");
- goto ADDRESS(handler);
- }
- else {
- PMC *key_tail, *key;
- STRING *tmp;
- int i, max;
-
- /* Need to turn list of strings into a key. Note that we are not
- including the first item in the array, since that is the HLL. */
- tmp = VTABLE_get_string_keyed_int(interp, ns, 1);
- $1 = key_tail = key_new_string(interp, tmp);
- max = VTABLE_elements(interp, ns);
- for (i = 2; i < max; i++)
- {
- tmp = VTABLE_get_string_keyed_int(interp, ns, i);
- key = key_new_string(interp, tmp);
- key_append(interp, key_tail, key);
- key_tail = key;
- }
- }
-}
-
-=back
-
=head2 More Experimental Ops
=over 4
@@ -212,64 +51,6 @@
#endif
}
-########################################
-
-=item B<need_finalize>(invar PMC)
-
-The ParrotObject $1 needs the __finalize method during GC.
-
-=cut
-
-op need_finalize(invar PMC) :deprecated {
- PMC* pmc = $1;
- if (PObj_is_object_TEST(pmc)) {
- PObj_get_FLAGS(pmc) |= PObj_need_finalize_FLAG;
- }
-}
-
-########################################
-
-=item B<runinterp>(invar PMC, in PMC)
-
-Invokes the PMC $2 using interp $1.
-
-=cut
-
-op runinterp(invar PMC, in PMC) :deprecated {
- Interp * const new_interp = (Interp *)VTABLE_get_pointer(interp, $1);
- opcode_t *pc;
- Interp_flags_SET(new_interp, PARROT_EXTERN_CODE_FLAG);
- pc = (opcode_t *)VTABLE_invoke(new_interp, $2, NULL);
- UNUSED(pc);
- Parrot_runops_fromc_args(new_interp, $2, "P");
-}
-
-########################################
-
-=item B<substr_r>(out STR, in STR, in INT, in INT)
-
-Make $1 refer to the given part of $2, basically like above, but it
-is reusing the given destination string and does not care if the
-source string is changed later. This I<is changed> includes
-also GC runs, which will move the referenced string. This also
-means that $1 has to be reset before any GC may happen.
-
-This opcode should really be just used to quickly refer to a substring of
-another part, e.g. for printing and is a temporary hack.
-
-B<Handle with care.>
-
-=cut
-
-inline op substr_r(out STR, in STR, in INT, in INT) :base_core :deprecated {
- STRING *dest = $1;
- if (!dest)
- dest = new_string_header(interp, 0);
- $1 = Parrot_str_substr(interp, $2, $3, $4, &dest, 1);
-}
-
-=back
-
=head1 COPYRIGHT
Copyright (C) 2001-2009, Parrot Foundation.
Modified: trunk/t/op/arithmetics.t
==============================================================================
--- trunk/t/op/arithmetics.t Wed Mar 18 19:41:12 2009 (r37552)
+++ trunk/t/op/arithmetics.t Wed Mar 18 19:48:54 2009 (r37553)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 30;
+use Parrot::Test tests => 23;
# test for GMP
use Parrot::Config;
@@ -533,249 +533,6 @@
ok 5
OUTPUT
-pasm_output_is( <<'CODE', <<OUTPUT, "gcd(int,int,int)" );
- set I0, 125
- set I1, 15
- gcd I2, I1, I0
- eq I2, 5, OK1
- print "not "
-OK1: print "ok 1\n"
- end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<'CODE', <<OUTPUT, "is gcd(int,int,int) transitive?" );
- set I0, 125
- set I1, 15
- gcd I2, I1, I0
-
- neg I0
- gcd I3, I1, I0
- eq I2, I3, OK1
- print I2
- print " not "
- print I3
-OK1: print "ok 1\n"
-
- neg I1
- gcd I3, I1, I0
- eq I2, I3, OK2
- print I2
- print " not "
- print I3
-OK2: print "ok 2\n"
-
- neg I0
- neg I1
- gcd I3, I1, I0
- eq I2, I3, OK3
- print I2
- print " not "
- print I3
-OK3: print "ok 3\n"
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<'CODE', <<OUTPUT, "gcd num (with whole numbers)" );
- set N0, 125.0
- set N1, 15.0
- gcd I0, N1, N0
- eq I0, 5, OK1
- print "not "
-OK1: print "ok 1\n"
- end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<'CODE', <<OUTPUT, "gcd num (2)" );
- set N0, 12.3
- set N1, 24.6
- gcd I0, N1, N0
- eq I0, 12, OK1
- print I0
- print " not "
-OK1: print "ok 1\n"
- end
-CODE
-ok 1
-OUTPUT
-
-pasm_output_is( <<'CODE', <<OUTPUT, "is gcd(int,num,num) transitive?" );
- set N0, 125
- set N1, 15
- gcd I2, N1, N0
-
- neg N0
- gcd I3, N1, N0
- eq I2, I3, OK1
- print I2
- print " not "
- print I3
-OK1: print "ok 1\n"
-
- neg N1
- gcd I3, N1, N0
- eq I2, I3, OK2
- print I2
- print " not "
- print I3
-OK2: print "ok 2\n"
-
- neg N0
- neg N1
- gcd I3, N1, N0
- eq I2, I3, OK3
- print I2
- print " not "
- print I3
-OK3: print "ok 3\n"
- end
-CODE
-ok 1
-ok 2
-ok 3
-OUTPUT
-
-pasm_output_is( <<'CODE', <<OUTPUT, "gcd - 5 args version" );
- set I3, +100
- set I4, +35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- set I3, +100
- set I4, -35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- set I3, -100
- set I4, -35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- set I3, -100
- set I4, +35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- set I4, +100
- set I3, +35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- set I4, +100
- set I3, -35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- set I4, -100
- set I3, -35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- set I4, -100
- set I3, +35
- gcd I0, I1, I2, I3, I4
- bsr output
-
- print "done\n"
- end
-
-output:
- #I5 = I1*I3 + I2*I4
- mul I5, I1, I3
- mul I6, I2, I4
- add I5, I6
-
- print I0
- print " = "
- print I5
- print " = "
- print I1
- print "*"
- print I3
- print " + "
- print I2
- print "*"
- print I4
- print "\n"
- ret
-CODE
-5 = 5 = -1*100 + 3*35
-5 = 5 = -1*100 + -3*-35
-5 = 5 = 1*-100 + -3*-35
-5 = 5 = 1*-100 + 3*35
-5 = 5 = 3*35 + -1*100
-5 = 5 = -3*-35 + -1*100
-5 = 5 = -3*-35 + 1*-100
-5 = 5 = 3*35 + 1*-100
-done
-OUTPUT
-
-pasm_output_is( <<'CODE', <<OUTPUT, "is gcd(int,int,int,int,int) transitive?" );
- set I0, 130
- set I1, -35
- gcd I7, I0, I1
-
- # +, +
- gcd I2, I3, I4, I0, I1
- mul I5, I3, I0
- mul I6, I4, I1
- add I5, I5, I6
- ne I2, I5, NOK1
- eq I2, I7, OK1
-NOK1:
- print " not "
-OK1: print "ok 1\n"
-
- # -, +
- neg I0
- gcd I2, I3, I4, I0, I1
- mul I5, I3, I0
- mul I6, I4, I1
- add I5, I5, I6
- ne I2, I5, NOK2
- eq I2, I7, OK2
-NOK2:
- print " not "
-OK2: print "ok 2\n"
-
- # -, -
- neg I1
- gcd I2, I3, I4, I0, I1
- mul I5, I3, I0
- mul I6, I4, I1
- add I5, I5, I6
- ne I2, I5, NOK3
- eq I2, I7, OK3
-NOK3:
- print " not "
-OK3: print "ok 3\n"
-
- # +, -
- neg I0
- gcd I2, I3, I4, I0, I1
- mul I5, I3, I0
- mul I6, I4, I1
- add I5, I5, I6
- ne I2, I5, NOK4
- eq I2, I7, OK4
-NOK4:
- print " not "
-OK4: print "ok 4\n"
- end
-CODE
-ok 1
-ok 2
-ok 3
-ok 4
-OUTPUT
-
SKIP: {
skip( 'No integer overflow for 32-bit INTVALs without GMP installed', 1 )
if $PConfig{intvalsize} == 4 && !$PConfig{gmp};
Modified: trunk/t/op/string.t
==============================================================================
--- trunk/t/op/string.t Wed Mar 18 19:41:12 2009 (r37552)
+++ trunk/t/op/string.t Wed Mar 18 19:48:54 2009 (r37553)
@@ -7,7 +7,7 @@
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 161;
+use Parrot::Test tests => 160;
use Parrot::Config;
=head1 NAME
@@ -2031,32 +2031,6 @@
OUTPUT
}
-pasm_output_is( <<'CODE', <<'OUTPUT', 'experimental opcode substr_r_s_s|sc_i|ic_i|ic' );
- set S4, "12345JAPH01"
- set I4, 5
- set I5, 4
- substr_r S5, S4, I4, I5
- print S5
- substr_r S5, S4, I4, 4
- print S5
- substr_r S5, S4, 5, I5
- print S5
- substr_r S5, S4, 5, 4
- print S5
- substr_r S5, "12345JAPH01", I4, I5
- print S5
- substr_r S5, "12345JAPH01", I4, 4
- print S5
- substr_r S5, "12345JAPH01", 5, I5
- print S5
- substr_r S5, "12345JAPH01", 5, 4
- print S5
- print "\n"
- end
-CODE
-JAPHJAPHJAPHJAPHJAPHJAPHJAPHJAPH
-OUTPUT
-
pasm_output_is( <<'CODE', <<'OUTPUT', 'assign' );
set S4, "JAPH\n"
assign S5, S4
Modified: trunk/t/pmc/parrotinterpreter.t
==============================================================================
--- trunk/t/pmc/parrotinterpreter.t Wed Mar 18 19:41:12 2009 (r37552)
+++ trunk/t/pmc/parrotinterpreter.t Wed Mar 18 19:48:54 2009 (r37553)
@@ -6,7 +6,7 @@
use warnings;
use lib qw( . lib ../lib ../../lib );
use Test::More;
-use Parrot::Test tests => 5;
+use Parrot::Test tests => 2;
=head1 NAME
@@ -32,68 +32,6 @@
ok 1
OUT
-pir_output_is( <<'CODE', <<'OUT', 'run passed code pmc in another interpreter' );
-.sub main :main
- $S0 = <<"PIR"
-.sub test :main
- print "Hello, world\\n"
-.end
-PIR
- # Compile it.
- $P0 = compreg "PIR"
- $P1 = $P0($S0)
- # Invoke in different interpreter.
- $P2 = new ['ParrotInterpreter']
- runinterp $P2, $P1
- print "survived\n"
-.end
-CODE
-Hello, world
-survived
-OUT
-
-pir_output_is( <<'CODE', <<'OUT', 'running passed code pmc in another interpreter' );
-.sub 'main' :main
- $S0 = <<'PIR'
- .sub 'main' :main
- say "help, i'm stuck inside an interpreter!"
- .end
-PIR
- $P0 = new ['ParrotInterpreter']
- $P1 = compreg 'PIR'
- $P2 = $P1($S0)
- runinterp $P0, $P2
- say "nobody cares."
- end
- .end
-CODE
-help, i'm stuck inside an interpreter!
-nobody cares.
-OUT
-
-pir_output_is( <<'CODE', <<'OUT', 'accessing PMCs from nested interp' );
-.sub 'main' :main
- $S0 = <<'PIR'
- .sub 'main' :main
- $P0 = get_global 'some_string'
- $P0 = 'Accessing globals from other interpreters.'
- .end
-PIR
- $P3 = new ['String']
- set_global 'some_string', $P3
-
- $P0 = new ['ParrotInterpreter']
- $P1 = compreg 'PIR'
- $P2 = $P1($S0)
- runinterp $P0, $P2
- $S1 = $P3
- say $S1
- end
- .end
-CODE
-Accessing globals from other interpreters.
-OUT
-
pir_output_is( <<'CODE', <<'OUT', 'setting HLL map dynamically' );
.HLL 'Perl6'
More information about the parrot-commits
mailing list