Author: paul.biggar
Date: Sat Jul 5 08:21:22 2008
New Revision: 1439
Modified:
trunk/src/ast_to_hir/AST_to_HIR.h
trunk/src/process_hir/HIR_to_AST.h
trunk/src/process_mir/MIR_to_AST.h
Log:
Re-organize *_to_* classes, primarily to make them easier to diff
against each other.
Modified: trunk/src/ast_to_hir/AST_to_HIR.h
==============================================================================
--- trunk/src/ast_to_hir/AST_to_HIR.h (original)
+++ trunk/src/ast_to_hir/AST_to_HIR.h Sat Jul 5 08:21:22 2008
@@ -106,7 +106,9 @@
HIR::Loop* // While*
>
{
+ HIR::Statement* eval_expr_assignment;
HIR::Reflection* reflection;
+
public:
AST_to_HIR ()
{
@@ -314,7 +316,6 @@
}
/* fold_impl_assignment sets eval_expr_assignment, which is returned
if EXPR is NULL */
- HIR::Statement* eval_expr_assignment;
HIR::Statement* fold_impl_eval_expr(AST::Eval_expr* orig, HIR::Expr* expr)
{
HIR::Statement* result;
Modified: trunk/src/process_hir/HIR_to_AST.h
==============================================================================
--- trunk/src/process_hir/HIR_to_AST.h (original)
+++ trunk/src/process_hir/HIR_to_AST.h Sat Jul 5 08:21:22 2008
@@ -289,62 +289,6 @@
return result;
}
- AST::Foreign_expr* fold_impl_foreign_expr(HIR::Foreign_expr* orig)
- {
- AST::Foreign_expr* result;
- result = new AST::Foreign_expr (orig->foreign);
- result->attrs = orig->attrs;
- return result;
- }
-
- AST::Foreign_statement* fold_impl_foreign_statement
(HIR::Foreign_statement* orig)
- {
- AST::Foreign_statement* result;
- result = new AST::Foreign_statement (orig->foreign);
- result->attrs = orig->attrs;
- return result;
- }
-
- AST::Break* fold_impl_break (HIR::Break* orig, AST::Expr* expr)
- {
- AST::Break* result;
- result = new AST::Break (expr);
- result->attrs = orig->attrs;
- return result;
- }
-
- AST::If* fold_impl_if(HIR::If* orig, AST::VARIABLE_NAME*
variable_name, List<AST::Statement*>* iftrue, List<AST::Statement*>* iffalse)
- {
- AST::If* result;
- result = new AST::If (wrap_var_name (variable_name), iftrue, iffalse);
- result->attrs = orig->attrs;
- return result;
- }
-
- AST::While* fold_impl_loop (HIR::Loop* orig, List<AST::Statement*>* statements)
- {
- AST::While* result;
- result = new AST::While(new AST::BOOL (true), statements);
- result->attrs = orig->attrs;
- return result;
- }
-
- AST::Foreach* fold_impl_foreach (HIR::Foreach* orig,
AST::VARIABLE_NAME* expr, AST::VARIABLE_NAME* key, bool is_ref,
AST::VARIABLE_NAME* val, List<AST::Statement*>* statements)
- {
- AST::Foreach* result;
- result = new AST::Foreach(wrap_var_name (expr), wrap_var_name (key),
is_ref, wrap_var_name (val), statements);
- result->attrs = orig->attrs;
- return result;
- }
-
- AST::Continue* fold_impl_continue(HIR::Continue* orig, AST::Expr* expr)
- {
- AST::Continue* result;
- result = new AST::Continue(expr);
- result->attrs = orig->attrs;
- return result;
- }
-
AST::Eval_expr* fold_impl_assign_var (HIR::Assign_var* orig,
AST::VARIABLE_NAME* lhs, bool is_ref, AST::Expr* rhs)
{
AST::Assignment* result;
@@ -707,6 +651,64 @@
return result;
}
+ /* Foreign nodes */
+ AST::Foreign_statement*
fold_impl_foreign_statement(HIR::Foreign_statement* orig)
+ {
+ AST::Foreign_statement* result;
+ result = new AST::Foreign_statement (orig->foreign);
+ result->attrs = orig->attrs;
+ return result;
+ }
+
+ AST::Foreign_expr* fold_impl_foreign_expr(HIR::Foreign_expr* orig)
+ {
+ AST::Foreign_expr* result;
+ result = new AST::Foreign_expr (orig->foreign);
+ result->attrs = orig->attrs;
+ return result;
+ }
+
+ /* HIR types not in the MIR */
+
+ AST::Break* fold_impl_break (HIR::Break* orig, AST::Expr* expr)
+ {
+ AST::Break* result;
+ result = new AST::Break (expr);
+ result->attrs = orig->attrs;
+ return result;
+ }
+
+ AST::If* fold_impl_if(HIR::If* orig, AST::VARIABLE_NAME*
variable_name, List<AST::Statement*>* iftrue, List<AST::Statement*>* iffalse)
+ {
+ AST::If* result;
+ result = new AST::If (wrap_var_name (variable_name), iftrue, iffalse);
+ result->attrs = orig->attrs;
+ return result;
+ }
+
+ AST::While* fold_impl_loop (HIR::Loop* orig, List<AST::Statement*>* statements)
+ {
+ AST::While* result;
+ result = new AST::While(new AST::BOOL (true), statements);
+ result->attrs = orig->attrs;
+ return result;
+ }
+
+ AST::Foreach* fold_impl_foreach (HIR::Foreach* orig,
AST::VARIABLE_NAME* expr, AST::VARIABLE_NAME* key, bool is_ref,
AST::VARIABLE_NAME* val, List<AST::Statement*>* statements)
+ {
+ AST::Foreach* result;
+ result = new AST::Foreach(wrap_var_name (expr), wrap_var_name (key),
is_ref, wrap_var_name (val), statements);
+ result->attrs = orig->attrs;
+ return result;
+ }
+
+ AST::Continue* fold_impl_continue(HIR::Continue* orig, AST::Expr* expr)
+ {
+ AST::Continue* result;
+ result = new AST::Continue(expr);
+ result->attrs = orig->attrs;
+ return result;
+ }
~HIR_to_AST () {}
};
Modified: trunk/src/process_mir/MIR_to_AST.h
==============================================================================
--- trunk/src/process_mir/MIR_to_AST.h (original)
+++ trunk/src/process_mir/MIR_to_AST.h Sat Jul 5 08:21:22 2008
@@ -297,73 +297,6 @@
return result;
}
- AST::Statement* fold_impl_foreign_statement(MIR::Foreign_statement* orig)
- {
- AST::Statement* result;
- result = dynamic_cast<AST::Statement*> (orig->foreign);
- assert (result);
- return result;
- }
-
-
- AST::Foreign_statement* fold_impl_branch(MIR::Branch* orig,
AST::VARIABLE_NAME* variable_name, AST::Identifier* iftrue,
AST::Identifier* iffalse)
- {
- return new AST::Foreign_statement (orig);
- }
-
- AST::Foreign_statement* fold_impl_goto(MIR::Goto* orig,
AST::Identifier* label_name)
- {
- return new AST::Foreign_statement (orig);
- }
-
- AST::Foreign_statement* fold_impl_label(MIR::Label* orig,
AST::Identifier* label_name)
- {
- return new AST::Foreign_statement (orig);
- }
-
- AST::Identifier* fold_label_name(MIR::LABEL_NAME* orig)
- {
- // do nothing. LABEL_NAMEs are always wrapped, but there will be an
- // attempt to fold them, so we need to supply a definition so that it
- // doesnt fail.
- return NULL;
- }
-
- AST::Foreign_statement* fold_impl_foreach_reset (MIR::Foreach_reset*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
- {
- return new AST::Foreign_statement (orig);
- }
-
- AST::Foreign_statement* fold_impl_foreach_next (MIR::Foreach_next*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
- {
- return new AST::Foreign_statement (orig);
- }
-
- AST::Foreign_statement* fold_impl_foreach_end (MIR::Foreach_end*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
- {
- return new AST::Foreign_statement (orig);
- }
-
- AST::Foreign_expr* fold_impl_foreach_has_key (MIR::Foreach_has_key*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
- {
- return new AST::Foreign_expr (orig);
- }
-
- AST::Foreign_expr* fold_impl_foreach_get_key (MIR::Foreach_get_key*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
- {
- return new AST::Foreign_expr (orig);
- }
-
- AST::Foreign_expr* fold_impl_foreach_get_val (MIR::Foreach_get_val*
orig, AST::VARIABLE_NAME* array, AST::VARIABLE_NAME* key,
AST::Identifier* iter)
- {
- return new AST::Foreign_expr (orig);
- }
-
- AST::Identifier* fold_ht_iterator (MIR::HT_ITERATOR* orig)
- {
- foreign_expr = new AST::Foreign_expr (orig);
- return NULL;
- }
AST::Eval_expr* fold_impl_assign_var (MIR::Assign_var* orig,
AST::VARIABLE_NAME* lhs, bool is_ref, AST::Expr* rhs)
{
@@ -741,6 +674,85 @@
result->attrs = orig->attrs;
return result;
}
+
+ /* Foreign nodes */
+ AST::Statement* fold_impl_foreign_statement(MIR::Foreign_statement* orig)
+ {
+ AST::Statement* result;
+ result = dynamic_cast<AST::Statement*> (orig->foreign);
+ assert (result);
+ return result;
+ }
+
+ AST::Foreign_expr* fold_impl_foreign_expr(MIR::Foreign_expr* orig)
+ {
+ AST::Foreign_expr* result;
+ result = new AST::Foreign_expr (orig->foreign);
+ result->attrs = orig->attrs;
+ return result;
+ }
+
+ /* MIR types without an AST equivalent. */
+
+ AST::Foreign_statement* fold_impl_branch(MIR::Branch* orig,
AST::VARIABLE_NAME* variable_name, AST::Identifier* iftrue,
AST::Identifier* iffalse)
+ {
+ return new AST::Foreign_statement (orig);
+ }
+
+ AST::Foreign_statement* fold_impl_goto(MIR::Goto* orig,
AST::Identifier* label_name)
+ {
+ return new AST::Foreign_statement (orig);
+ }
+
+ AST::Foreign_statement* fold_impl_label(MIR::Label* orig,
AST::Identifier* label_name)
+ {
+ return new AST::Foreign_statement (orig);
+ }
+
+ AST::Identifier* fold_label_name(MIR::LABEL_NAME* orig)
+ {
+ // do nothing. LABEL_NAMEs are always wrapped, but there will be an
+ // attempt to fold them, so we need to supply a definition so that it
+ // doesnt fail.
+ return NULL;
+ }
+
+ AST::Foreign_statement* fold_impl_foreach_reset (MIR::Foreach_reset*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
+ {
+ return new AST::Foreign_statement (orig);
+ }
+
+ AST::Foreign_statement* fold_impl_foreach_next (MIR::Foreach_next*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
+ {
+ return new AST::Foreign_statement (orig);
+ }
+
+ AST::Foreign_statement* fold_impl_foreach_end (MIR::Foreach_end*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
+ {
+ return new AST::Foreign_statement (orig);
+ }
+
+ AST::Foreign_expr* fold_impl_foreach_has_key (MIR::Foreach_has_key*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
+ {
+ return new AST::Foreign_expr (orig);
+ }
+
+ AST::Foreign_expr* fold_impl_foreach_get_key (MIR::Foreach_get_key*
orig, AST::VARIABLE_NAME* array, AST::Identifier* iter)
+ {
+ return new AST::Foreign_expr (orig);
+ }
+
+ AST::Foreign_expr* fold_impl_foreach_get_val (MIR::Foreach_get_val*
orig, AST::VARIABLE_NAME* array, AST::VARIABLE_NAME* key,
AST::Identifier* iter)
+ {
+ return new AST::Foreign_expr (orig);
+ }
+
+ AST::Identifier* fold_ht_iterator (MIR::HT_ITERATOR* orig)
+ {
+ foreign_expr = new AST::Foreign_expr (orig);
+ return NULL;
+ }
+
~MIR_to_AST () {}
};