Author: chromatic
Date: Sun Mar 30 21:25:42 2008
New Revision: 26656
Modified:
trunk/compilers/bcg/include/bcg.h
trunk/compilers/bcg/src/bcg.c
trunk/compilers/bcg/src/bcg_logger.c
trunk/compilers/bcg/src/bcg_reg_alloc_vanilla.c
trunk/compilers/bcg/src/pmc/bcg.pmc
Log:
[BCG] Rescued this compiler; now it compiles.
Made PMCs use parrot/extend.h instead of parrot/parrot.h (RT #39043).
Removed several compiler warnings.
Half of the tests fail, but that means they all run and half pass. Progress.
Modified: trunk/compilers/bcg/include/bcg.h
==============================================================================
--- trunk/compilers/bcg/include/bcg.h (original)
+++ trunk/compilers/bcg/include/bcg.h Sun Mar 30 21:25:42 2008
@@ -15,7 +15,8 @@
case 0:
#define BCG_CATCH(excp) break; \
case excp:
-#define BCG_END_TRY } \
+#define BCG_END_TRY default: break; \
+ } \
} while (0)
#define BCG_EXCEPTION 1
Modified: trunk/compilers/bcg/src/bcg.c
==============================================================================
--- trunk/compilers/bcg/src/bcg.c (original)
+++ trunk/compilers/bcg/src/bcg.c Sun Mar 30 21:25:42 2008
@@ -302,12 +302,12 @@
curr_unit = bcg_info_current_unit(bcg_info);
curr_op = bcg_info_current_op(bcg_info);
- op_arg = bcg_hash_get(bcg_info, curr_unit->symbol_table, var_name);
- if (op_arg == NULL) {
- op_arg =
- bcg_op_arg_create(bcg_info, var_name, BCG_OP_ARG_VARIABLE,
+ op_arg = (bcg_op_arg *)bcg_hash_get(bcg_info, curr_unit->symbol_table,
var_name);
+
+ if (!op_arg)
+ op_arg = bcg_op_arg_create(bcg_info, var_name, BCG_OP_ARG_VARIABLE,
var_type);
- }
+
bcg_op_add_arg(bcg_info, curr_op, op_arg);
bcg_hash_put(bcg_info, curr_unit->symbol_table, var_name, op_arg);
}
Modified: trunk/compilers/bcg/src/bcg_logger.c
==============================================================================
--- trunk/compilers/bcg/src/bcg_logger.c (original)
+++ trunk/compilers/bcg/src/bcg_logger.c Sun Mar 30 21:25:42 2008
@@ -40,17 +40,17 @@
bcg_throw_exception(BCG_info * bcg_info,
const int code, const char *format, ...)
{
- char *message;
- va_list ap_list;
+ char *message = mem_allocate_n_zeroed_typed(MAX_MESSAGE_SIZE, char);
+ va_list ap_list;
- message = mem_sys_allocate_zeroed(sizeof (char) * MAX_MESSAGE_SIZE);
va_start(ap_list, format);
vsnprintf(message, MAX_MESSAGE_SIZE, format, ap_list);
va_end(ap_list);
- bcg_info->error_msg = message;
+ bcg_info->error_msg = message;
bcg_info->error_code = code;
+
BCG_THROW(bcg_info, code);
}
Modified: trunk/compilers/bcg/src/bcg_reg_alloc_vanilla.c
==============================================================================
--- trunk/compilers/bcg/src/bcg_reg_alloc_vanilla.c (original)
+++ trunk/compilers/bcg/src/bcg_reg_alloc_vanilla.c Sun Mar 30 21:25:42 2008
@@ -96,8 +96,9 @@
case 'S':
reg_count[3]++;
return reg_count[3] - 1;
+ default:
+ return -1;
}
- return -1;
}
/*
Modified: trunk/compilers/bcg/src/pmc/bcg.pmc
==============================================================================
--- trunk/compilers/bcg/src/pmc/bcg.pmc (original)
+++ trunk/compilers/bcg/src/pmc/bcg.pmc Sun Mar 30 21:25:42 2008
@@ -21,7 +21,7 @@
*/
#include <string.h>
-#include "parrot/parrot.h"
+#include "parrot/extend.h"
#include "bcg.h"
static INTVAL dynpmc_BCG;
@@ -31,9 +31,8 @@
void class_init()
{
- if (pass) {
+ if (pass)
dynpmc_BCG = Parrot_PMC_typenum(INTERP, "BCG");
- }
}
/*
@@ -47,11 +46,7 @@
*/
void init()
{
- BCG_info *bcg_info;
-
- PMC_struct_val(SELF) = NULL;
- bcg_info=BCG_create();
- PMC_struct_val(SELF) = bcg_info;
+ PMC_struct_val(SELF) = BCG_create();
}
/*
@@ -66,7 +61,7 @@
void destroy()
{
if (PMC_struct_val(SELF)) {
- BCG_destroy((BCG_info*) PMC_struct_val(SELF));
+ BCG_destroy((BCG_info *)PMC_struct_val(SELF));
PMC_struct_val(SELF) = NULL;
}
}
@@ -82,9 +77,8 @@
*/
METHOD startCodeGen()
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
BCG_start_code_gen(bcg_info);
}
@@ -104,9 +98,8 @@
*/
METHOD endCodeGen()
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
BCG_end_code_gen(bcg_info);
}
@@ -128,12 +121,11 @@
*/
METHOD startSub(STRING *subName, STRING *pragma)
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
char *name_str = string_to_cstring(INTERP, subName);
- char *pragma_str = string_to_cstring(INTERP, pragma).
+ char *pragma_str = string_to_cstring(INTERP, pragma);
BCG_start_sub(bcg_info, name_str, pragma_str);
string_cstring_free(name_str);
string_cstring_free(pragma_str);
@@ -155,9 +147,8 @@
*/
METHOD endSub()
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
BCG_end_sub(bcg_info);
}
@@ -177,9 +168,8 @@
*/
METHOD startCall(STRING *subName)
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
char *name_str = string_to_cstring(INTERP, subName);
BCG_start_call(bcg_info, name_str);
@@ -202,9 +192,8 @@
*/
METHOD endCall()
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
BCG_end_call(bcg_info);
}
@@ -225,9 +214,8 @@
*/
METHOD startOp(STRING *op)
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info*) PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
char *op_name = string_to_cstring(INTERP, op);
BCG_start_op(bcg_info, op_name);
@@ -250,9 +238,8 @@
*/
METHOD endOp()
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
BCG_end_op(bcg_info);
}
@@ -273,13 +260,10 @@
*/
METHOD val(STRING *value, STRING *type)
{
- BCG_info *bcg_info;
- char data_type;
- char *type_str = string_to_cstring(INTERP, type);
- char *val_str = string_to_cstring(INTERP, value);
-
- data_type = get_data_type_from_cstring(INTERP, type_str);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
+ char *type_str = string_to_cstring(INTERP, type);
+ char *val_str = string_to_cstring(INTERP, value);
+ char data_type = get_data_type_from_cstring(INTERP, type_str);
string_cstring_free(type_str);
@@ -307,13 +291,11 @@
*/
METHOD var(STRING *varName, STRING *type)
{
- BCG_info *bcg_info;
- char data_type;
- char *type_str = string_to_cstring(INTERP, type);
- char *name_str = string_to_cstring(INTERP, varName);
+ BCG_info *bcg_info = (BCG_info*) PMC_struct_val(SELF);
+ char *type_str = string_to_cstring(INTERP, type);
+ char *name_str = string_to_cstring(INTERP, varName);
+ char data_type = get_data_type_from_cstring(INTERP, type_str);
- data_type = get_data_type_from_cstring(INTERP, type_str);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
string_cstring_free(type_str);
BCG_TRY(bcg_info) {
@@ -340,10 +322,9 @@
*/
METHOD label(STRING *label)
{
- BCG_info *bcg_info;
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
char *label_str = string_to_cstring(INTERP, label);
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
BCG_TRY(bcg_info) {
BCG_label(bcg_info, label_str);
}
@@ -360,9 +341,7 @@
METHOD printPASM()
{
- BCG_info *bcg_info;
-
- bcg_info = (BCG_info*) PMC_struct_val(SELF);
+ BCG_info *bcg_info = (BCG_info *)PMC_struct_val(SELF);
BCG_print_pasm(bcg_info);
}
}
@@ -384,7 +363,6 @@
}
real_exception(interp, NULL, E_Exception, "Invalid data type.");
- return '\0';
}
/*
@@ -393,7 +371,7 @@
=head1 LICENSE
-Copyright (C) 2006, The Perl Foundation.
+Copyright (C) 2006-2008, The Perl Foundation.
This is free software; you may redistribute it and/or modify
it under the same terms as Parrot.