Author: kjs
Date: Fri Jan 2 06:17:27 2009
New Revision: 34807
Modified:
trunk/compilers/pirc/new/pir.y
trunk/compilers/pirc/new/pircompunit.c
trunk/compilers/pirc/new/pircompunit.h
trunk/compilers/pirc/new/pirparser.c
Log:
[pirc] refactoring and add a stub for annotations.
Modified: trunk/compilers/pirc/new/pir.y
==============================================================================
--- trunk/compilers/pirc/new/pir.y (original)
+++ trunk/compilers/pirc/new/pir.y Fri Jan 2 06:17:27 2009
@@ -656,7 +656,7 @@
;
annotation : ".annotate" TK_STRINGC ',' TK_STRINGC
- { /* XXX */ }
+ { annotate(lexer, $2, $4); }
;
/* HLL stuff */
@@ -3461,8 +3461,6 @@
iter = iter->next;
do {
int keylength = get_signature_length(iter);
- /* printf("keylength of operand was: %d\n", keylength);
- */
fullname_length += keylength;
iter = iter->next;
++num_operands;
@@ -3575,9 +3573,11 @@
symbol *sym = find_symbol(lexer, operand->expr.id);
if (sym) {
- operand->expr.t = new_target(lexer);
- /* operand->expr.t->s.sym = sym; */ /* target's pointer set
to symbol */
+ operand->expr.t = target_from_symbol(lexer, sym);
+ /*
+ operand->expr.t = new_target(lexer);
operand->expr.t->info = &sym->info;
+ */
operand->type = EXPR_TARGET; /* convert operand node
into EXPR_TARGET */
}
else { /* it must be a label */
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Fri Jan 2 06:17:27 2009
@@ -2302,6 +2302,21 @@
CURRENT_SUB(lexer)->info.regs_used[i] = reg_usage[i];
}
+/*
+
+=item C<void
+annotate(lexer_state * const lexer, char const * const key, char const * const
value)>
+
+Add a new annotation with key C<key> and value C<value>.
+
+=cut
+
+*/
+void
+annotate(lexer_state * const lexer, char const * const key, char const * const
value) {
+ /* XXX todo */
+}
+
/*
Modified: trunk/compilers/pirc/new/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.h (original)
+++ trunk/compilers/pirc/new/pircompunit.h Fri Jan 2 06:17:27 2009
@@ -463,6 +463,8 @@
void new_sub_instr(struct lexer_state * const lexer, int opcode, char const *
const opname,
unsigned num_var_args);
+void annotate(struct lexer_state * const lexer, char const * const key, char
const * const value);
+
#endif /* PARROT_PIR_PIRCOMPUNIT_H_GUARD */
/*
Modified: trunk/compilers/pirc/new/pirparser.c
==============================================================================
--- trunk/compilers/pirc/new/pirparser.c (original)
+++ trunk/compilers/pirc/new/pirparser.c Fri Jan 2 06:17:27 2009
@@ -2663,7 +2663,7 @@
case 40:
#line 659 "pir.y"
- { /* XXX */ ;}
+ { annotate(lexer, (yyvsp[(2) - (4)].sval), (yyvsp[(4) - (4)].sval)); ;}
break;
case 41:
@@ -6049,7 +6049,7 @@
case EXPR_KEY: { /* for '_', 'k' */
int n;
/* if the key is an integer constant, then signature becomes
'_kic', otherwise _kc. */
- if (e->expr.k->head->expr->type == EXPR_CONSTANT
+ if (e->expr.k->head->expr->type == EXPR_CONSTANT
&& e->expr.k->head->expr->expr.c->type == INT_TYPE)
n = 3;
else
@@ -6203,8 +6203,6 @@
iter = iter->next;
do {
int keylength = get_signature_length(iter);
- /* printf("keylength of operand was: %d\n", keylength);
- */
fullname_length += keylength;
iter = iter->next;
++num_operands;
@@ -6317,9 +6315,11 @@
symbol *sym = find_symbol(lexer, operand->expr.id);
if (sym) {
- operand->expr.t = new_target(lexer);
- /* operand->expr.t->s.sym = sym; */ /* target's pointer set
to symbol */
+ operand->expr.t = target_from_symbol(lexer, sym);
+ /*
+ operand->expr.t = new_target(lexer);
operand->expr.t->info = &sym->info;
+ */
operand->type = EXPR_TARGET; /* convert operand node
into EXPR_TARGET */
}
else { /* it must be a label */