Front page | perl.cvs.parrot |
Postings from January 2009
[svn:parrot] r34892 - trunk/compilers/pirc/new
From:
kjs
Date:
January 3, 2009 09:01
Subject:
[svn:parrot] r34892 - trunk/compilers/pirc/new
Message ID:
20090103170144.44D94CB9FA@x12.develooper.com
Author: kjs
Date: Sat Jan 3 09:01:43 2009
New Revision: 34892
Modified:
trunk/compilers/pirc/new/bcgen.c
trunk/compilers/pirc/new/pircompunit.c
trunk/compilers/pirc/new/piremit.c
Log:
[pirc] .const "Integer" i = 42 now auto-boxes 42 in a HLL_map respecting Integer object in the constant table.
Modified: trunk/compilers/pirc/new/bcgen.c
==============================================================================
--- trunk/compilers/pirc/new/bcgen.c (original)
+++ trunk/compilers/pirc/new/bcgen.c Sat Jan 3 09:01:43 2009
@@ -203,6 +203,8 @@
return index;
}
+
+
/*
=item C<int
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Sat Jan 3 09:01:43 2009
@@ -1325,7 +1325,7 @@
/* type must be a Sub, and value must be a string, holding the name of a sub */
if (is_a_sub && value->type == STRING_VAL) {
/* create a symbol representing the constant */
- symbol *constsym = new_symbol(lexer, name, PMC_TYPE);
+ symbol *constsym = new_symbol(lexer, name, PMC_TYPE);
/* create a target from the symbol */
target *consttarg = target_from_symbol(lexer, constsym);
@@ -1336,18 +1336,37 @@
value->type = PMC_VAL; /* set type of constant node */
value->val.pval = value->val.sval;
+ /* generate set_p_pc instruction, which takes the just-generated
+ * consttarg variable as first operand, and the constant "value"
+ * as second; its type is PMC_VAL, which is processed further in
+ * piremit::emit_pbc_const_arg(), case PMC_VAL.
+ */
new_sub_instr(lexer, PARROT_OP_set_p_pc, "set_p_pc", 0);
push_operand(lexer, expr_from_target(lexer, consttarg));
push_operand(lexer, expr_from_const(lexer, value));
}
- /*
- else if (value->type == INT_VAL) {
+ else if (value->type == INT_VAL) {
STRING *intclassname = string_from_cstring(lexer->interp, "Integer", 7);
INTVAL is_an_int = VTABLE_isa(lexer->interp, constclass, intclassname);
if (is_an_int) {
+ symbol *constsym = new_symbol(lexer, name, PMC_TYPE);
+ target *consttarg = target_from_symbol(lexer, constsym);
+
+ PMC *intconst = pmc_new(lexer->interp,
+ Parrot_get_ctx_HLL_type(lexer->interp, enum_class_Integer));
+ int index = add_pmc_const(lexer->bc, intconst);
+ VTABLE_set_integer_native(lexer->interp, intconst, value->val.ival);
+
+ declare_local(lexer, PMC_TYPE, constsym);
+
+ value->name = name;
+
+ new_sub_instr(lexer, PARROT_OP_set_p_pc, "set_p_pc", 0);
+ push_operand(lexer, expr_from_target(lexer, consttarg));
+ push_operand(lexer, expr_from_int(lexer, index));
}
else {
@@ -1362,9 +1381,9 @@
else if (value->type == STRING_VAL) {
}
- */
+ fprintf(stderr, "done with new pmc const()\n");
return value;
}
Modified: trunk/compilers/pirc/new/piremit.c
==============================================================================
--- trunk/compilers/pirc/new/piremit.c (original)
+++ trunk/compilers/pirc/new/piremit.c Sat Jan 3 09:01:43 2009
@@ -464,8 +464,10 @@
*/
static void
emit_pbc_const_arg(lexer_state * const lexer, constant * const c) {
+ fprintf(stderr, "emit pbc const arg\n");
switch (c->type) {
case INT_VAL:
+ fprintf(stderr, "INTVAL\n");
emit_int_arg(lexer->bc, c->val.ival);
break;
case NUM_VAL: {
@@ -504,6 +506,7 @@
break;
}
default:
+ panic(lexer, "unknown constant type");
break;
}
}
@@ -699,6 +702,8 @@
}
}
+
+
/*
=item C<static void
-
[svn:parrot] r34892 - trunk/compilers/pirc/new
by kjs