cvsuser 04/03/19 03:09:20
Modified: lib/Parrot Op.pm OpsFile.pm
ops core.ops
Log:
OpsFile hints - 1
Revision Changes Path
1.14 +27 -1 parrot/lib/Parrot/Op.pm
Index: Op.pm
===================================================================
RCS file: /cvs/public/parrot/lib/Parrot/Op.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- Op.pm 15 Jan 2004 21:50:13 -0000 1.13
+++ Op.pm 19 Mar 2004 11:09:15 -0000 1.14
@@ -18,13 +18,15 @@
sub new
{
my $class = shift;
- my ($code, $type, $name, $args, $argdirs) = @_;
+ my ($code, $type, $name, $args, $argdirs, $labels, $flags) = @_;
my $self = { CODE => $code,
TYPE => $type,
NAME => $name,
ARGS => [ @$args ],
ARGDIRS => [ @$argdirs ],
+ LABELS => [ @$labels ],
+ FLAGS => $flags,
BODY => '',
JUMP => 0,
};
@@ -128,6 +130,30 @@
return @{$self->{ARGDIRS}};
}
+
+#
+# labels()
+#
+
+sub labels
+{
+ my $self = shift;
+ return @{$self->{LABELS}};
+}
+#
+#
+# flags()
+#
+
+sub flags
+{
+ my $self = shift;
+ if (@_) {
+ $self->{FLAGS} = shift;
+ }
+
+ return $self->{FLAGS};
+}
#
# arg_dir()
1.40 +22 -6 parrot/lib/Parrot/OpsFile.pm
Index: OpsFile.pm
===================================================================
RCS file: /cvs/public/parrot/lib/Parrot/OpsFile.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -w -r1.39 -r1.40
--- OpsFile.pm 24 Oct 2003 09:37:57 -0000 1.39
+++ OpsFile.pm 19 Mar 2004 11:09:15 -0000 1.40
@@ -99,6 +99,8 @@
my $seen_pod;
my $seen_op;
my $line;
+ my $flags;
+ my @labels;
while (<OPS>) {
$seen_pod = 1 if m|^=|;
@@ -159,7 +161,7 @@
# kc Key constant index
#
- if (/^(inline\s+)?op\s+([a-zA-Z]\w*)\s*\((.*)\)\s*{/) {
+ if (/^(inline\s+)?op\s+([a-zA-Z]\w*)\s*\((.*)\)\s*(\S*)?\s*{/) {
if ($seen_op) {
die "$ops_file [$.]: Cannot define an op within an op definition!\n";
}
@@ -167,8 +169,10 @@
$type = defined($1) ? 'inline' : 'function';
$short_name = lc $2;
$args = trim(lc $3);
+ $flags = $4 ? trim(lc $4) : "";
@args = split(/\s*,\s*/, $args);
@argdirs = ();
+ @labels = ();
$body = '';
$seen_op = 1;
$line = $.+1;
@@ -176,7 +180,10 @@
my @temp = ();
foreach my $arg (@args) {
- my ($use, $type) = $arg =~
m/^(in|out|inout|inconst|invar)\s+(INT|NUM|STR|PMC|KEY|INTKEY)$/i;
+ my ($use, $type) = $arg =~
+ m/^(in|out|inout|inconst|invar|label|labelconst|labelvar)
+ \s+
+ (INT|NUM|STR|PMC|KEY|INTKEY)$/ix;
die "Unrecognized arg format '$arg' in '$_'!" unless defined($use) and
defined($type);
@@ -186,6 +193,15 @@
else {
$type = lc substr($type, 0, 1);
}
+ # convert e.g. "labelvar" to "invar" and remember labels
+ if ($use =~ /label(\w*)/) {
+ push @labels, 1;
+ $use = "in$1";
+ }
+ else {
+ push @labels, 0;
+ }
+
if ($use eq 'in') {
push @temp, ($type eq 'p') ? 'p' : "$type|${type}c";
@@ -226,7 +242,7 @@
if (/^}\s*$/) {
$count += $self->make_op($count, $type, $short_name, $body, [EMAIL PROTECTED],
- [EMAIL PROTECTED], $line, $orig);
+ [EMAIL PROTECTED], $line, $orig, [EMAIL PROTECTED], $flags);
$seen_op = 0;
@@ -274,7 +290,7 @@
sub make_op
{
my ($self, $code, $type, $short_name, $body, $args, $argdirs,
- $line, $file) = @_;
+ $line, $file, $labels, $flags) = @_;
my $counter = 0;
my $absolute = 0;
my $branch = 0;
@@ -285,7 +301,7 @@
foreach my $variant (expand_args(@$args)) {
my(@fixedargs)=split(/,/,$variant);
my $op = Parrot::Op->new($code++, $type, $short_name,
- [ 'op', @fixedargs ], [ '', @$argdirs ]);
+ [ 'op', @fixedargs ], [ '', @$argdirs ], [0, @$labels], $flags);
my $op_size = $op->size;
my $jumps = "0";
1.353 +13 -13 parrot/ops/core.ops
Index: core.ops
===================================================================
RCS file: /cvs/public/parrot/ops/core.ops,v
retrieving revision 1.352
retrieving revision 1.353
diff -u -w -r1.352 -r1.353
--- core.ops 13 Mar 2004 08:43:18 -0000 1.352
+++ core.ops 19 Mar 2004 11:09:20 -0000 1.353
@@ -119,19 +119,19 @@
goto ADDRESS(next); /* force this being a branch op */
}
-inline op check_events__() {
+inline op check_events__() :internal {
opcode_t *this = CUR_OPCODE;
this = HANDLE_EVENTS(interpreter, this);
goto ADDRESS(this); /* force this being a branch op */
}
-inline op wrapper__() {
+inline op wrapper__() :internal {
opcode_t *pc = CUR_OPCODE;
DO_OP(pc, interpreter);
goto ADDRESS(pc);
}
-inline op prederef__() {
+inline op prederef__() :internal {
do_prederef((void**)cur_opcode, interpreter, op_lib.core_type);
goto OFFSET(0);
}
@@ -140,7 +140,7 @@
goto NEXT(); /* reserve 2 entries */
}
-inline op load_bytecode(in STR) {
+inline op load_bytecode(in STR) :load_file {
char * file = string_to_cstring(interpreter, $1);
Parrot_load_bytecode(interpreter, file);
string_cstring_free(file);
@@ -163,24 +163,24 @@
########################################
-=item B<branch>(in INT)
+=item B<branch>(label INT)
Branch forward or backward by the amount in $1.
=cut
-inline op branch (in INT) {
+inline op branch (label INT) :base_loop {
goto OFFSET($1);
}
-=item B<branch_cs>(in STR)
+=item B<branch_cs>(label STR)
Intersegment branch to location in fixup table named $1.
=cut
-inline op branch_cs (in STR) {
+inline op branch_cs (label STR) :base_loop,check_event {
char * label = string_to_cstring(interpreter, $1);
struct PackFile_FixupEntry *fe = PackFile_find_fixup_entry(interpreter,
enum_fixup_label, label);
@@ -204,7 +204,7 @@
=cut
-inline op bsr (in INT) {
+inline op bsr (label INT) :base_core,check_event {
stack_push(interpreter, &interpreter->ctx.control_stack, expr NEXT(),
STACK_ENTRY_DESTINATION, STACK_CLEANUP_NULL);
goto OFFSET($1);
}
@@ -222,14 +222,14 @@
########################################
-=item B<jsr>(in INT)
+=item B<jsr>(label INT)
Jump to the location specified by register $1. Push the current
location onto the call stack for later returning.
=cut
-inline op jsr(in INT) {
+inline op jsr(label INT) :base_core,check_event {
opcode_t * loc;
stack_push(interpreter, &interpreter->ctx.control_stack, expr NEXT(),
STACK_ENTRY_DESTINATION, STACK_CLEANUP_NULL);
loc = INTVAL2PTR(opcode_t *, $1);
@@ -239,13 +239,13 @@
########################################
-=item B<jump>(in INT)
+=item B<jump>(label INT)
Jump to the address held in register $1.
=cut
-inline op jump(in INT) {
+inline op jump(label INT) :base_loop {
opcode_t * loc;
loc = INTVAL2PTR(opcode_t *, $1);
goto ADDRESS(loc);