[svn:parrot] r44796 - in branches/ops_pct: . compilers/opsc config/gen/makefiles include/parrot lib/Parrot src/interp src/ops src/pmc src/runcore t/pmc t/src tools/dev
cotto at svn.parrot.org
cotto at svn.parrot.org
Tue Mar 9 07:06:21 UTC 2010
Author: cotto
Date: Tue Mar 9 07:06:18 2010
New Revision: 44796
URL: https://trac.parrot.org/parrot/changeset/44796
Log:
[opsc] sync branch with trunk
Modified:
branches/ops_pct/ (props changed)
branches/ops_pct/compilers/opsc/Defines.mak (props changed)
branches/ops_pct/compilers/opsc/Rules.mak (props changed)
branches/ops_pct/config/gen/makefiles/root.in
branches/ops_pct/include/parrot/runcore_trace.h (props changed)
branches/ops_pct/lib/Parrot/Op.pm
branches/ops_pct/src/interp/inter_create.c (props changed)
branches/ops_pct/src/ops/core_ops.c
branches/ops_pct/src/ops/var.ops
branches/ops_pct/src/pmc/complex.pmc
branches/ops_pct/src/pmc/os.pmc
branches/ops_pct/src/pmc/parrotthread.pmc
branches/ops_pct/src/runcore/cores.c (props changed)
branches/ops_pct/src/runcore/trace.c (props changed)
branches/ops_pct/t/pmc/complex.t
branches/ops_pct/t/src/embed.t (props changed)
branches/ops_pct/tools/dev/mk_gitignore.pl (props changed)
Modified: branches/ops_pct/config/gen/makefiles/root.in
==============================================================================
--- branches/ops_pct/config/gen/makefiles/root.in Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/config/gen/makefiles/root.in Tue Mar 9 07:06:18 2010 (r44796)
@@ -2238,7 +2238,7 @@
# +redef, +redecl: Ops currently have tons of redefinitions
# added to splint target to simplify experimentation,
-# ex: make SPLINTFLAGS_TEST='-posixstrictlib +posixlib' splint
+# example: make SPLINTFLAGS_TEST='-posixstrictlib +posixlib' splint
SPLINT_SOURCE = `echo $(O_FILES) | $(PERL) -pe @PQ at s/\.o/\.c/g at PQ@`
Modified: branches/ops_pct/lib/Parrot/Op.pm
==============================================================================
--- branches/ops_pct/lib/Parrot/Op.pm Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/lib/Parrot/Op.pm Tue Mar 9 07:06:18 2010 (r44796)
@@ -315,15 +315,12 @@
s/{{=0,=([^{]*?)}}/ $trans->restart_address($1) . "; {{=0}}"; /me;
s/{{=0,\+=([^{]*?)}}/ $trans->restart_offset($1) . "; {{=0}}"; /me;
- s/{{=0,-=([^{]*?)}}/ $trans->restart_offset(-$1) . "; {{=0}}"; /me;
s/{{\+=([^{]*?)}}/ $trans->goto_offset($1); /me;
- s/{{-=([^{]*?)}}/ $trans->goto_offset(-$1); /me;
s/{{=([^*][^{]*?)}}/ $trans->goto_address($1); /me;
- s/{{\^(-?\d+)}}/ $1 /me;
+ s/{{\^(\d+)}}/ $1 /me;
s/{{\^\+([^{]*?)}}/ $trans->expr_offset($1); /me;
- s/{{\^-([^{]*?)}}/ $trans->expr_offset(-$1); /me;
s/{{\^([^{]*?)}}/ $trans->expr_address($1); /me;
return $_;
Modified: branches/ops_pct/src/ops/core_ops.c
==============================================================================
--- branches/ops_pct/src/ops/core_ops.c Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/src/ops/core_ops.c Tue Mar 9 07:06:18 2010 (r44796)
@@ -30198,7 +30198,7 @@
opcode_t *
Parrot_find_sub_not_null_p_s (opcode_t *cur_opcode, PARROT_INTERP) {
Parrot_Context const * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-#line 476 "src/ops/var.ops"
+#line 481 "src/ops/var.ops"
opcode_t *dest = cur_opcode + 3;
PMC *sub = Parrot_find_name_op(interp, SREG(2), dest);
@@ -30216,7 +30216,7 @@
opcode_t *
Parrot_find_sub_not_null_p_sc (opcode_t *cur_opcode, PARROT_INTERP) {
Parrot_Context const * const CUR_CTX = Parrot_pcc_get_context_struct(interp, interp->ctx);
-#line 476 "src/ops/var.ops"
+#line 481 "src/ops/var.ops"
opcode_t *dest = cur_opcode + 3;
PMC *sub = Parrot_find_name_op(interp, CONST(2)->u.string, dest);
Modified: branches/ops_pct/src/ops/var.ops
==============================================================================
--- branches/ops_pct/src/ops/var.ops Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/src/ops/var.ops Tue Mar 9 07:06:18 2010 (r44796)
@@ -472,6 +472,11 @@
=item B<find_sub_not_null>(out PMC, in STR)
+Do the same thing as C<find_name>, but throw an exception if the name isn't
+found.
+
+=cut
+
inline op find_sub_not_null(out PMC, in STR) :base_core {
opcode_t *dest = expr NEXT();
PMC *sub = Parrot_find_name_op(interp, $2, dest);
Modified: branches/ops_pct/src/pmc/complex.pmc
==============================================================================
--- branches/ops_pct/src/pmc/complex.pmc Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/src/pmc/complex.pmc Tue Mar 9 07:06:18 2010 (r44796)
@@ -224,37 +224,6 @@
/*
-=item C<opcode_t *invoke(void *next)>
-
-Pythonic object constructor. SELF is a Complex Class object. Return a new
-C<complex> object according to 2.1. Built-in Functions.
-
-=cut
-
-*/
- VTABLE opcode_t *invoke(void *next) {
- const int argcP = REG_INT(interp, 3);
- PMC * const res = Parrot_pmc_new(INTERP, enum_class_Complex);
-
- if (argcP == 1) {
- PMC * const arg = REG_PMC(interp, 5);
-
- if (arg->vtable->base_type == enum_class_String)
- VTABLE_set_string_native(INTERP, res, VTABLE_get_string(interp, arg));
- else
- SET_ATTR_re(INTERP, res, VTABLE_get_number(INTERP, arg));
- }
- else if (argcP == 2) {
- SET_ATTR_re(INTERP, res, VTABLE_get_number(INTERP, REG_PMC(interp, 5)));
- SET_ATTR_im(INTERP, res, VTABLE_get_number(INTERP, REG_PMC(interp, 6)));
- }
-
- REG_PMC(interp, 5) = res;
- return (opcode_t *)next;
- }
-
-/*
-
=back
=head2 Methods
@@ -329,6 +298,42 @@
/*
+=item C<void freeze(PMC *visit)>
+
+=item C<void thaw(PMC *visit)>
+
+Serialize/deserialize this object for bytecode.
+
+=cut
+
+*/
+
+ VTABLE void freeze(PMC *visit) {
+ FLOATVAL re, im;
+
+ SUPER(visit);
+
+ GET_ATTR_re(INTERP, SELF, re);
+ VTABLE_push_float(INTERP, visit, re);
+
+ GET_ATTR_im(INTERP, SELF, im);
+ VTABLE_push_float(INTERP, visit, im);
+ }
+
+ VTABLE void thaw(PMC *visit) {
+ FLOATVAL re, im;
+
+ SUPER(visit);
+
+ re = VTABLE_shift_float(INTERP, visit);
+ SET_ATTR_re(INTERP, SELF, re);
+
+ im = VTABLE_shift_float(INTERP, visit);
+ SET_ATTR_im(INTERP, SELF, im);
+ }
+
+/*
+
=item C<INTVAL get_integer()>
Returns the modulus of the complex number as an integer.
Modified: branches/ops_pct/src/pmc/os.pmc
==============================================================================
--- branches/ops_pct/src/pmc/os.pmc Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/src/pmc/os.pmc Tue Mar 9 07:06:18 2010 (r44796)
@@ -22,6 +22,8 @@
#if defined(_MSC_VER)
# include <direct.h>
# include <io.h>
+# include <tchar.h>
+# include <windows.h>
#elif defined(__BORLANDC__)
# include <dir.h>
# include <dirent.h>
@@ -475,11 +477,11 @@
*/
METHOD readdir(STRING *path) {
+ PMC * array = Parrot_pmc_new(INTERP, enum_class_ResizableStringArray);
#ifndef _MSC_VER
char * const cpath = Parrot_str_to_cstring(INTERP, path);
DIR *dir = opendir(cpath);
struct dirent *dirent;
- PMC *array;
STRING *retval;
Parrot_str_free_cstring(cpath);
@@ -490,20 +492,43 @@
errmsg);
}
- array = Parrot_pmc_new(INTERP, enum_class_ResizableStringArray);
-
while ((dirent = readdir(dir)) != NULL) {
retval = Parrot_str_new(INTERP, dirent->d_name, 0) ;
VTABLE_push_string(INTERP, array, retval);
}
closedir(dir);
-
- RETURN(PMC *array);
#else
- Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_INTERNAL_NOT_IMPLEMENTED,
- "Win32 is not POSIX. Need Win32 developer!");
+ WIN32_FIND_DATA file_find_data;
+ char * cpath;
+ HANDLE hFind = INVALID_HANDLE_VALUE;
+
+ /* Add \* to the directory name and start search. */
+ cpath = Parrot_str_to_cstring(interp, Parrot_str_concat(interp,
+ path, string_from_literal(interp, "\\*"), 0));
+ hFind = FindFirstFile(cpath, &file_find_data);
+ Parrot_str_free_cstring(cpath);
+ if (hFind == INVALID_HANDLE_VALUE)
+ {
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_EXTERNAL_ERROR,
+ "Unable to readdir");
+ }
+
+ /* Loop over all directories and add to result array. */
+ do
+ {
+ VTABLE_push_string(INTERP, array, Parrot_str_new(INTERP,
+ file_find_data.cFileName, 0));
+ }
+ while (FindNextFile(hFind, &file_find_data) != 0);
+ if (GetLastError() != ERROR_NO_MORE_FILES)
+ {
+ Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_EXTERNAL_ERROR,
+ "Error during readdir");
+ }
+ FindClose(hFind);
#endif
+ RETURN(PMC *array);
}
/*
=item C<rename(STRING *oldpath, STRING *newpath)>
Modified: branches/ops_pct/src/pmc/parrotthread.pmc
==============================================================================
--- branches/ops_pct/src/pmc/parrotthread.pmc Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/src/pmc/parrotthread.pmc Tue Mar 9 07:06:18 2010 (r44796)
@@ -79,7 +79,7 @@
return tid;
}
-pmclass ParrotThread extends ParrotInterpreter no_ro {
+pmclass ParrotThread extends ParrotInterpreter no_ro manual_attrs {
/*
Modified: branches/ops_pct/t/pmc/complex.t
==============================================================================
--- branches/ops_pct/t/pmc/complex.t Tue Mar 9 06:59:31 2010 (r44795)
+++ branches/ops_pct/t/pmc/complex.t Tue Mar 9 07:06:18 2010 (r44796)
@@ -21,7 +21,7 @@
.include 'fp_equality.pasm'
.include "iglobals.pasm"
- plan(458)
+ plan(459)
string_parsing()
exception_malformed_string__real_part()
@@ -50,6 +50,7 @@
instantiate__pir__s()
test_complex_neg()
test_clone()
+ test_freeze_thaw()
test_sub()
test_i_sub()
sprintf_with_a_complex()
@@ -591,6 +592,14 @@
.fp_eq_ok($N1, -3.0, '... nor to imag portion')
.end
+.sub test_freeze_thaw
+ $P0 = new ['Complex']
+ set $P0, "1 - 3i"
+ $S0 = freeze $P0
+ $P1 = thaw $S0
+ is($P0, $P1, 'roundtrip serialize Complex PMC')
+.end
+
.sub test_sub
.local pmc d, f, c
d = new ['Undef']
More information about the parrot-commits
mailing list