summaryrefslogtreecommitdiff
path: root/src/mem/slicc/ast
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/slicc/ast')
-rw-r--r--src/mem/slicc/ast/AST.cc39
-rw-r--r--src/mem/slicc/ast/AST.hh94
-rw-r--r--src/mem/slicc/ast/ASTs.hh90
-rw-r--r--src/mem/slicc/ast/ActionDeclAST.cc96
-rw-r--r--src/mem/slicc/ast/ActionDeclAST.hh85
-rw-r--r--src/mem/slicc/ast/AssignStatementAST.cc76
-rw-r--r--src/mem/slicc/ast/AssignStatementAST.hh85
-rw-r--r--src/mem/slicc/ast/CheckAllocateStatementAST.cc72
-rw-r--r--src/mem/slicc/ast/CheckAllocateStatementAST.hh82
-rw-r--r--src/mem/slicc/ast/CheckStopSlotsStatementAST.cc115
-rw-r--r--src/mem/slicc/ast/CheckStopSlotsStatementAST.hh85
-rw-r--r--src/mem/slicc/ast/ChipComponentAccessAST.cc244
-rw-r--r--src/mem/slicc/ast/ChipComponentAccessAST.hh101
-rw-r--r--src/mem/slicc/ast/CopyHeadStatementAST.cc85
-rw-r--r--src/mem/slicc/ast/CopyHeadStatementAST.hh87
-rw-r--r--src/mem/slicc/ast/DeclAST.cc39
-rw-r--r--src/mem/slicc/ast/DeclAST.hh85
-rw-r--r--src/mem/slicc/ast/DeclListAST.cc86
-rw-r--r--src/mem/slicc/ast/DeclListAST.hh84
-rw-r--r--src/mem/slicc/ast/EnqueueStatementAST.cc104
-rw-r--r--src/mem/slicc/ast/EnqueueStatementAST.hh93
-rw-r--r--src/mem/slicc/ast/EnumDeclAST.cc98
-rw-r--r--src/mem/slicc/ast/EnumDeclAST.hh86
-rw-r--r--src/mem/slicc/ast/EnumExprAST.cc76
-rw-r--r--src/mem/slicc/ast/EnumExprAST.hh85
-rw-r--r--src/mem/slicc/ast/ExprAST.cc39
-rw-r--r--src/mem/slicc/ast/ExprAST.hh84
-rw-r--r--src/mem/slicc/ast/ExprStatementAST.cc73
-rw-r--r--src/mem/slicc/ast/ExprStatementAST.hh83
-rw-r--r--src/mem/slicc/ast/FormalParamAST.cc61
-rw-r--r--src/mem/slicc/ast/FormalParamAST.hh84
-rw-r--r--src/mem/slicc/ast/FuncCallExprAST.cc224
-rw-r--r--src/mem/slicc/ast/FuncCallExprAST.hh89
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.cc111
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.hh90
-rw-r--r--src/mem/slicc/ast/IfStatementAST.cc98
-rw-r--r--src/mem/slicc/ast/IfStatementAST.hh89
-rw-r--r--src/mem/slicc/ast/InPortDeclAST.cc149
-rw-r--r--src/mem/slicc/ast/InPortDeclAST.hh91
-rw-r--r--src/mem/slicc/ast/InfixOperatorExprAST.cc121
-rw-r--r--src/mem/slicc/ast/InfixOperatorExprAST.hh85
-rw-r--r--src/mem/slicc/ast/LiteralExprAST.cc55
-rw-r--r--src/mem/slicc/ast/LiteralExprAST.hh83
-rw-r--r--src/mem/slicc/ast/Location.cc83
-rw-r--r--src/mem/slicc/ast/Location.hh93
-rw-r--r--src/mem/slicc/ast/MachineAST.cc96
-rw-r--r--src/mem/slicc/ast/MachineAST.hh88
-rw-r--r--src/mem/slicc/ast/MemberExprAST.cc72
-rw-r--r--src/mem/slicc/ast/MemberExprAST.hh83
-rw-r--r--src/mem/slicc/ast/MethodCallExprAST.cc150
-rw-r--r--src/mem/slicc/ast/MethodCallExprAST.hh93
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.cc148
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.hh86
-rw-r--r--src/mem/slicc/ast/OutPortDeclAST.cc79
-rw-r--r--src/mem/slicc/ast/OutPortDeclAST.hh89
-rw-r--r--src/mem/slicc/ast/PairAST.cc72
-rw-r--r--src/mem/slicc/ast/PairAST.hh86
-rw-r--r--src/mem/slicc/ast/PairListAST.cc49
-rw-r--r--src/mem/slicc/ast/PairListAST.hh82
-rw-r--r--src/mem/slicc/ast/PeekStatementAST.cc115
-rw-r--r--src/mem/slicc/ast/PeekStatementAST.hh91
-rw-r--r--src/mem/slicc/ast/ReturnStatementAST.cc79
-rw-r--r--src/mem/slicc/ast/ReturnStatementAST.hh83
-rw-r--r--src/mem/slicc/ast/StatementAST.cc60
-rw-r--r--src/mem/slicc/ast/StatementAST.hh88
-rw-r--r--src/mem/slicc/ast/StatementListAST.cc86
-rw-r--r--src/mem/slicc/ast/StatementListAST.hh85
-rw-r--r--src/mem/slicc/ast/TransitionDeclAST.cc89
-rw-r--r--src/mem/slicc/ast/TransitionDeclAST.hh89
-rw-r--r--src/mem/slicc/ast/TypeAST.cc67
-rw-r--r--src/mem/slicc/ast/TypeAST.hh83
-rw-r--r--src/mem/slicc/ast/TypeDeclAST.cc86
-rw-r--r--src/mem/slicc/ast/TypeDeclAST.hh86
-rw-r--r--src/mem/slicc/ast/TypeFieldAST.cc44
-rw-r--r--src/mem/slicc/ast/TypeFieldAST.hh83
-rw-r--r--src/mem/slicc/ast/TypeFieldEnumAST.cc82
-rw-r--r--src/mem/slicc/ast/TypeFieldEnumAST.hh86
-rw-r--r--src/mem/slicc/ast/TypeFieldMemberAST.cc84
-rw-r--r--src/mem/slicc/ast/TypeFieldMemberAST.hh91
-rw-r--r--src/mem/slicc/ast/TypeFieldMethodAST.cc81
-rw-r--r--src/mem/slicc/ast/TypeFieldMethodAST.hh87
-rw-r--r--src/mem/slicc/ast/VarExprAST.cc76
-rw-r--r--src/mem/slicc/ast/VarExprAST.hh86
83 files changed, 7417 insertions, 0 deletions
diff --git a/src/mem/slicc/ast/AST.cc b/src/mem/slicc/ast/AST.cc
new file mode 100644
index 000000000..9342cd2e8
--- /dev/null
+++ b/src/mem/slicc/ast/AST.cc
@@ -0,0 +1,39 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * AST.C
+ *
+ * Description: See AST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "AST.hh"
diff --git a/src/mem/slicc/ast/AST.hh b/src/mem/slicc/ast/AST.hh
new file mode 100644
index 000000000..b20bbebe2
--- /dev/null
+++ b/src/mem/slicc/ast/AST.hh
@@ -0,0 +1,94 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * AST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef AST_H
+#define AST_H
+
+#include "slicc_global.hh"
+#include "Vector.hh"
+#include "Map.hh"
+#include "Location.hh"
+#include "SymbolTable.hh"
+
+class AST {
+public:
+ // Constructors
+ AST(Map<string, string> pairs) { m_pairs = pairs; };
+ AST() {};
+
+ // Destructor
+ virtual ~AST() {};
+
+ // Public Methods
+ virtual void print(ostream& out) const = 0;
+ void error(string err_msg) const { m_location.error(err_msg); };
+ string embedError(string err_msg) const { return m_location.embedError(err_msg); };
+ void warning(string err_msg) const { m_location.warning(err_msg); };
+
+ const Location& getLocation() const { return m_location; };
+
+ const Map<string, string>& getPairs() const { return m_pairs; };
+ Map<string, string>& getPairs() { return m_pairs; };
+
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ // AST(const AST& obj);
+ // AST& operator=(const AST& obj);
+
+ // Data Members (m_ prefix)
+ Location m_location;
+ Map<string, string> m_pairs;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const AST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const AST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //AST_H
diff --git a/src/mem/slicc/ast/ASTs.hh b/src/mem/slicc/ast/ASTs.hh
new file mode 100644
index 000000000..77b055a80
--- /dev/null
+++ b/src/mem/slicc/ast/ASTs.hh
@@ -0,0 +1,90 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#ifndef ASTs_H
+#define ASTs_H
+
+#include "slicc_global.hh"
+#include "main.hh"
+#include "StateMachine.hh"
+#include "AST.hh"
+
+#include "MachineAST.hh"
+
+#include "TypeAST.hh"
+#include "FormalParamAST.hh"
+
+#include "DeclListAST.hh"
+#include "DeclAST.hh"
+#include "ActionDeclAST.hh"
+#include "InPortDeclAST.hh"
+#include "OutPortDeclAST.hh"
+#include "TransitionDeclAST.hh"
+#include "EnumDeclAST.hh"
+#include "TypeDeclAST.hh"
+#include "ObjDeclAST.hh"
+#include "FuncDeclAST.hh"
+
+#include "TypeFieldAST.hh"
+#include "TypeFieldMethodAST.hh"
+#include "TypeFieldMemberAST.hh"
+#include "TypeFieldEnumAST.hh"
+
+#include "PairAST.hh"
+#include "PairListAST.hh"
+
+#include "ExprAST.hh"
+#include "VarExprAST.hh"
+#include "EnumExprAST.hh"
+#include "LiteralExprAST.hh"
+#include "MemberExprAST.hh"
+#include "InfixOperatorExprAST.hh"
+#include "FuncCallExprAST.hh"
+#include "MethodCallExprAST.hh"
+
+#include "ChipComponentAccessAST.hh"
+
+#include "StatementListAST.hh"
+#include "StatementAST.hh"
+#include "ExprStatementAST.hh"
+#include "AssignStatementAST.hh"
+#include "EnqueueStatementAST.hh"
+#include "IfStatementAST.hh"
+#include "PeekStatementAST.hh"
+#include "CopyHeadStatementAST.hh"
+#include "CheckAllocateStatementAST.hh"
+#include "CheckStopSlotsStatementAST.hh"
+#include "ReturnStatementAST.hh"
+
+#endif //ASTs_H
diff --git a/src/mem/slicc/ast/ActionDeclAST.cc b/src/mem/slicc/ast/ActionDeclAST.cc
new file mode 100644
index 000000000..6514b9afd
--- /dev/null
+++ b/src/mem/slicc/ast/ActionDeclAST.cc
@@ -0,0 +1,96 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ActionDeclAST.C
+ *
+ * Description: See ActionDeclAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "ActionDeclAST.hh"
+#include "Action.hh"
+
+ActionDeclAST::ActionDeclAST(string* ident_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_ident_ptr = ident_ptr;
+ m_statement_list_ptr = statement_list_ptr;
+}
+
+ActionDeclAST::~ActionDeclAST()
+{
+ delete m_ident_ptr;
+ delete m_statement_list_ptr;
+}
+
+void ActionDeclAST::generate()
+{
+ Map<Var*, string> resource_list;
+ if (m_statement_list_ptr != NULL) {
+ string code;
+
+ // Add new local vars
+ g_sym_table.pushFrame();
+
+ Type* type_ptr = g_sym_table.getType("Address");
+
+ if (type_ptr == NULL) {
+ error("Type 'Address' not declared.");
+ }
+
+ g_sym_table.newSym(new Var("address", getLocation(), type_ptr, "addr", getPairs()));
+
+ // Don't allows returns in actions
+ m_statement_list_ptr->generate(code, NULL);
+
+ getPairs().add("c_code", code);
+
+ m_statement_list_ptr->findResources(resource_list);
+
+ g_sym_table.popFrame();
+ }
+
+ StateMachine* machine_ptr = g_sym_table.getStateMachine();
+ if (machine_ptr == NULL) {
+ error("Action declaration not part of a machine.");
+ } else {
+ machine_ptr->addAction(new Action(*m_ident_ptr, resource_list, getLocation(), getPairs()));
+ }
+
+}
+
+void ActionDeclAST::print(ostream& out) const
+{
+ out << "[ActionDecl: " << *m_ident_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/ActionDeclAST.hh b/src/mem/slicc/ast/ActionDeclAST.hh
new file mode 100644
index 000000000..cc020a95f
--- /dev/null
+++ b/src/mem/slicc/ast/ActionDeclAST.hh
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ActionDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: ActionDeclAST.h,v 3.2 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#ifndef ActionDeclAST_H
+#define ActionDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "StatementListAST.hh"
+
+class ActionDeclAST : public DeclAST {
+public:
+ // Constructors
+ ActionDeclAST(string* ident_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ptr);
+
+ // Destructor
+ ~ActionDeclAST();
+
+ // Public Methods
+ void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ ActionDeclAST(const ActionDeclAST& obj);
+ ActionDeclAST& operator=(const ActionDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+ StatementListAST* m_statement_list_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const ActionDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const ActionDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //ActionDeclAST_H
diff --git a/src/mem/slicc/ast/AssignStatementAST.cc b/src/mem/slicc/ast/AssignStatementAST.cc
new file mode 100644
index 000000000..2d72e583e
--- /dev/null
+++ b/src/mem/slicc/ast/AssignStatementAST.cc
@@ -0,0 +1,76 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * AssignStatementAST.C
+ *
+ * Description: See AssignStatementAST.h
+ *
+ * $Id: AssignStatementAST.C,v 3.2 2003/08/01 18:38:19 beckmann Exp $
+ *
+ */
+
+#include "AssignStatementAST.hh"
+
+AssignStatementAST::AssignStatementAST(ExprAST* lvalue_ptr, ExprAST* rvalue_ptr)
+ : StatementAST()
+{
+ m_lvalue_ptr = lvalue_ptr;
+ m_rvalue_ptr = rvalue_ptr;
+}
+
+AssignStatementAST::~AssignStatementAST()
+{
+ delete m_lvalue_ptr;
+ delete m_rvalue_ptr;
+}
+
+void AssignStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ code += indent_str();
+ Type* lvalue_type_ptr = m_lvalue_ptr->generate(code);
+ code += " = ";
+ Type* rvalue_type_ptr = m_rvalue_ptr->generate(code);
+ code += ";\n";
+
+ if (lvalue_type_ptr != rvalue_type_ptr) {
+ // FIXME - beckmann
+ // the following if statement is a hack to allow NetDest objects to be assigned to Sets
+ // this allows for the previous NetworkMessage Destiantion 'Set class' to migrate to the
+ // new NetworkMessage Destiantion 'NetDest class'
+ if (lvalue_type_ptr->toString() != "NetDest" && rvalue_type_ptr->toString() != "Set") {
+ error("Assignment type mismatch '" + lvalue_type_ptr->toString() + "' and '" + rvalue_type_ptr->toString() + "'");
+ }
+ }
+}
+
+void AssignStatementAST::print(ostream& out) const
+{
+ out << "[AssignStatementAST: " << *m_lvalue_ptr << " := " << *m_rvalue_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/AssignStatementAST.hh b/src/mem/slicc/ast/AssignStatementAST.hh
new file mode 100644
index 000000000..c249c8a75
--- /dev/null
+++ b/src/mem/slicc/ast/AssignStatementAST.hh
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * AssignStatementAST.h
+ *
+ * Description:
+ *
+ * $Id: AssignStatementAST.h,v 3.2 2001/12/12 01:00:09 milo Exp $
+ *
+ */
+
+#ifndef ASSIGNSTATEMENTAST_H
+#define ASSIGNSTATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "ExprAST.hh"
+
+
+
+class AssignStatementAST : public StatementAST {
+public:
+ // Constructors
+ AssignStatementAST(ExprAST* lvalue_ptr, ExprAST* rvalue_ptr);
+
+ // Destructor
+ ~AssignStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ AssignStatementAST(const AssignStatementAST& obj);
+ AssignStatementAST& operator=(const AssignStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ ExprAST* m_lvalue_ptr;
+ ExprAST* m_rvalue_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const AssignStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const AssignStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //ASSIGNSTATEMENTAST_H
diff --git a/src/mem/slicc/ast/CheckAllocateStatementAST.cc b/src/mem/slicc/ast/CheckAllocateStatementAST.cc
new file mode 100644
index 000000000..25fd4d2e7
--- /dev/null
+++ b/src/mem/slicc/ast/CheckAllocateStatementAST.cc
@@ -0,0 +1,72 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#include "CheckAllocateStatementAST.hh"
+#include "SymbolTable.hh"
+#include "VarExprAST.hh"
+#include "util.hh"
+
+CheckAllocateStatementAST::CheckAllocateStatementAST(VarExprAST* variable)
+ : StatementAST()
+{
+ m_variable = variable;
+}
+
+CheckAllocateStatementAST::~CheckAllocateStatementAST()
+{
+ delete m_variable;
+}
+
+void CheckAllocateStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ // FIXME - check the type of the variable
+
+ // Make sure the variable is valid
+ m_variable->getVar();
+}
+
+void CheckAllocateStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ Var* var_ptr = m_variable->getVar();
+ int res_count = 0;
+ if (resource_list.exist(var_ptr)) {
+ res_count = atoi((resource_list.lookup(var_ptr)).c_str());
+ }
+ resource_list.add(var_ptr, int_to_string(res_count+1));
+}
+
+void CheckAllocateStatementAST::print(ostream& out) const
+{
+ out << "[CheckAllocateStatementAst: " << *m_variable << "]";
+}
diff --git a/src/mem/slicc/ast/CheckAllocateStatementAST.hh b/src/mem/slicc/ast/CheckAllocateStatementAST.hh
new file mode 100644
index 000000000..8df08a086
--- /dev/null
+++ b/src/mem/slicc/ast/CheckAllocateStatementAST.hh
@@ -0,0 +1,82 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#ifndef CHECKALLOCATESTATEMENTAST_H
+#define CHECKALLOCATESTATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "TypeAST.hh"
+
+class VarExprAST;
+class Var;
+
+class CheckAllocateStatementAST : public StatementAST {
+public:
+ // Constructors
+ CheckAllocateStatementAST(VarExprAST* variable);
+
+ // Destructor
+ ~CheckAllocateStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ CheckAllocateStatementAST(const CheckAllocateStatementAST& obj);
+ CheckAllocateStatementAST& operator=(const CheckAllocateStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ VarExprAST* m_variable;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const CheckAllocateStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const CheckAllocateStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //CHECKALLOCATESTATEMENTAST_H
diff --git a/src/mem/slicc/ast/CheckStopSlotsStatementAST.cc b/src/mem/slicc/ast/CheckStopSlotsStatementAST.cc
new file mode 100644
index 000000000..f102e8894
--- /dev/null
+++ b/src/mem/slicc/ast/CheckStopSlotsStatementAST.cc
@@ -0,0 +1,115 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#include "CheckStopSlotsStatementAST.hh"
+#include "SymbolTable.hh"
+#include "VarExprAST.hh"
+#include "PairListAST.hh"
+
+CheckStopSlotsStatementAST::CheckStopSlotsStatementAST(VarExprAST* variable, string* condStr, string* bankStr)
+ : StatementAST()
+{
+ m_variable = variable;
+ m_condStr_ptr = condStr;
+ m_bankStr_ptr = bankStr;
+}
+
+CheckStopSlotsStatementAST::~CheckStopSlotsStatementAST()
+{
+ delete m_variable;
+ delete m_condStr_ptr;
+ delete m_bankStr_ptr;
+}
+
+void CheckStopSlotsStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+
+ // Make sure the variable is valid
+ m_variable->getVar();
+
+}
+
+void CheckStopSlotsStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ Type* type_ptr;
+
+ Var* var_ptr = m_variable->getVar();
+ string check_code;
+
+ if (*m_condStr_ptr == "((*in_msg_ptr)).m_isOnChipSearch") {
+ check_code += " const Response9Msg* in_msg_ptr;\n";
+ check_code += " in_msg_ptr = dynamic_cast<const Response9Msg*>(((*(m_chip_ptr->m_L2Cache_responseToL2Cache9_vec[m_version]))).peek());\n";
+ check_code += " assert(in_msg_ptr != NULL);\n";
+ }
+
+ check_code += " if (";
+ check_code += *m_condStr_ptr;
+ check_code += ") {\n";
+
+ check_code += " if (!";
+ type_ptr = m_variable->generate(check_code);
+ check_code += ".isDisableSPossible((((*(m_chip_ptr->m_DNUCAmover_ptr))).getBankPos(";
+ check_code += *m_bankStr_ptr;
+ check_code += ")))) {\n";
+ if(CHECK_INVALID_RESOURCE_STALLS) {
+ check_code += " assert(priority >= ";
+ type_ptr = m_variable->generate(check_code);
+ check_code += ".getPriority());\n";
+ }
+ check_code += " return TransitionResult_ResourceStall;\n";
+ check_code += " }\n";
+ check_code += " } else {\n";
+ check_code += " if (!";
+ type_ptr = m_variable->generate(check_code);
+ check_code += ".isDisableFPossible((((*(m_chip_ptr->m_DNUCAmover_ptr))).getBankPos(";
+ check_code += *m_bankStr_ptr;
+ check_code += ")))) {\n";
+ if(CHECK_INVALID_RESOURCE_STALLS) {
+ check_code += " assert(priority >= ";
+ type_ptr = m_variable->generate(check_code);
+ check_code += ".getPriority());\n";
+ }
+ check_code += " return TransitionResult_ResourceStall;\n";
+ check_code += " }\n";
+ check_code += " }\n";
+
+ assert(!resource_list.exist(var_ptr));
+ resource_list.add(var_ptr, check_code);
+
+}
+
+void CheckStopSlotsStatementAST::print(ostream& out) const
+{
+ out << "[CheckStopSlotsStatementAst: " << *m_variable << "]";
+}
diff --git a/src/mem/slicc/ast/CheckStopSlotsStatementAST.hh b/src/mem/slicc/ast/CheckStopSlotsStatementAST.hh
new file mode 100644
index 000000000..131b8cf4d
--- /dev/null
+++ b/src/mem/slicc/ast/CheckStopSlotsStatementAST.hh
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#ifndef CHECKSTOPSLOTSSTATEMENTAST_H
+#define CHECKSTOPSLOTSSTATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "ExprAST.hh"
+#include "StatementAST.hh"
+#include "TypeAST.hh"
+
+class VarExprAST;
+class Var;
+
+class CheckStopSlotsStatementAST : public StatementAST {
+public:
+ // Constructors
+ CheckStopSlotsStatementAST(VarExprAST* variable, string* condStr, string* bankStr);
+
+ // Destructor
+ ~CheckStopSlotsStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ CheckStopSlotsStatementAST(const CheckStopSlotsStatementAST& obj);
+ CheckStopSlotsStatementAST& operator=(const CheckStopSlotsStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ VarExprAST* m_variable;
+ string* m_condStr_ptr;
+ string* m_bankStr_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const CheckStopSlotsStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const CheckStopSlotsStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //CHECKSTOPSLOTSSTATEMENTAST_H
diff --git a/src/mem/slicc/ast/ChipComponentAccessAST.cc b/src/mem/slicc/ast/ChipComponentAccessAST.cc
new file mode 100644
index 000000000..1ba1b98f2
--- /dev/null
+++ b/src/mem/slicc/ast/ChipComponentAccessAST.cc
@@ -0,0 +1,244 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ChipComponentAccessAST.C
+ *
+ * Description: See ChipComponentAccessAST.h
+ *
+ * $Id: ChipComponentAccessAST.C 1.9 04/06/18 21:00:08-00:00 beckmann@cottons.cs.wisc.edu $
+ *
+ */
+
+#include "ChipComponentAccessAST.hh"
+
+ChipComponentAccessAST::ChipComponentAccessAST(VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* proc_name, Vector<ExprAST*>* expr_vec_ptr)
+
+ : ExprAST()
+{
+ m_chip_ver_expr_ptr = NULL;
+ m_mach_var_ptr = machine;
+ m_comp_var_ptr = component;
+ m_mach_ver_expr_ptr = mach_version;
+ m_expr_vec_ptr = expr_vec_ptr;
+ m_proc_name_ptr = proc_name;
+ m_field_name_ptr = NULL;
+}
+
+ChipComponentAccessAST::ChipComponentAccessAST(VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* field_name)
+
+ : ExprAST()
+{
+ m_chip_ver_expr_ptr = NULL;
+ m_mach_var_ptr = machine;
+ m_comp_var_ptr = component;
+ m_mach_ver_expr_ptr = mach_version;
+ m_expr_vec_ptr = NULL;
+ m_proc_name_ptr = NULL;
+ m_field_name_ptr = field_name;
+}
+
+ChipComponentAccessAST::ChipComponentAccessAST(ExprAST* chip_version, VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* proc_name, Vector<ExprAST*>* expr_vec_ptr)
+
+ : ExprAST()
+{
+ m_chip_ver_expr_ptr = chip_version;
+ m_mach_var_ptr = machine;
+ m_comp_var_ptr = component;
+ m_mach_ver_expr_ptr = mach_version;
+ m_expr_vec_ptr = expr_vec_ptr;
+ m_proc_name_ptr = proc_name;
+ m_field_name_ptr = NULL;
+}
+
+ChipComponentAccessAST::ChipComponentAccessAST(ExprAST* chip_version, VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* field_name)
+
+ : ExprAST()
+{
+ m_chip_ver_expr_ptr = chip_version;
+ m_mach_var_ptr = machine;
+ m_comp_var_ptr = component;
+ m_mach_ver_expr_ptr = mach_version;
+ m_expr_vec_ptr = NULL;
+ m_proc_name_ptr = NULL;
+ m_field_name_ptr = field_name;
+}
+
+
+
+ChipComponentAccessAST::~ChipComponentAccessAST()
+{
+ if (m_expr_vec_ptr != NULL) {
+ int size = m_expr_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_expr_vec_ptr)[i];
+ }
+ }
+
+ delete m_mach_var_ptr;
+ delete m_comp_var_ptr;
+ delete m_mach_ver_expr_ptr;
+
+ if (m_proc_name_ptr != NULL) {
+ delete m_proc_name_ptr;
+ }
+
+ if (m_field_name_ptr != NULL) {
+ delete m_field_name_ptr;
+ }
+
+ if (m_chip_ver_expr_ptr != NULL) {
+ delete m_chip_ver_expr_ptr;
+ }
+}
+
+Type* ChipComponentAccessAST::generate(string& code) const
+{
+ Type* void_type_ptr = g_sym_table.getType("void");
+ Type* ret_type_ptr;
+
+
+ code += "(";
+
+ Var* v = g_sym_table.getMachComponentVar(m_mach_var_ptr->getName(), m_comp_var_ptr->getName());
+
+ string orig_code = v->getCode();
+ string working_code;
+
+ if (m_chip_ver_expr_ptr != NULL) {
+ // replace m_chip_ptr with specified chip
+
+ unsigned int t = orig_code.find("m_chip_ptr");
+ assert(t != string::npos);
+ string code_temp0 = orig_code.substr(0, t);
+ string code_temp1 = orig_code.substr(t+10);
+
+ working_code += code_temp0;
+ working_code += "g_system_ptr->getChip(";
+ m_chip_ver_expr_ptr->generate(working_code);
+ working_code += ")";
+ working_code += code_temp1;
+ }
+ else {
+ working_code += orig_code;
+ }
+
+ // replace default "m_version" with the version we really want
+ unsigned int tmp_uint = working_code.find("m_version");
+ assert(tmp_uint != string::npos);
+ string code_temp2 = working_code.substr(0, tmp_uint);
+ string code_temp3 = working_code.substr(tmp_uint+9);
+
+ code += code_temp2;
+ code += "(";
+ m_mach_ver_expr_ptr->generate(code);
+ code += ")";
+ code += code_temp3;
+ code += ")";
+
+ if (m_proc_name_ptr != NULL) {
+ // method call
+ code += ".";
+
+ Vector <Type*> paramTypes;
+
+ // generate code
+ int actual_size = m_expr_vec_ptr->size();
+ code += (*m_proc_name_ptr) + "(";
+ for(int i=0; i<actual_size; i++) {
+ if (i != 0) {
+ code += ", ";
+ }
+ // Check the types of the parameter
+ Type* actual_type_ptr = (*m_expr_vec_ptr)[i]->generate(code);
+ paramTypes.insertAtBottom(actual_type_ptr);
+ }
+ code += ")";
+
+ Type* obj_type_ptr = v->getType();
+ string methodId = obj_type_ptr->methodId(*m_proc_name_ptr, paramTypes);
+
+ // Verify that this is a method of the object
+ if (!obj_type_ptr->methodExist(methodId)) {
+ error("Invalid method call: Type '" + obj_type_ptr->toString() + "' does not have a method '" + methodId + "'");
+ }
+
+ int expected_size = obj_type_ptr->methodParamType(methodId).size();
+ if (actual_size != expected_size) {
+ // Right number of parameters
+ ostringstream err;
+ err << "Wrong number of parameters for function name: '" << *m_proc_name_ptr << "'";
+ err << ", expected: ";
+ err << expected_size;
+ err << ", actual: ";
+ err << actual_size;
+ error(err.str());
+ }
+
+ for(int i=0; i<actual_size; i++) {
+ // Check the types of the parameter
+ Type* actual_type_ptr = paramTypes[i];
+ Type* expected_type_ptr = obj_type_ptr->methodParamType(methodId)[i];
+ if (actual_type_ptr != expected_type_ptr) {
+ (*m_expr_vec_ptr)[i]->error("Type mismatch: expected: " + expected_type_ptr->toString() +
+ " actual: " + actual_type_ptr->toString());
+ }
+ }
+
+ // Return the return type of the method
+ ret_type_ptr = obj_type_ptr->methodReturnType(methodId);
+ }
+ else if (m_field_name_ptr != NULL) {
+ Type* obj_type_ptr = v->getType();
+ code += ").m_" + (*m_field_name_ptr);
+
+ // Verify that this is a valid field name for this type
+ if (!obj_type_ptr->dataMemberExist(*m_field_name_ptr)) {
+ error("Invalid object field: Type '" + obj_type_ptr->toString() + "' does not have data member " + *m_field_name_ptr);
+ }
+
+ // Return the type of the field
+ ret_type_ptr = obj_type_ptr->dataMemberType(*m_field_name_ptr);
+ }
+ else {
+ assert(0);
+ }
+
+ return ret_type_ptr;
+}
+
+void ChipComponentAccessAST::findResources(Map<Var*, string>& resource_list) const
+{
+
+}
+
+void ChipComponentAccessAST::print(ostream& out) const
+{
+ out << "[ChipAccessExpr: " << *m_expr_vec_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/ChipComponentAccessAST.hh b/src/mem/slicc/ast/ChipComponentAccessAST.hh
new file mode 100644
index 000000000..039fece2b
--- /dev/null
+++ b/src/mem/slicc/ast/ChipComponentAccessAST.hh
@@ -0,0 +1,101 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ *
+ *
+ * Description:
+ *
+ * $Id: ChipComponentAccessAST.h 1.8 04/06/18 21:00:08-00:00 beckmann@cottons.cs.wisc.edu $
+ *
+ */
+
+#ifndef ChipComponentAccessAST_H
+#define ChipComponentAccessAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "ExprAST.hh"
+#include "VarExprAST.hh"
+#include "TypeAST.hh"
+
+class ChipComponentAccessAST : public ExprAST {
+public:
+ // Constructors
+
+ // method call from local chip
+ ChipComponentAccessAST(VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* proc_name, Vector<ExprAST*>* expr_vec_ptr);
+ // member access from local chip
+ ChipComponentAccessAST(VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* field_name);
+
+ // method call from specified chip
+ ChipComponentAccessAST(ExprAST* chip_version, VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* proc_name, Vector<ExprAST*>* expr_vec_ptr);
+
+ // member access from specified chip
+ ChipComponentAccessAST(ExprAST* chip_version, VarExprAST* machine, ExprAST* mach_version, VarExprAST* component, string* field_name);
+
+ // Destructor
+ ~ChipComponentAccessAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ ChipComponentAccessAST(const ChipComponentAccessAST& obj);
+ ChipComponentAccessAST& operator=(const ChipComponentAccessAST& obj);
+
+ // Data Members (m_ prefix)
+ VarExprAST* m_mach_var_ptr;
+ VarExprAST* m_comp_var_ptr;
+ ExprAST* m_mach_ver_expr_ptr;
+ ExprAST* m_chip_ver_expr_ptr;
+ Vector<ExprAST*>* m_expr_vec_ptr;
+ string* m_proc_name_ptr;
+ string* m_field_name_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const ChipComponentAccessAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const ChipComponentAccessAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif // ChipComponentAccessAST_H
diff --git a/src/mem/slicc/ast/CopyHeadStatementAST.cc b/src/mem/slicc/ast/CopyHeadStatementAST.cc
new file mode 100644
index 000000000..40e61dc07
--- /dev/null
+++ b/src/mem/slicc/ast/CopyHeadStatementAST.cc
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#include "CopyHeadStatementAST.hh"
+#include "SymbolTable.hh"
+#include "VarExprAST.hh"
+#include "util.hh"
+
+CopyHeadStatementAST::CopyHeadStatementAST(VarExprAST* in_queue_ptr,
+ VarExprAST* out_queue_ptr,
+ PairListAST* pairs_ptr)
+ : StatementAST(pairs_ptr->getPairs())
+{
+ m_in_queue_ptr = in_queue_ptr;
+ m_out_queue_ptr = out_queue_ptr;
+}
+
+CopyHeadStatementAST::~CopyHeadStatementAST()
+{
+ delete m_in_queue_ptr;
+ delete m_out_queue_ptr;
+}
+
+void CopyHeadStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ m_in_queue_ptr->assertType("InPort");
+ m_out_queue_ptr->assertType("OutPort");
+
+ code += indent_str();
+ code += m_out_queue_ptr->getVar()->getCode() + ".enqueue(" + m_in_queue_ptr->getVar()->getCode() + ".getMsgPtrCopy()";
+
+ if (getPairs().exist("latency")) {
+ code += ", " + getPairs().lookup("latency");
+ } else {
+ code += ", COPY_HEAD_LATENCY";
+ }
+
+ code += ");\n";
+}
+
+void CopyHeadStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ Var* var_ptr = m_out_queue_ptr->getVar();
+ int res_count = 0;
+ if (resource_list.exist(var_ptr)) {
+ res_count = atoi((resource_list.lookup(var_ptr)).c_str());
+ }
+ resource_list.add(var_ptr, int_to_string(res_count+1));
+}
+
+void CopyHeadStatementAST::print(ostream& out) const
+{
+ out << "[CopyHeadStatementAst: " << *m_in_queue_ptr << " " << *m_out_queue_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/CopyHeadStatementAST.hh b/src/mem/slicc/ast/CopyHeadStatementAST.hh
new file mode 100644
index 000000000..1631395fc
--- /dev/null
+++ b/src/mem/slicc/ast/CopyHeadStatementAST.hh
@@ -0,0 +1,87 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#ifndef COPYHEADSTATEMENTAST_H
+#define COPYHEADTATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "StatementListAST.hh"
+#include "TypeAST.hh"
+#include "PairListAST.hh"
+
+class VarExprAST;
+class Var;
+
+class CopyHeadStatementAST : public StatementAST {
+public:
+ // Constructors
+ CopyHeadStatementAST(VarExprAST* in_queue_ptr,
+ VarExprAST* out_queue_ptr,
+ PairListAST* pairs_ptr);
+
+ // Destructor
+ ~CopyHeadStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ CopyHeadStatementAST(const CopyHeadStatementAST& obj);
+ CopyHeadStatementAST& operator=(const CopyHeadStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ VarExprAST* m_in_queue_ptr;
+ VarExprAST* m_out_queue_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const CopyHeadStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const CopyHeadStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //COPYHEADSTATEMENTAST_H
diff --git a/src/mem/slicc/ast/DeclAST.cc b/src/mem/slicc/ast/DeclAST.cc
new file mode 100644
index 000000000..4269ed9f4
--- /dev/null
+++ b/src/mem/slicc/ast/DeclAST.cc
@@ -0,0 +1,39 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * DeclAST.C
+ *
+ * Description: See DeclAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "DeclAST.hh"
diff --git a/src/mem/slicc/ast/DeclAST.hh b/src/mem/slicc/ast/DeclAST.hh
new file mode 100644
index 000000000..e7c8467d6
--- /dev/null
+++ b/src/mem/slicc/ast/DeclAST.hh
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * DeclAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef DECLAST_H
+#define DECLAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+#include "PairListAST.hh"
+#include "StateMachine.hh"
+#include "TypeAST.hh"
+
+class DeclAST : public AST {
+public:
+ // Constructors
+ DeclAST(PairListAST* pairs_ptr) : AST(pairs_ptr->getPairs()) {}
+
+ // Destructor
+ virtual ~DeclAST() {}
+
+ // Public Methods
+ virtual void generate() = 0;
+ virtual void findMachines() {};
+
+ // void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ // DeclAST(const DeclAST& obj);
+ // DeclAST& operator=(const DeclAST& obj);
+
+ // Data Members (m_ prefix)
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const DeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const DeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //DECLAST_H
diff --git a/src/mem/slicc/ast/DeclListAST.cc b/src/mem/slicc/ast/DeclListAST.cc
new file mode 100644
index 000000000..6dacd5435
--- /dev/null
+++ b/src/mem/slicc/ast/DeclListAST.cc
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * DeclListAST.C
+ *
+ * Description: See DeclListAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "DeclListAST.hh"
+
+DeclListAST::DeclListAST(Vector<DeclAST*>* vec_ptr)
+ : AST()
+{
+ assert(vec_ptr != NULL);
+ m_vec_ptr = vec_ptr;
+}
+
+// Singleton constructor.
+DeclListAST::DeclListAST(DeclAST* Decl_ptr)
+ : AST()
+{
+ assert(Decl_ptr != NULL);
+ m_vec_ptr = new Vector<DeclAST*>;
+ m_vec_ptr->insertAtTop(Decl_ptr);
+}
+
+DeclListAST::~DeclListAST()
+{
+ int size = m_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_vec_ptr)[i];
+ }
+ delete m_vec_ptr;
+}
+
+void DeclListAST::generate() const
+{
+ int size = m_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ (*m_vec_ptr)[i]->generate();
+ }
+}
+
+void DeclListAST::findMachines() const
+{
+ int size = m_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ (*m_vec_ptr)[i]->findMachines();
+ }
+}
+
+void DeclListAST::print(ostream& out) const
+{
+ assert(m_vec_ptr != NULL);
+ out << "[DeclListAST: " << *m_vec_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/DeclListAST.hh b/src/mem/slicc/ast/DeclListAST.hh
new file mode 100644
index 000000000..80c7fffcc
--- /dev/null
+++ b/src/mem/slicc/ast/DeclListAST.hh
@@ -0,0 +1,84 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * DeclListAST.h
+ *
+ * Description:
+ *
+ * $Id: DeclListAST.h,v 3.1 2001/12/12 01:00:12 milo Exp $
+ *
+ */
+
+#ifndef DeclListAST_H
+#define DeclListAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+#include "DeclAST.hh"
+
+class DeclListAST : public AST {
+public:
+ // Constructors
+ DeclListAST(Vector<DeclAST*>* vec_ptr);
+ DeclListAST(DeclAST* statement_ptr);
+
+ // Destructor
+ ~DeclListAST();
+
+ // Public Methods
+ void generate() const;
+ void findMachines() const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ DeclListAST(const DeclListAST& obj);
+ DeclListAST& operator=(const DeclListAST& obj);
+
+ // Data Members (m_ prefix)
+ Vector<DeclAST*>* m_vec_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const DeclListAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const DeclListAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //DeclListAST_H
diff --git a/src/mem/slicc/ast/EnqueueStatementAST.cc b/src/mem/slicc/ast/EnqueueStatementAST.cc
new file mode 100644
index 000000000..49f2a9233
--- /dev/null
+++ b/src/mem/slicc/ast/EnqueueStatementAST.cc
@@ -0,0 +1,104 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * $Id$
+ *
+ */
+
+#include "EnqueueStatementAST.hh"
+#include "SymbolTable.hh"
+#include "VarExprAST.hh"
+#include "PairListAST.hh"
+#include "util.hh"
+
+EnqueueStatementAST::EnqueueStatementAST(VarExprAST* queue_name_ptr,
+ TypeAST* type_name_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ast_ptr)
+ : StatementAST(pairs_ptr->getPairs())
+{
+ m_queue_name_ptr = queue_name_ptr;
+ m_type_name_ptr = type_name_ptr;
+ m_statement_list_ast_ptr = statement_list_ast_ptr;
+}
+
+EnqueueStatementAST::~EnqueueStatementAST()
+{
+ delete m_queue_name_ptr;
+ delete m_type_name_ptr;
+ delete m_statement_list_ast_ptr;
+}
+
+void EnqueueStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ code += indent_str() + "{\n"; // Start scope
+ inc_indent();
+ g_sym_table.pushFrame();
+
+ Type* msg_type_ptr = m_type_name_ptr->lookupType();
+
+ // Add new local var to symbol table
+ g_sym_table.newSym(new Var("out_msg", getLocation(), msg_type_ptr, "out_msg", getPairs()));
+
+ code += indent_str() + msg_type_ptr->cIdent() + " out_msg;\n"; // Declare message
+ m_statement_list_ast_ptr->generate(code, NULL); // The other statements
+
+ code += indent_str();
+
+ m_queue_name_ptr->assertType("OutPort");
+ code += "(" + m_queue_name_ptr->getVar()->getCode() + ")";
+ code += ".enqueue(out_msg";
+
+ if (getPairs().exist("latency")) {
+ code += ", " + getPairs().lookup("latency");
+ }
+
+ code += ");\n";
+
+ dec_indent();
+ g_sym_table.popFrame();
+ code += indent_str() + "}\n"; // End scope
+}
+
+void EnqueueStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ Var* var_ptr = m_queue_name_ptr->getVar();
+ int res_count = 0;
+ if (resource_list.exist(var_ptr)) {
+ res_count = atoi((resource_list.lookup(var_ptr)).c_str());
+ }
+ resource_list.add(var_ptr, int_to_string(res_count+1));
+}
+
+void EnqueueStatementAST::print(ostream& out) const
+{
+ out << "[EnqueueStatementAst: " << *m_queue_name_ptr << " "
+ << m_type_name_ptr->toString() << " " << *m_statement_list_ast_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/EnqueueStatementAST.hh b/src/mem/slicc/ast/EnqueueStatementAST.hh
new file mode 100644
index 000000000..eb7dad9af
--- /dev/null
+++ b/src/mem/slicc/ast/EnqueueStatementAST.hh
@@ -0,0 +1,93 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * EnqueueStatementAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef ENQUEUESTATEMENTAST_H
+#define ENQUEUESTATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "StatementListAST.hh"
+#include "TypeAST.hh"
+
+class VarExprAST;
+class Var;
+class PairListAST;
+
+class EnqueueStatementAST : public StatementAST {
+public:
+ // Constructors
+ EnqueueStatementAST(VarExprAST* queue_name_ptr,
+ TypeAST* type_name_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ast_ptr);
+
+ // Destructor
+ ~EnqueueStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ EnqueueStatementAST(const EnqueueStatementAST& obj);
+ EnqueueStatementAST& operator=(const EnqueueStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ VarExprAST* m_queue_name_ptr;
+ TypeAST* m_type_name_ptr;
+ StatementListAST* m_statement_list_ast_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const EnqueueStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const EnqueueStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //ENQUEUESTATEMENTAST_H
diff --git a/src/mem/slicc/ast/EnumDeclAST.cc b/src/mem/slicc/ast/EnumDeclAST.cc
new file mode 100644
index 000000000..c8e033095
--- /dev/null
+++ b/src/mem/slicc/ast/EnumDeclAST.cc
@@ -0,0 +1,98 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * EnumDeclAST.C
+ *
+ * Description: See EnumDeclAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "EnumDeclAST.hh"
+#include "main.hh"
+#include "SymbolTable.hh"
+
+EnumDeclAST::EnumDeclAST(TypeAST* type_ast_ptr,
+ PairListAST* pairs_ptr,
+ Vector<TypeFieldAST*>* field_vec_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_type_ast_ptr = type_ast_ptr;
+ m_field_vec_ptr = field_vec_ptr;
+}
+
+EnumDeclAST::~EnumDeclAST()
+{
+ delete m_type_ast_ptr;
+ if (m_field_vec_ptr != NULL) {
+ int size = m_field_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_field_vec_ptr)[i];
+ }
+ delete m_field_vec_ptr;
+ }
+}
+
+void EnumDeclAST::generate()
+{
+ string machine_name;
+ string id = m_type_ast_ptr->toString();
+
+ Vector<Type*> param_type_vec; // used by to_string func call
+
+ // Make the new type
+ Type* new_type_ptr = new Type(id, getLocation(), getPairs(),
+ g_sym_table.getStateMachine());
+ g_sym_table.newSym(new_type_ptr);
+
+ // Add all of the fields of the type to it
+ if (m_field_vec_ptr != NULL) {
+ int size = m_field_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ (*m_field_vec_ptr)[i]->generate(new_type_ptr);
+ }
+ }
+
+ // Add the implicit State_to_string method - FIXME, this is a bit dirty
+ param_type_vec.insertAtBottom(new_type_ptr); // add state to param vector
+ string func_id = new_type_ptr->cIdent()+"_to_string";
+
+ Map<string, string> pairs;
+ pairs.add("external", "yes");
+ Vector<string> string_vec;
+ g_sym_table.newSym(new Func(func_id, getLocation(), g_sym_table.getType("string"), param_type_vec, string_vec, string(""), pairs, NULL));
+}
+
+void EnumDeclAST::print(ostream& out) const
+{
+ out << "[EnumDecl: " << m_type_ast_ptr->toString() << "]";
+}
+
diff --git a/src/mem/slicc/ast/EnumDeclAST.hh b/src/mem/slicc/ast/EnumDeclAST.hh
new file mode 100644
index 000000000..4474b69cc
--- /dev/null
+++ b/src/mem/slicc/ast/EnumDeclAST.hh
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * EnummDeclAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef EnumDeclAST_H
+#define EnumDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "TypeAST.hh"
+#include "TypeFieldAST.hh"
+
+class EnumDeclAST : public DeclAST {
+public:
+ // Constructors
+ EnumDeclAST(TypeAST* type_ast_ptr,
+ PairListAST* pairs_ptr,
+ Vector<TypeFieldAST*>* field_vec_ptr);
+
+ // Destructor
+ ~EnumDeclAST();
+
+ // Public Methods
+ virtual void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ EnumDeclAST(const EnumDeclAST& obj);
+ EnumDeclAST& operator=(const EnumDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ TypeAST* m_type_ast_ptr;
+ Vector<TypeFieldAST*>* m_field_vec_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const EnumDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const EnumDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //EnumDeclAST_H
diff --git a/src/mem/slicc/ast/EnumExprAST.cc b/src/mem/slicc/ast/EnumExprAST.cc
new file mode 100644
index 000000000..90dc4bebf
--- /dev/null
+++ b/src/mem/slicc/ast/EnumExprAST.cc
@@ -0,0 +1,76 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * EnumExprAST.C
+ *
+ * Description: See EnumExprAST.h
+ *
+ * $Id: EnumExprAST.C,v 3.1 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#include "EnumExprAST.hh"
+
+EnumExprAST::EnumExprAST(TypeAST* type_ast_ptr,
+ string* value_ptr)
+ : ExprAST()
+{
+ assert(value_ptr != NULL);
+ assert(type_ast_ptr != NULL);
+ m_type_ast_ptr = type_ast_ptr;
+ m_value_ptr = value_ptr;
+}
+
+EnumExprAST::~EnumExprAST()
+{
+ delete m_type_ast_ptr;
+ delete m_value_ptr;
+}
+
+Type* EnumExprAST::generate(string& code) const
+{
+ Type* type_ptr = m_type_ast_ptr->lookupType();
+ code += type_ptr->cIdent() + "_" + (*m_value_ptr);
+
+ // Make sure the enumeration value exists
+ if (!type_ptr->enumExist(*m_value_ptr)) {
+ error("Type '" + m_type_ast_ptr->toString() + "' does not have enumeration '" + *m_value_ptr + "'");
+ }
+
+ // Return the proper type
+ return type_ptr;
+}
+
+void EnumExprAST::print(ostream& out) const
+{
+ string str;
+ str += m_type_ast_ptr->toString()+":"+(*m_value_ptr);
+ out << "[EnumExpr: " << str << "]";
+}
diff --git a/src/mem/slicc/ast/EnumExprAST.hh b/src/mem/slicc/ast/EnumExprAST.hh
new file mode 100644
index 000000000..492f9ac33
--- /dev/null
+++ b/src/mem/slicc/ast/EnumExprAST.hh
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * EnumExprAST.h
+ *
+ * Description:
+ *
+ * $Id: EnumExprAST.h,v 3.2 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#ifndef EnumExprAST_H
+#define EnumExprAST_H
+
+#include "slicc_global.hh"
+#include "ExprAST.hh"
+#include "TypeAST.hh"
+
+
+class EnumExprAST : public ExprAST {
+public:
+ // Constructors
+ EnumExprAST(TypeAST* type_ast_ptr,
+ string* value_ptr);
+
+ // Destructor
+ ~EnumExprAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ EnumExprAST(const EnumExprAST& obj);
+ EnumExprAST& operator=(const EnumExprAST& obj);
+
+ // Data Members (m_ prefix)
+ TypeAST* m_type_ast_ptr;
+ string* m_value_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const EnumExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const EnumExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //EnumExprAST_H
diff --git a/src/mem/slicc/ast/ExprAST.cc b/src/mem/slicc/ast/ExprAST.cc
new file mode 100644
index 000000000..e910d688a
--- /dev/null
+++ b/src/mem/slicc/ast/ExprAST.cc
@@ -0,0 +1,39 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ExprAST.C
+ *
+ * Description: See ExprAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "ExprAST.hh"
diff --git a/src/mem/slicc/ast/ExprAST.hh b/src/mem/slicc/ast/ExprAST.hh
new file mode 100644
index 000000000..0015cebaa
--- /dev/null
+++ b/src/mem/slicc/ast/ExprAST.hh
@@ -0,0 +1,84 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ExprAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef EXPRAST_H
+#define EXPRAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+
+
+class ExprAST : public AST {
+public:
+ // Constructors
+ ExprAST() : AST() { }
+
+ // Destructor
+ virtual ~ExprAST() { }
+
+ // Public Methods
+ virtual Type* generate(string& code) const = 0;
+ virtual void findResources(Map<Var*, string>& resource_list) const {} // The default is no resources
+
+ // void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ // ExprAST(const ExprAST& obj);
+ // ExprAST& operator=(const ExprAST& obj);
+
+ // Data Members (m_ prefix)
+
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const ExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const ExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //EXPRAST_H
diff --git a/src/mem/slicc/ast/ExprStatementAST.cc b/src/mem/slicc/ast/ExprStatementAST.cc
new file mode 100644
index 000000000..5eb1ce7b4
--- /dev/null
+++ b/src/mem/slicc/ast/ExprStatementAST.cc
@@ -0,0 +1,73 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ExprStatementAST.C
+ *
+ * Description: See ExprStatementAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "ExprStatementAST.hh"
+
+ExprStatementAST::ExprStatementAST(ExprAST* expr_ptr)
+ : StatementAST()
+{
+ m_expr_ptr = expr_ptr;
+}
+
+ExprStatementAST::~ExprStatementAST()
+{
+ delete m_expr_ptr;
+}
+
+void ExprStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ code += indent_str();
+ Type* actual_type_ptr = m_expr_ptr->generate(code);
+ code += ";\n";
+
+ // The return type must be void
+ Type* expected_type_ptr = g_sym_table.getType("void");
+ if (expected_type_ptr != actual_type_ptr) {
+ m_expr_ptr->error("Non-void return must not be ignored, return type is '" + actual_type_ptr->toString() + "'");
+ }
+}
+
+void ExprStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ m_expr_ptr->findResources(resource_list);
+}
+
+void ExprStatementAST::print(ostream& out) const
+{
+ out << "[ExprStatementAST: " << *m_expr_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/ExprStatementAST.hh b/src/mem/slicc/ast/ExprStatementAST.hh
new file mode 100644
index 000000000..925ded72a
--- /dev/null
+++ b/src/mem/slicc/ast/ExprStatementAST.hh
@@ -0,0 +1,83 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ExprStatementAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef ExprStatementAST_H
+#define ExprStatementAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "ExprAST.hh"
+
+class ExprStatementAST : public StatementAST {
+public:
+ // Constructors
+ ExprStatementAST(ExprAST* expr_ptr);
+
+ // Destructor
+ ~ExprStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ ExprStatementAST(const ExprStatementAST& obj);
+ ExprStatementAST& operator=(const ExprStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ ExprAST* m_expr_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const ExprStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const ExprStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //ExprStatementAST_H
diff --git a/src/mem/slicc/ast/FormalParamAST.cc b/src/mem/slicc/ast/FormalParamAST.cc
new file mode 100644
index 000000000..b7dacf8a1
--- /dev/null
+++ b/src/mem/slicc/ast/FormalParamAST.cc
@@ -0,0 +1,61 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * FormalParamAST.C
+ *
+ * Description: See FormalParamAST.h
+ *
+ * $Id: FormalParamAST.C,v 3.1 2000/10/05 21:22:20 milo Exp $
+ *
+ */
+
+#include "FormalParamAST.hh"
+#include "StatementAST.hh"
+#include "SymbolTable.hh"
+
+FormalParamAST::~FormalParamAST()
+{
+ delete m_ident_ptr;
+ delete m_type_ast_ptr;
+}
+
+Type* FormalParamAST::generate(string& code) const
+{
+ string param = "param_" + *m_ident_ptr;
+
+ Type* type_ptr = m_type_ast_ptr->lookupType();
+ code += type_ptr->cIdent();
+ code += " ";
+ code += param;
+
+ // Add to symbol table
+ g_sym_table.newSym(new Var(*m_ident_ptr, getLocation(), type_ptr, param, getPairs()));
+ return type_ptr;
+}
diff --git a/src/mem/slicc/ast/FormalParamAST.hh b/src/mem/slicc/ast/FormalParamAST.hh
new file mode 100644
index 000000000..0dc08fabe
--- /dev/null
+++ b/src/mem/slicc/ast/FormalParamAST.hh
@@ -0,0 +1,84 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * FormalParamAST.h
+ *
+ * Description:
+ *
+ * $Id: FormalParamAST.h,v 3.1 2001/12/12 01:00:15 milo Exp $
+ *
+ */
+
+#ifndef FORMALPARAMAST_H
+#define FORMALPARAMAST_H
+
+#include "slicc_global.hh"
+#include "TypeAST.hh"
+
+
+class FormalParamAST : public AST {
+public:
+ // Constructors
+ FormalParamAST(TypeAST* type_ast_ptr, string* ident_ptr) : AST() { m_type_ast_ptr = type_ast_ptr; m_ident_ptr = ident_ptr; }
+
+ // Destructor
+ ~FormalParamAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void print(ostream& out) const { out << "[FormalParamAST: " << *m_ident_ptr << "]"; }
+ string getName() const { return *m_ident_ptr; }
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ FormalParamAST(const FormalParamAST& obj);
+ FormalParamAST& operator=(const FormalParamAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+ TypeAST* m_type_ast_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const FormalParamAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const FormalParamAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //FORMALPARAMAST_H
diff --git a/src/mem/slicc/ast/FuncCallExprAST.cc b/src/mem/slicc/ast/FuncCallExprAST.cc
new file mode 100644
index 000000000..845d0c8e3
--- /dev/null
+++ b/src/mem/slicc/ast/FuncCallExprAST.cc
@@ -0,0 +1,224 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * FuncCallExprAST.C
+ *
+ * Description: See FuncCallExprAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "FuncCallExprAST.hh"
+#include "SymbolTable.hh"
+
+FuncCallExprAST::FuncCallExprAST(string* proc_name_ptr,
+ Vector<ExprAST*>* expr_vec_ptr)
+ : ExprAST()
+{
+ m_proc_name_ptr = proc_name_ptr;
+ m_expr_vec_ptr = expr_vec_ptr;
+}
+
+FuncCallExprAST::~FuncCallExprAST()
+{
+ delete m_proc_name_ptr;
+ int size = m_expr_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_expr_vec_ptr)[i];
+ }
+ delete m_expr_vec_ptr;
+}
+
+Type* FuncCallExprAST::generate(string& code) const
+{
+ // DEBUG_EXPR is strange since it takes parameters of multiple types
+ if (*m_proc_name_ptr == "DEBUG_EXPR") {
+ // FIXME - check for number of parameters
+ code += "DEBUG_SLICC(MedPrio, \"";
+ code += (*m_expr_vec_ptr)[0]->getLocation().toString();
+ code += ": \", ";
+ (*m_expr_vec_ptr)[0]->generate(code);
+ code += ");\n";
+ Type* void_type_ptr = g_sym_table.getType("void");
+ assert(void_type_ptr != NULL);
+ return void_type_ptr;
+ }
+
+ // hack for adding comments to profileTransition
+ if (*m_proc_name_ptr == "APPEND_TRANSITION_COMMENT") {
+ // FIXME - check for number of parameters
+ code += "APPEND_TRANSITION_COMMENT(";
+ //code += (*m_expr_vec_ptr)[0]->getLocation().toString();
+ //code += ": \", ";
+ (*m_expr_vec_ptr)[0]->generate(code);
+ code += ");\n";
+ Type* void_type_ptr = g_sym_table.getType("void");
+ assert(void_type_ptr != NULL);
+ return void_type_ptr;
+ }
+
+ // Look up the function in the symbol table
+ Vector<string> code_vec;
+ Func* func_ptr = g_sym_table.getFunc(*m_proc_name_ptr);
+
+ // Check the types and get the code for the parameters
+ if (func_ptr == NULL) {
+ error("Unrecognized function name: '" + *m_proc_name_ptr + "'");
+ } else {
+ int size = m_expr_vec_ptr->size();
+
+ Vector<Type*> f = func_ptr->getParamTypes();
+
+ if (size != f.size() ) {
+ error("Wrong number of arguments passed to function : '" + *m_proc_name_ptr + "'");
+ }
+ else {
+ for(int i=0; i<size; i++) {
+
+ // Check the types of the parameter
+ string param_code;
+ Type* actual_type_ptr = (*m_expr_vec_ptr)[i]->generate(param_code);
+ Type* expected_type_ptr = func_ptr->getParamTypes()[i];
+ if (actual_type_ptr != expected_type_ptr) {
+ (*m_expr_vec_ptr)[i]->error("Type mismatch: expected: " + expected_type_ptr->toString() +
+ " actual: " + actual_type_ptr->toString());
+ }
+ code_vec.insertAtBottom(param_code);
+ }
+ }
+ }
+
+ /* OK, the semantics of "trigger" here is that, ports in the machine have
+ * different priorities. We always check the first port for doable
+ * transitions. If nothing/stalled, we pick one from the next port.
+ *
+ * One thing we have to be careful as the SLICC protocol writter is :
+ * If a port have two or more transitions can be picked from in one cycle,
+ * they must be independent. Otherwise, if transition A and B mean to be
+ * executed in sequential, and A get stalled, transition B can be issued
+ * erroneously. In practice, in most case, there is only one transition
+ * should be executed in one cycle for a given port. So as most of current
+ * protocols.
+ */
+
+ if (*m_proc_name_ptr == "trigger") {
+ code += indent_str() + "{\n";
+ code += indent_str() + " Address addr = ";
+ code += code_vec[1];
+ code += ";\n";
+ code += indent_str() + " TransitionResult result = doTransition(";
+ code += code_vec[0];
+ code += ", " + g_sym_table.getStateMachine()->toString() + "_getState(addr), addr";
+ if(CHECK_INVALID_RESOURCE_STALLS) {
+ // FIXME - the current assumption is that in_buffer_rank is declared in the msg buffer peek statement
+ code += ", in_buffer_rank";
+ }
+ code += ");\n";
+ code += indent_str() + " if (result == TransitionResult_Valid) {\n";
+ code += indent_str() + " counter++;\n";
+ code += indent_str() + " continue; // Check the first port again\n";
+ code += indent_str() + " }\n";
+ code += indent_str() + " if (result == TransitionResult_ResourceStall) {\n";
+ code += indent_str() + " g_eventQueue_ptr->scheduleEvent(this, 1);\n";
+ code += indent_str() + " // Cannot do anything with this transition, go check next doable transition (mostly likely of next port)\n";
+ code += indent_str() + " }\n";
+ code += indent_str() + "}\n";
+ } else if (*m_proc_name_ptr == "doubleTrigger") {
+ // NOTE: Use the doubleTrigger call with extreme caution
+ // the key to double trigger is the second event triggered cannot fail becuase the first event cannot be undone
+ assert(code_vec.size() == 4);
+ code += indent_str() + "{\n";
+ code += indent_str() + " Address addr1 = ";
+ code += code_vec[1];
+ code += ";\n";
+ code += indent_str() + " TransitionResult result1 = doTransition(";
+ code += code_vec[0];
+ code += ", " + g_sym_table.getStateMachine()->toString() + "_getState(addr1), addr1";
+ if(CHECK_INVALID_RESOURCE_STALLS) {
+ // FIXME - the current assumption is that in_buffer_rank is declared in the msg buffer peek statement
+ code += ", in_buffer_rank";
+ }
+ code += ");\n";
+ code += indent_str() + " if (result1 == TransitionResult_Valid) {\n";
+ code += indent_str() + " //this second event cannont fail because the first event already took effect\n";
+ code += indent_str() + " Address addr2 = ";
+ code += code_vec[3];
+ code += ";\n";
+ code += indent_str() + " TransitionResult result2 = doTransition(";
+ code += code_vec[2];
+ code += ", " + g_sym_table.getStateMachine()->toString() + "_getState(addr2), addr2";
+ if(CHECK_INVALID_RESOURCE_STALLS) {
+ // FIXME - the current assumption is that in_buffer_rank is declared in the msg buffer peek statement
+ code += ", in_buffer_rank";
+ }
+ code += ");\n";
+ code += indent_str() + " assert(result2 == TransitionResult_Valid); // ensure the event suceeded\n";
+ code += indent_str() + " counter++;\n";
+ code += indent_str() + " continue; // Check the first port again\n";
+ code += indent_str() + " }\n";
+ code += indent_str() + " if (result1 == TransitionResult_ResourceStall) {\n";
+ code += indent_str() + " g_eventQueue_ptr->scheduleEvent(this, 1);\n";
+ code += indent_str() + " // Cannot do anything with this transition, go check next doable transition (mostly likely of next port)\n";
+ code += indent_str() + " }\n";
+ code += indent_str() + "}\n";
+ } else if (*m_proc_name_ptr == "error") {
+ code += indent_str() + (*m_expr_vec_ptr)[0]->embedError(code_vec[0]) + "\n";
+ } else if (*m_proc_name_ptr == "assert") {
+ code += indent_str() + "if (ASSERT_FLAG && !(" + code_vec[0] + ")) {\n";
+ code += indent_str() + " " + (*m_expr_vec_ptr)[0]->embedError("\"assert failure\"") + "\n";
+ code += indent_str() + "}\n";
+ } else if (*m_proc_name_ptr == "continueProcessing") {
+ code += "counter++; continue; // Check the first port again";
+ } else {
+ // Normal function
+ code += "(";
+ // if the func is internal to the chip but not the machine then it can only be
+ // accessed through the chip pointer
+ if (!func_ptr->existPair("external") && !func_ptr->isInternalMachineFunc()) {
+ code += "m_chip_ptr->";
+ }
+ code += func_ptr->cIdent() + "(";
+ int size = code_vec.size();
+ for(int i=0; i<size; i++) {
+ if (i != 0) {
+ code += ", ";
+ }
+ code += code_vec[i];
+ }
+ code += "))";
+ }
+ return func_ptr->getReturnType();
+}
+
+void FuncCallExprAST::print(ostream& out) const
+{
+ out << "[FuncCallExpr: " << *m_proc_name_ptr << " " << *m_expr_vec_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/FuncCallExprAST.hh b/src/mem/slicc/ast/FuncCallExprAST.hh
new file mode 100644
index 000000000..edac97a04
--- /dev/null
+++ b/src/mem/slicc/ast/FuncCallExprAST.hh
@@ -0,0 +1,89 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * FuncCallExprAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef FUNCCALLEXPRAST_H
+#define FUNCCALLEXPRAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "ExprAST.hh"
+
+
+// ProcGen decl
+class FuncGen;
+
+class FuncCallExprAST : public ExprAST {
+public:
+ // Constructors
+ FuncCallExprAST(string* proc_name_ptr,
+ Vector<ExprAST*>* expr_vec_ptr);
+
+ // Destructor
+ ~FuncCallExprAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void print(ostream& out) const;
+
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ FuncCallExprAST(const FuncCallExprAST& obj);
+ FuncCallExprAST& operator=(const FuncCallExprAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_proc_name_ptr;
+ Vector<ExprAST*>* m_expr_vec_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const FuncCallExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const FuncCallExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //FUNCCALLEXPRAST_H
diff --git a/src/mem/slicc/ast/FuncDeclAST.cc b/src/mem/slicc/ast/FuncDeclAST.cc
new file mode 100644
index 000000000..9f9dd1f8e
--- /dev/null
+++ b/src/mem/slicc/ast/FuncDeclAST.cc
@@ -0,0 +1,111 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * FuncDeclAST.C
+ *
+ * Description: See FuncDeclAST.h
+ *
+ * $Id: FuncDeclAST.C,v 3.4 2003/08/22 18:19:34 beckmann Exp $
+ *
+ */
+
+#include "FuncDeclAST.hh"
+#include "SymbolTable.hh"
+#include "main.hh"
+
+FuncDeclAST::FuncDeclAST(TypeAST* return_type_ast_ptr,
+ string* ident_ptr,
+ Vector<FormalParamAST*>* formal_vec_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_return_type_ast_ptr = return_type_ast_ptr;
+ m_ident_ptr = ident_ptr;
+ m_formal_vec_ptr = formal_vec_ptr;
+ m_statement_list_ptr = statement_list_ptr;
+}
+
+FuncDeclAST::~FuncDeclAST()
+{
+ delete m_return_type_ast_ptr;
+ delete m_ident_ptr;
+
+ int size = m_formal_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_formal_vec_ptr)[i];
+ }
+ delete m_formal_vec_ptr;
+ delete m_statement_list_ptr;
+}
+
+void FuncDeclAST::generate()
+{
+ Vector<Type*> type_vec;
+ Vector<string> param_vec;
+ Type* void_type_ptr = g_sym_table.getType("void");
+
+ // Generate definition code
+ g_sym_table.pushFrame();
+
+ // Lookup return type
+ Type* return_type_ptr = m_return_type_ast_ptr->lookupType();
+
+ // Generate function header
+ int size = m_formal_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ // Lookup parameter types
+ string ident;
+ Type* type_ptr = (*m_formal_vec_ptr)[i]->generate(ident);
+ type_vec.insertAtBottom(type_ptr);
+ param_vec.insertAtBottom(ident);
+ }
+
+ string body;
+ if (m_statement_list_ptr == NULL) {
+ getPairs().add("external", "yes");
+ } else {
+ m_statement_list_ptr->generate(body, return_type_ptr);
+ }
+ g_sym_table.popFrame();
+
+ StateMachine* machine_ptr = g_sym_table.getStateMachine();
+ if (machine_ptr != NULL) {
+ machine_ptr->addFunc(new Func(*m_ident_ptr, getLocation(), return_type_ptr, type_vec, param_vec, body, getPairs(), machine_ptr));
+ } else {
+ g_sym_table.newSym(new Func(*m_ident_ptr, getLocation(), return_type_ptr, type_vec, param_vec, body, getPairs(), machine_ptr));
+ }
+
+}
+
+void FuncDeclAST::print(ostream& out) const
+{
+ out << "[FuncDecl: " << *m_ident_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/FuncDeclAST.hh b/src/mem/slicc/ast/FuncDeclAST.hh
new file mode 100644
index 000000000..4096a8b66
--- /dev/null
+++ b/src/mem/slicc/ast/FuncDeclAST.hh
@@ -0,0 +1,90 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * FuncDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: FuncDeclAST.h,v 3.2 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#ifndef FuncDeclAST_H
+#define FuncDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "TypeFieldAST.hh"
+#include "TypeAST.hh"
+#include "FormalParamAST.hh"
+
+class FuncDeclAST : public DeclAST {
+public:
+ // Constructors
+ FuncDeclAST(TypeAST* return_type_ptr,
+ string* ident_ptr,
+ Vector<FormalParamAST*>* formal_vec_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ptr);
+ // Destructor
+ ~FuncDeclAST();
+
+ // Public Methods
+ void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ FuncDeclAST(const FuncDeclAST& obj);
+ FuncDeclAST& operator=(const FuncDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+ TypeAST* m_return_type_ast_ptr;
+ Vector<FormalParamAST*>* m_formal_vec_ptr;
+ StatementListAST* m_statement_list_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const FuncDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const FuncDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //FuncDeclAST_H
diff --git a/src/mem/slicc/ast/IfStatementAST.cc b/src/mem/slicc/ast/IfStatementAST.cc
new file mode 100644
index 000000000..372b213d8
--- /dev/null
+++ b/src/mem/slicc/ast/IfStatementAST.cc
@@ -0,0 +1,98 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * IfStatementAST.C
+ *
+ * Description: See IfStatementAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "IfStatementAST.hh"
+
+IfStatementAST::IfStatementAST(ExprAST* cond_ptr,
+ StatementListAST* then_ptr,
+ StatementListAST* else_ptr)
+ : StatementAST()
+{
+ assert(cond_ptr != NULL);
+ assert(then_ptr != NULL);
+ m_cond_ptr = cond_ptr;
+ m_then_ptr = then_ptr;
+ m_else_ptr = else_ptr;
+}
+
+IfStatementAST::~IfStatementAST()
+{
+ delete m_cond_ptr;
+ delete m_then_ptr;
+ delete m_else_ptr;
+}
+
+
+void IfStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ Type* type_ptr;
+
+ // Conditional
+ code += indent_str() + "if (";
+ type_ptr = m_cond_ptr->generate(code);
+ if (type_ptr != g_sym_table.getType("bool")) {
+ m_cond_ptr->error("Condition of if statement must be boolean, type was '" + type_ptr->toString() + "'");
+ }
+ code += ") {\n";
+ // Then part
+ inc_indent();
+ m_then_ptr->generate(code, return_type_ptr);
+ dec_indent();
+ // Else part
+ if (m_else_ptr != NULL) {
+ code += indent_str() + "} else {\n";
+ inc_indent();
+ m_else_ptr->generate(code, return_type_ptr);
+ dec_indent();
+ }
+ code += indent_str() + "}\n"; // End scope
+}
+
+void IfStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ // Take a worse case look at both paths
+ m_then_ptr->findResources(resource_list);
+ if (m_else_ptr != NULL) {
+ m_else_ptr->findResources(resource_list);
+ }
+}
+
+void IfStatementAST::print(ostream& out) const
+{
+ out << "[IfStatement: " << *m_cond_ptr << *m_then_ptr << *m_else_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/IfStatementAST.hh b/src/mem/slicc/ast/IfStatementAST.hh
new file mode 100644
index 000000000..bad7a286d
--- /dev/null
+++ b/src/mem/slicc/ast/IfStatementAST.hh
@@ -0,0 +1,89 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * IfStatementAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef IFSTATEMENTAST_H
+#define IFSTATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "ExprAST.hh"
+#include "StatementAST.hh"
+#include "StatementListAST.hh"
+
+
+class IfStatementAST : public StatementAST {
+public:
+ // Constructors
+ IfStatementAST(ExprAST* cond_ptr,
+ StatementListAST* then_ptr,
+ StatementListAST* else_ptr);
+
+ // Destructor
+ ~IfStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ IfStatementAST(const IfStatementAST& obj);
+ IfStatementAST& operator=(const IfStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ ExprAST* m_cond_ptr;
+ StatementListAST* m_then_ptr;
+ StatementListAST* m_else_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const IfStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const IfStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //IFSTATEMENTAST_H
diff --git a/src/mem/slicc/ast/InPortDeclAST.cc b/src/mem/slicc/ast/InPortDeclAST.cc
new file mode 100644
index 000000000..6b13fec51
--- /dev/null
+++ b/src/mem/slicc/ast/InPortDeclAST.cc
@@ -0,0 +1,149 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * InPortDeclAST.C
+ *
+ * Description: See InPortDeclAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "InPortDeclAST.hh"
+#include "SymbolTable.hh"
+#include "Var.hh"
+
+InPortDeclAST::InPortDeclAST(string* ident_ptr,
+ TypeAST* msg_type_ptr,
+ ExprAST* var_expr_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_ident_ptr = ident_ptr;
+ m_msg_type_ptr = msg_type_ptr;
+ m_var_expr_ptr = var_expr_ptr;
+ m_statement_list_ptr = statement_list_ptr;
+ m_queue_type_ptr = new TypeAST(new string("InPort"));
+}
+
+InPortDeclAST::~InPortDeclAST()
+{
+ delete m_ident_ptr;
+ delete m_msg_type_ptr;
+ delete m_var_expr_ptr;
+ delete m_statement_list_ptr;
+ delete m_queue_type_ptr;
+}
+
+void InPortDeclAST::generate()
+{
+ string code;
+ Type* queue_type_ptr = m_var_expr_ptr->generate(code);
+ if (!queue_type_ptr->isInPort()) {
+ error("Inport queues must be of a type that has the 'inport' attribute. The type '" +
+ queue_type_ptr->toString() + "' does not have this attribute.");
+ }
+
+ Type* type_ptr = m_queue_type_ptr->lookupType();
+ Var* in_port_ptr = new Var(*m_ident_ptr, getLocation(), type_ptr, code, getPairs());
+ g_sym_table.newSym(in_port_ptr);
+
+ g_sym_table.pushFrame();
+ Vector<Type*> param_type_vec;
+
+ // Check for Event
+ type_ptr = g_sym_table.getType("Event");
+ if (type_ptr == NULL) {
+ error("in_port declarations require 'Event' enumeration to be defined");
+ }
+ param_type_vec.insertAtBottom(type_ptr);
+
+ // Check for Address
+ type_ptr = g_sym_table.getType("Address");
+ if (type_ptr == NULL) {
+ error("in_port declarations require 'Address' type to be defined");
+ }
+ param_type_vec.insertAtBottom(type_ptr);
+
+ // Add the trigger method - FIXME, this is a bit dirty
+ Map<string, string> pairs;
+ pairs.add("external", "yes");
+ Vector<string> string_vec;
+ g_sym_table.newSym(new Func("trigger", getLocation(), g_sym_table.getType("void"), param_type_vec, string_vec, string(""), pairs, NULL));
+
+ // Check for Event2
+ type_ptr = g_sym_table.getType("Event");
+ if (type_ptr == NULL) {
+ error("in_port declarations require 'Event' enumeration to be defined");
+ }
+ param_type_vec.insertAtBottom(type_ptr);
+
+ // Check for Address2
+ type_ptr = g_sym_table.getType("Address");
+ if (type_ptr == NULL) {
+ error("in_port declarations require 'Address' type to be defined");
+ }
+ param_type_vec.insertAtBottom(type_ptr);
+
+ // Add the doubleTrigger method - this hack supports tiggering two simulateous events
+ // The key is that the second transistion cannot fail because the first event cannot be undone
+ // therefore you must do some checks before calling double trigger to ensure that won't happen
+ g_sym_table.newSym(new Func("doubleTrigger", getLocation(), g_sym_table.getType("void"), param_type_vec, string_vec, string(""), pairs, NULL));
+
+ // Add the continueProcessing method - this hack supports messages that don't trigger events
+ Vector<Type*> empty_param_type_vec;
+ Vector<string> empty_string_vec;
+ g_sym_table.newSym(new Func("continueProcessing", getLocation(), g_sym_table.getType("void"), empty_param_type_vec, empty_string_vec, string(""), pairs, NULL));
+
+ if (m_statement_list_ptr != NULL) {
+ inc_indent();
+ inc_indent();
+ string code;
+ m_statement_list_ptr->generate(code, NULL);
+ in_port_ptr->addPair("c_code_in_port", code);
+ dec_indent();
+ dec_indent();
+ }
+ g_sym_table.popFrame();
+
+ // Add port to state machine
+ StateMachine* machine_ptr = g_sym_table.getStateMachine();
+ if (machine_ptr == NULL) {
+ error("InPort declaration not part of a machine.");
+ }
+ machine_ptr->addInPort(in_port_ptr);
+}
+
+
+void InPortDeclAST::print(ostream& out) const
+{
+ out << "[InPortDecl: " << *m_ident_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/InPortDeclAST.hh b/src/mem/slicc/ast/InPortDeclAST.hh
new file mode 100644
index 000000000..4f3c25f93
--- /dev/null
+++ b/src/mem/slicc/ast/InPortDeclAST.hh
@@ -0,0 +1,91 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * InPortDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: InPortDeclAST.h,v 3.2 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#ifndef InPortDeclAST_H
+#define InPortDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "StatementListAST.hh"
+#include "VarExprAST.hh"
+
+class InPortDeclAST : public DeclAST {
+public:
+ // Constructors
+ InPortDeclAST(string* ident_ptr,
+ TypeAST* msg_type_ptr,
+ ExprAST* var_expr_ptr,
+ PairListAST* pairs_ptr,
+ StatementListAST* statement_list_ptr);
+
+ // Destructor
+ ~InPortDeclAST();
+
+ // Public Methods
+ void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ InPortDeclAST(const InPortDeclAST& obj);
+ InPortDeclAST& operator=(const InPortDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+ TypeAST* m_msg_type_ptr;
+ ExprAST* m_var_expr_ptr;
+ StatementListAST* m_statement_list_ptr;
+ TypeAST* m_queue_type_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const InPortDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const InPortDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //InPortDeclAST_H
diff --git a/src/mem/slicc/ast/InfixOperatorExprAST.cc b/src/mem/slicc/ast/InfixOperatorExprAST.cc
new file mode 100644
index 000000000..ba3aa1245
--- /dev/null
+++ b/src/mem/slicc/ast/InfixOperatorExprAST.cc
@@ -0,0 +1,121 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * InfixOperatorExprAST.C
+ *
+ * Description: See InfixOperatorExprAST.h
+ *
+ * $Id: InfixOperatorExprAST.C,v 3.2 2004/01/31 20:46:15 milo Exp $
+ *
+ */
+
+#include "InfixOperatorExprAST.hh"
+
+InfixOperatorExprAST::InfixOperatorExprAST(ExprAST* left_ptr,
+ string* op_ptr,
+ ExprAST* right_ptr)
+ : ExprAST()
+{
+ m_left_ptr = left_ptr;
+ m_op_ptr = op_ptr;
+ m_right_ptr = right_ptr;
+}
+
+InfixOperatorExprAST::~InfixOperatorExprAST()
+{
+ delete m_left_ptr;
+ delete m_op_ptr;
+ delete m_right_ptr;
+}
+
+Type* InfixOperatorExprAST::generate(string& code) const
+{
+ code += "(";
+ Type* left_type_ptr = m_left_ptr->generate(code);
+ code += " " + *m_op_ptr + " ";
+ Type* right_type_ptr = m_right_ptr->generate(code);
+ code += ")";
+
+ string inputs, output;
+ // Figure out what the input and output types should be
+ if ((*m_op_ptr == "==" ||
+ *m_op_ptr == "!=")) {
+ output = "bool";
+ if (left_type_ptr != right_type_ptr) {
+ error("Type mismatch: left & right operand of operator '" + *m_op_ptr +
+ "' must be the same type." +
+ "left: '" + left_type_ptr->toString() +
+ "', right: '" + right_type_ptr->toString() + "'");
+ }
+ } else {
+ if ((*m_op_ptr == "&&" ||
+ *m_op_ptr == "||")) {
+ // boolean inputs and output
+ inputs = "bool";
+ output = "bool";
+ } else if ((*m_op_ptr == "==" ||
+ *m_op_ptr == "!=" ||
+ *m_op_ptr == ">=" ||
+ *m_op_ptr == "<=" ||
+ *m_op_ptr == ">" ||
+ *m_op_ptr == "<")) {
+ // Integer inputs, boolean output
+ inputs = "int";
+ output = "bool";
+ } else {
+ // integer inputs and output
+ inputs = "int";
+ output = "int";
+ }
+
+ Type* inputs_type = g_sym_table.getType(inputs);
+
+ if (inputs_type != left_type_ptr) {
+ m_left_ptr->error("Type mismatch: left operand of operator '" + *m_op_ptr +
+ "' expects input type '" + inputs + "', actual was " + left_type_ptr->toString() + "'");
+ }
+
+ if (inputs_type != right_type_ptr) {
+ m_right_ptr->error("Type mismatch: right operand of operator '" + *m_op_ptr +
+ "' expects input type '" + inputs + "', actual was '" + right_type_ptr->toString() + "'");
+ }
+ }
+
+ // All is well
+ Type* output_type = g_sym_table.getType(output);
+ return output_type;
+}
+
+
+void InfixOperatorExprAST::print(ostream& out) const
+{
+ out << "[InfixExpr: " << *m_left_ptr
+ << *m_op_ptr << *m_right_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/InfixOperatorExprAST.hh b/src/mem/slicc/ast/InfixOperatorExprAST.hh
new file mode 100644
index 000000000..451156f6d
--- /dev/null
+++ b/src/mem/slicc/ast/InfixOperatorExprAST.hh
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * InfixOperatorExprAST.h
+ *
+ * Description:
+ *
+ * $Id: InfixOperatorExprAST.h,v 3.1 2001/12/12 01:00:19 milo Exp $
+ *
+ */
+
+#ifndef INFIXOPERATOREXPRAST_H
+#define INFIXOPERATOREXPRAST_H
+
+#include "slicc_global.hh"
+#include "ExprAST.hh"
+
+
+class InfixOperatorExprAST : public ExprAST {
+public:
+ // Constructors
+ InfixOperatorExprAST(ExprAST* left_ptr, string* op_ptr, ExprAST* right_ptr);
+
+ // Destructor
+ ~InfixOperatorExprAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ InfixOperatorExprAST(const InfixOperatorExprAST& obj);
+ InfixOperatorExprAST& operator=(const InfixOperatorExprAST& obj);
+
+ // Data Members (m_ prefix)
+ ExprAST* m_left_ptr;
+ string* m_op_ptr;
+ ExprAST* m_right_ptr;
+
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const InfixOperatorExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const InfixOperatorExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //INFIXOPERATOREXPRAST_H
diff --git a/src/mem/slicc/ast/LiteralExprAST.cc b/src/mem/slicc/ast/LiteralExprAST.cc
new file mode 100644
index 000000000..b3b415bc9
--- /dev/null
+++ b/src/mem/slicc/ast/LiteralExprAST.cc
@@ -0,0 +1,55 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * LiteralExprAST.C
+ *
+ * Description: See LiteralExprAST.h
+ *
+ * $Id: LiteralExprAST.C,v 3.1 2002/10/22 21:27:52 milo Exp $
+ *
+ */
+
+#include "LiteralExprAST.hh"
+
+Type* LiteralExprAST::generate(string& code) const
+{
+ if (m_type == "string") {
+ code += "(\"" + *m_lit_ptr + "\")";
+ } else {
+ code += "(" + *m_lit_ptr + ")";
+ }
+
+ Type* type_ptr = g_sym_table.getType(m_type);
+ if (type_ptr == NULL) {
+ // Can't find the type
+ error("Internal: can't primitive type '" + m_type + "'");
+ }
+ return type_ptr;
+}
diff --git a/src/mem/slicc/ast/LiteralExprAST.hh b/src/mem/slicc/ast/LiteralExprAST.hh
new file mode 100644
index 000000000..be433a1e3
--- /dev/null
+++ b/src/mem/slicc/ast/LiteralExprAST.hh
@@ -0,0 +1,83 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * LiteralExprAST.h
+ *
+ * Description:
+ *
+ * $Id: LiteralExprAST.h,v 3.1 2001/12/12 01:00:20 milo Exp $
+ *
+ */
+
+#ifndef LITERALEXPRAST_H
+#define LITERALEXPRAST_H
+
+#include "slicc_global.hh"
+#include "ExprAST.hh"
+
+
+class LiteralExprAST : public ExprAST {
+public:
+ // Constructors
+ LiteralExprAST(string* lit_ptr, string type) : ExprAST() { m_lit_ptr = lit_ptr; m_type = type; }
+
+ // Destructor
+ ~LiteralExprAST() { delete m_lit_ptr; }
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void print(ostream& out) const { out << "[Literal: " << *m_lit_ptr << "]"; }
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ LiteralExprAST(const LiteralExprAST& obj);
+ LiteralExprAST& operator=(const LiteralExprAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_lit_ptr;
+ string m_type;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const LiteralExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const LiteralExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //LITERALEXPRAST_H
diff --git a/src/mem/slicc/ast/Location.cc b/src/mem/slicc/ast/Location.cc
new file mode 100644
index 000000000..91b8dbd28
--- /dev/null
+++ b/src/mem/slicc/ast/Location.cc
@@ -0,0 +1,83 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Location.C
+ *
+ * Description: See Location.h
+ *
+ * $Id: Location.C,v 3.3 2004/05/30 22:19:02 kmoore Exp $
+ *
+ */
+
+#include "Location.hh"
+
+int g_line_number = 0;
+string g_file_name("");
+
+Location::Location()
+{
+ m_file_name = g_file_name;
+ m_line_number = g_line_number;
+
+ ostringstream sstr;
+ sstr << getLineNumber();
+ m_line_number_str = sstr.str();
+}
+
+void Location::error(string err_msg) const
+{
+ cerr << endl;
+ cerr << toString() << ": Error: " << err_msg << endl;
+ exit(1);
+}
+
+string Location::embedError(string err_msg) const
+{
+ string code;
+ code += "cerr << \"Runtime Error at ";
+ code += toString() + ", Ruby Time: \" << ";
+ code += "g_eventQueue_ptr->getTime() << \": \" << ";
+ code += err_msg;
+ code += " << \", PID: \" << getpid() << endl;\n";
+ code += "char c; cerr << \"press return to continue.\" << endl; cin.get(c); abort();\n";
+
+ return code;
+}
+
+void Location::warning(string err_msg) const
+{
+ cerr << toString() << ": Warning: "
+ << err_msg << endl;
+}
+
+string Location::toString() const
+{
+ return m_file_name + ":" + m_line_number_str;
+}
diff --git a/src/mem/slicc/ast/Location.hh b/src/mem/slicc/ast/Location.hh
new file mode 100644
index 000000000..6cf2df5a4
--- /dev/null
+++ b/src/mem/slicc/ast/Location.hh
@@ -0,0 +1,93 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Location.h
+ *
+ * Description:
+ *
+ * $Id: Location.h,v 3.1 2001/12/12 01:00:20 milo Exp $
+ *
+ */
+
+#ifndef LOCATION_H
+#define LOCATION_H
+
+#include "slicc_global.hh"
+
+extern int g_line_number;
+extern string g_file_name;
+
+class Location {
+public:
+ // Constructors
+ Location();
+
+ // Destructor
+ //~Location();
+
+ // Public Methods
+
+ void print(ostream& out) const;
+ void error(string err_msg) const;
+ string embedError(string err_msg) const;
+ void warning(string err_msg) const;
+ string toString() const;
+
+private:
+ // Private Methods
+ const string& getFileName() const { return m_file_name; }
+ int getLineNumber() const { return m_line_number; }
+ string getLineNumberStr() const { return m_line_number_str; }
+
+ // Private copy constructor and assignment operator
+ //Location(const Location& obj);
+ //Location& operator=(const Location& obj);
+
+ // Data Members (m_ prefix)
+ string m_file_name;
+ int m_line_number;
+ string m_line_number_str;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const Location& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const Location& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //LOCATION_H
diff --git a/src/mem/slicc/ast/MachineAST.cc b/src/mem/slicc/ast/MachineAST.cc
new file mode 100644
index 000000000..3ee97bc38
--- /dev/null
+++ b/src/mem/slicc/ast/MachineAST.cc
@@ -0,0 +1,96 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * MachineAST.C
+ *
+ * Description: See MachineAST.h
+ *
+ * $Id: MachineAST.C,v 3.1 2003/03/17 01:54:25 xu Exp $
+ *
+ */
+
+#include "MachineAST.hh"
+#include "SymbolTable.hh"
+
+MachineAST::MachineAST(string* ident_ptr,
+ PairListAST* pairs_ptr,
+ DeclListAST* decl_list_ptr)
+
+ : DeclAST(pairs_ptr)
+{
+ m_ident_ptr = ident_ptr;
+ m_pairs_ptr = pairs_ptr;
+ m_decl_list_ptr = decl_list_ptr;
+}
+
+MachineAST::~MachineAST()
+{
+ delete m_ident_ptr;
+ delete m_pairs_ptr;
+ delete m_decl_list_ptr;
+}
+
+void MachineAST::generate()
+{
+ StateMachine* machine_ptr;
+
+ // Make a new frame
+ g_sym_table.pushFrame();
+
+ // Create a new machine
+ machine_ptr = new StateMachine(*m_ident_ptr, getLocation(), getPairs());
+ g_sym_table.newCurrentMachine(machine_ptr);
+
+ // Generate code for all the internal decls
+ m_decl_list_ptr->generate();
+
+ // Build the transition table
+ machine_ptr->buildTable();
+
+ // Pop the frame
+ g_sym_table.popFrame();
+}
+
+void MachineAST::findMachines()
+{
+ // Add to MachineType enumeration
+ Type* type_ptr = g_sym_table.getType("MachineType");
+ if (!type_ptr->enumAdd(*m_ident_ptr, m_pairs_ptr->getPairs())) {
+ error("Duplicate machine name: " + type_ptr->toString() + ":" + *m_ident_ptr);
+ }
+
+ // Generate code for all the internal decls
+ m_decl_list_ptr->findMachines();
+}
+
+void MachineAST::print(ostream& out) const
+{
+ out << "[Machine: " << *m_ident_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/MachineAST.hh b/src/mem/slicc/ast/MachineAST.hh
new file mode 100644
index 000000000..c05bcc5f2
--- /dev/null
+++ b/src/mem/slicc/ast/MachineAST.hh
@@ -0,0 +1,88 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ActionDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: MachineAST.h,v 3.2 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#ifndef MachineAST_H
+#define MachineAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "DeclListAST.hh"
+#include "StateMachine.hh"
+
+class MachineAST : public DeclAST {
+public:
+ // Constructors
+ MachineAST(string* ident_ptr,
+ PairListAST* pairs_ptr,
+ DeclListAST* decl_list_ptr);
+
+ // Destructor
+ ~MachineAST();
+
+ // Public Methods
+ void print(ostream& out) const;
+ void generate();
+ void findMachines();
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ MachineAST(const MachineAST& obj);
+ MachineAST& operator=(const MachineAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+ DeclListAST* m_decl_list_ptr;
+ PairListAST* m_pairs_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const MachineAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const MachineAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //MachineAST_H
diff --git a/src/mem/slicc/ast/MemberExprAST.cc b/src/mem/slicc/ast/MemberExprAST.cc
new file mode 100644
index 000000000..c4e9ce24b
--- /dev/null
+++ b/src/mem/slicc/ast/MemberExprAST.cc
@@ -0,0 +1,72 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * FieldExprAST.C
+ *
+ * Description: See FieldExprAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "MemberExprAST.hh"
+
+MemberExprAST::MemberExprAST(ExprAST* expr_ast_ptr, string* field_ptr)
+ : ExprAST()
+{
+ m_expr_ast_ptr = expr_ast_ptr;
+ m_field_ptr = field_ptr;
+}
+
+MemberExprAST::~MemberExprAST()
+{
+ delete m_expr_ast_ptr;
+ delete m_field_ptr;
+}
+
+Type* MemberExprAST::generate(string& code) const
+{
+ code += "(";
+ Type* type_ptr = m_expr_ast_ptr->generate(code);
+ code += ").m_" + (*m_field_ptr);
+
+ // Verify that this is a valid field name for this type
+ if (!type_ptr->dataMemberExist(*m_field_ptr)) {
+ error("Invalid object field: Type '" + type_ptr->toString() + "' does not have data member " + *m_field_ptr);
+ }
+
+ // Return the type of the field
+ return type_ptr->dataMemberType(*m_field_ptr);
+}
+
+void MemberExprAST::print(ostream& out) const
+{
+ out << "[MemberExprAST: " << *m_expr_ast_ptr << "." << *m_field_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/MemberExprAST.hh b/src/mem/slicc/ast/MemberExprAST.hh
new file mode 100644
index 000000000..c5fd3d0dd
--- /dev/null
+++ b/src/mem/slicc/ast/MemberExprAST.hh
@@ -0,0 +1,83 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * MemberExprAST.h
+ *
+ * Description:
+ *
+ * $Id: MemberExprAST.h,v 3.1 2001/12/12 01:00:21 milo Exp $
+ *
+ */
+
+#ifndef MemberExprAST_H
+#define MemberExprAST_H
+
+#include "slicc_global.hh"
+#include "ExprAST.hh"
+
+
+class MemberExprAST : public ExprAST {
+public:
+ // Constructors
+ MemberExprAST(ExprAST* expr_ast_ptr, string* field_ptr);
+
+ // Destructor
+ ~MemberExprAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ MemberExprAST(const MemberExprAST& obj);
+ MemberExprAST& operator=(const MemberExprAST& obj);
+
+ // Data Members (m_ prefix)
+ ExprAST* m_expr_ast_ptr;
+ string* m_field_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const MemberExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const MemberExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //MemberExprAST_H
diff --git a/src/mem/slicc/ast/MethodCallExprAST.cc b/src/mem/slicc/ast/MethodCallExprAST.cc
new file mode 100644
index 000000000..fe6505a1a
--- /dev/null
+++ b/src/mem/slicc/ast/MethodCallExprAST.cc
@@ -0,0 +1,150 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * MethodCallExprAST.C
+ *
+ * Description: See MethodCallExprAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "MethodCallExprAST.hh"
+
+MethodCallExprAST::MethodCallExprAST(ExprAST* obj_expr_ptr,
+ string* proc_name_ptr,
+ Vector<ExprAST*>* expr_vec_ptr)
+ : ExprAST()
+{
+ m_obj_expr_ptr = obj_expr_ptr;
+ m_type_ptr = NULL;
+ m_proc_name_ptr = proc_name_ptr;
+ m_expr_vec_ptr = expr_vec_ptr;
+}
+
+MethodCallExprAST::MethodCallExprAST(TypeAST* type_ptr,
+ string* proc_name_ptr,
+ Vector<ExprAST*>* expr_vec_ptr)
+ : ExprAST()
+{
+ m_obj_expr_ptr = NULL;
+ m_type_ptr = type_ptr;
+ m_proc_name_ptr = proc_name_ptr;
+ m_expr_vec_ptr = expr_vec_ptr;
+}
+
+MethodCallExprAST::~MethodCallExprAST()
+{
+ delete m_obj_expr_ptr;
+ delete m_type_ptr;
+ delete m_proc_name_ptr;
+ int size = m_expr_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_expr_vec_ptr)[i];
+ }
+ delete m_expr_vec_ptr;
+}
+
+Type* MethodCallExprAST::generate(string& code) const
+{
+ Type* obj_type_ptr = NULL;
+
+ if(m_obj_expr_ptr) {
+ // member method call
+ code += "((";
+ obj_type_ptr = m_obj_expr_ptr->generate(code);
+
+ code += ").";
+ } else if (m_type_ptr) {
+ // class method call
+ code += "(" + m_type_ptr->toString() + "::";
+ obj_type_ptr = m_type_ptr->lookupType();
+ } else {
+ // impossible
+ assert(0);
+ }
+
+ Vector <Type*> paramTypes;
+
+ // generate code
+ int actual_size = m_expr_vec_ptr->size();
+ code += (*m_proc_name_ptr) + "(";
+ for(int i=0; i<actual_size; i++) {
+ if (i != 0) {
+ code += ", ";
+ }
+ // Check the types of the parameter
+ Type* actual_type_ptr = (*m_expr_vec_ptr)[i]->generate(code);
+ paramTypes.insertAtBottom(actual_type_ptr);
+ }
+ code += "))";
+
+ string methodId = obj_type_ptr->methodId(*m_proc_name_ptr, paramTypes);
+
+ // Verify that this is a method of the object
+ if (!obj_type_ptr->methodExist(methodId)) {
+ error("Invalid method call: Type '" + obj_type_ptr->toString() + "' does not have a method '" + methodId + "'");
+ }
+
+ int expected_size = obj_type_ptr->methodParamType(methodId).size();
+ if (actual_size != expected_size) {
+ // Right number of parameters
+ ostringstream err;
+ err << "Wrong number of parameters for function name: '" << *m_proc_name_ptr << "'";
+ err << ", expected: ";
+ err << expected_size;
+ err << ", actual: ";
+ err << actual_size;
+ error(err.str());
+ }
+
+ for(int i=0; i<actual_size; i++) {
+ // Check the types of the parameter
+ Type* actual_type_ptr = paramTypes[i];
+ Type* expected_type_ptr = obj_type_ptr->methodParamType(methodId)[i];
+ if (actual_type_ptr != expected_type_ptr) {
+ (*m_expr_vec_ptr)[i]->error("Type mismatch: expected: " + expected_type_ptr->toString() +
+ " actual: " + actual_type_ptr->toString());
+ }
+ }
+
+ // Return the return type of the method
+ return obj_type_ptr->methodReturnType(methodId);
+}
+
+void MethodCallExprAST::findResources(Map<Var*, string>& resource_list) const
+{
+
+}
+
+void MethodCallExprAST::print(ostream& out) const
+{
+ out << "[MethodCallExpr: " << *m_proc_name_ptr << *m_obj_expr_ptr << " " << *m_expr_vec_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/MethodCallExprAST.hh b/src/mem/slicc/ast/MethodCallExprAST.hh
new file mode 100644
index 000000000..22766e922
--- /dev/null
+++ b/src/mem/slicc/ast/MethodCallExprAST.hh
@@ -0,0 +1,93 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * MethodCallExprAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef MethodCallExprAST_H
+#define MethodCallExprAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "ExprAST.hh"
+#include "TypeAST.hh"
+
+class MethodCallExprAST : public ExprAST {
+public:
+ // Constructors
+ MethodCallExprAST(ExprAST* m_obj_expr_ptr,
+ string* proc_name_ptr,
+ Vector<ExprAST*>* expr_vec_ptr);
+
+ MethodCallExprAST(TypeAST* type_ptr,
+ string* proc_name_ptr,
+ Vector<ExprAST*>* expr_vec_ptr);
+
+ // Destructor
+ ~MethodCallExprAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ MethodCallExprAST(const MethodCallExprAST& obj);
+ MethodCallExprAST& operator=(const MethodCallExprAST& obj);
+
+ // Data Members (m_ prefix)
+ ExprAST* m_obj_expr_ptr;
+ TypeAST* m_type_ptr;
+ string* m_proc_name_ptr;
+ Vector<ExprAST*>* m_expr_vec_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const MethodCallExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const MethodCallExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif // MethodCallExprAST_H
diff --git a/src/mem/slicc/ast/ObjDeclAST.cc b/src/mem/slicc/ast/ObjDeclAST.cc
new file mode 100644
index 000000000..106c18cac
--- /dev/null
+++ b/src/mem/slicc/ast/ObjDeclAST.cc
@@ -0,0 +1,148 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ObjDeclAST.C
+ *
+ * Description: See ObjDeclAST.h
+ *
+ * $Id: ObjDeclAST.C,v 3.13 2004/06/24 15:56:14 beckmann Exp $
+ *
+ */
+
+#include "ObjDeclAST.hh"
+#include "SymbolTable.hh"
+#include "main.hh"
+
+ObjDeclAST::ObjDeclAST(TypeAST* type_ptr,
+ string* ident_ptr,
+ PairListAST* pairs_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_type_ptr = type_ptr;
+ m_ident_ptr = ident_ptr;
+}
+
+ObjDeclAST::~ObjDeclAST()
+{
+ delete m_type_ptr;
+ delete m_ident_ptr;
+}
+
+void ObjDeclAST::generate()
+{
+
+ bool machineComponentSym = false;
+
+ getPairs().add("chip_object", "yes");
+
+ string c_code;
+
+
+ if (getPairs().exist("hack")) {
+ warning("'hack=' is now deprecated");
+ }
+
+ if (getPairs().exist("network")) {
+ if (!getPairs().exist("virtual_network")) {
+ error("Network queues require a 'virtual_network' attribute.");
+ }
+ }
+
+ Type* type_ptr = m_type_ptr->lookupType();
+ if (type_ptr->isBuffer()) {
+ if (!getPairs().exist("ordered")) {
+ error("Buffer object declarations require an 'ordered' attribute.");
+ }
+ }
+
+ if (getPairs().exist("ordered")) {
+ string value = getPairs().lookup("ordered");
+ if (value != "true" && value != "false") {
+ error("The 'ordered' attribute must be 'true' or 'false'.");
+ }
+ }
+
+ if (getPairs().exist("random")) {
+ string value = getPairs().lookup("random");
+ if (value != "true" && value != "false") {
+ error("The 'random' attribute must be 'true' or 'false'.");
+ }
+ }
+
+ string machine;
+ if (g_sym_table.getStateMachine() != NULL) {
+ machine = g_sym_table.getStateMachine()->getIdent() + "_";
+ }
+
+ // FIXME : should all use accessors here to avoid public member variables
+ if (*m_ident_ptr == "id") {
+ c_code = "m_chip_ptr->getID()";
+ } else if (*m_ident_ptr == "version") {
+ c_code = "m_version";
+ } else if (*m_ident_ptr == "machineID") {
+ c_code = "m_machineID";
+ } else if (*m_ident_ptr == "sequencer") {
+ c_code = "*(dynamic_cast<"+m_type_ptr->toString()+"*>(m_chip_ptr->getSequencer(m_version)))";
+ machineComponentSym = true;
+ } /*else if (*m_ident_ptr == "xfdr_record_mgr") {
+ c_code = "*(dynamic_cast<"+m_type_ptr->toString()+"*>(m_chip_ptr->getXfdrManager(m_version)))";
+ machineComponentSym = true;
+ } */else if (// getPairs().exist("network") || (m_type_ptr->lookupType()->existPair("cache"))
+// || (m_type_ptr->lookupType()->existPair("tbe")) ||
+// (m_type_ptr->lookupType()->existPair("newtbe")) ||
+// (m_type_ptr->lookupType()->existPair("timer")) ||
+// (m_type_ptr->lookupType()->existPair("dir")) ||
+// (m_type_ptr->lookupType()->existPair("persistent")) ||
+// (m_type_ptr->lookupType()->existPair("filter")) ||
+// (getPairs().exist("trigger_queue"))
+ getPairs().exist("no_vector")) {
+ c_code = "(*(m_chip_ptr->m_" + machine + *m_ident_ptr + "_ptr))";
+ machineComponentSym = true;
+ } else {
+ c_code = "(*(m_chip_ptr->m_" + machine + *m_ident_ptr + "_vec[m_version]))";
+ machineComponentSym = true;
+ }
+
+ Var* v = new Var(*m_ident_ptr, getLocation(), type_ptr, c_code,
+ getPairs(), g_sym_table.getStateMachine());
+
+ g_sym_table.newSym(v);
+
+ // used to cheat-- that is, access components in other machines
+ if (machineComponentSym) {
+ g_sym_table.newMachComponentSym(v);
+ }
+
+}
+
+void ObjDeclAST::print(ostream& out) const
+{
+ out << "[ObjDecl: " << *m_ident_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/ObjDeclAST.hh b/src/mem/slicc/ast/ObjDeclAST.hh
new file mode 100644
index 000000000..2d4ac9714
--- /dev/null
+++ b/src/mem/slicc/ast/ObjDeclAST.hh
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ObjDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: ObjDeclAST.h,v 3.2 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#ifndef ObjDeclAST_H
+#define ObjDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "TypeFieldAST.hh"
+#include "TypeAST.hh"
+
+class ObjDeclAST : public DeclAST {
+public:
+ // Constructors
+ ObjDeclAST(TypeAST* type_ptr,
+ string* ident_ptr,
+ PairListAST* pairs_ptr);
+
+ // Destructor
+ ~ObjDeclAST();
+
+ // Public Methods
+ void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ ObjDeclAST(const ObjDeclAST& obj);
+ ObjDeclAST& operator=(const ObjDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+ TypeAST* m_type_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const ObjDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const ObjDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //ObjDeclAST_H
diff --git a/src/mem/slicc/ast/OutPortDeclAST.cc b/src/mem/slicc/ast/OutPortDeclAST.cc
new file mode 100644
index 000000000..1aa0363aa
--- /dev/null
+++ b/src/mem/slicc/ast/OutPortDeclAST.cc
@@ -0,0 +1,79 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * OutPortDeclAST.C
+ *
+ * Description: See OutPortDeclAST.h
+ *
+ * $Id: OutPortDeclAST.C,v 3.3 2004/02/02 22:37:51 milo Exp $
+ *
+ */
+
+#include "OutPortDeclAST.hh"
+#include "SymbolTable.hh"
+
+OutPortDeclAST::OutPortDeclAST(string* ident_ptr,
+ TypeAST* msg_type_ptr,
+ ExprAST* var_expr_ptr,
+ PairListAST* pairs_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_ident_ptr = ident_ptr;
+ m_msg_type_ptr = msg_type_ptr;
+ m_var_expr_ptr = var_expr_ptr;
+ m_queue_type_ptr = new TypeAST(new string("OutPort"));
+}
+
+OutPortDeclAST::~OutPortDeclAST()
+{
+ delete m_ident_ptr;
+ delete m_msg_type_ptr;
+ delete m_var_expr_ptr;
+ delete m_queue_type_ptr;
+}
+
+void OutPortDeclAST::generate()
+{
+ string code;
+ Type* queue_type_ptr = m_var_expr_ptr->generate(code);
+ if (!queue_type_ptr->isOutPort()) {
+ error("Outport queues must be of a type that has the 'outport' attribute. The type '" +
+ queue_type_ptr->toString() + "' does not have this attribute.");
+ }
+
+ Type* type_ptr = m_queue_type_ptr->lookupType();
+ g_sym_table.newSym(new Var(*m_ident_ptr, getLocation(), type_ptr, code, getPairs()));
+}
+
+
+void OutPortDeclAST::print(ostream& out) const
+{
+ out << "[OutPortDecl: " << *m_ident_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/OutPortDeclAST.hh b/src/mem/slicc/ast/OutPortDeclAST.hh
new file mode 100644
index 000000000..3fcd755ef
--- /dev/null
+++ b/src/mem/slicc/ast/OutPortDeclAST.hh
@@ -0,0 +1,89 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * OutPortDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: OutPortDeclAST.h,v 3.2 2003/07/10 18:08:06 milo Exp $
+ *
+ */
+
+#ifndef OutPortDeclAST_H
+#define OutPortDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "StatementListAST.hh"
+#include "VarExprAST.hh"
+
+class OutPortDeclAST : public DeclAST {
+public:
+ // Constructors
+ OutPortDeclAST(string* ident_ptr,
+ TypeAST* msg_type_ptr,
+ ExprAST* var_expr_ptr,
+ PairListAST* pairs_ptr);
+
+ // Destructor
+ ~OutPortDeclAST();
+
+ // Public Methods
+ void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ OutPortDeclAST(const OutPortDeclAST& obj);
+ OutPortDeclAST& operator=(const OutPortDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+ TypeAST* m_msg_type_ptr;
+ TypeAST* m_queue_type_ptr;
+ ExprAST* m_var_expr_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const OutPortDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const OutPortDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //OutPortDeclAST_H
diff --git a/src/mem/slicc/ast/PairAST.cc b/src/mem/slicc/ast/PairAST.cc
new file mode 100644
index 000000000..da71bdd01
--- /dev/null
+++ b/src/mem/slicc/ast/PairAST.cc
@@ -0,0 +1,72 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * PairAST.C
+ *
+ * Description: See PairAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "PairAST.hh"
+
+PairAST::PairAST(string* key_ptr, string* value_ptr)
+ : AST()
+{
+ m_key_ptr = key_ptr;
+ m_value_ptr = value_ptr;
+}
+
+PairAST::PairAST(string key, string* value_ptr)
+ : AST()
+{
+ m_key_ptr = new string(key);
+ m_value_ptr = value_ptr;
+}
+
+PairAST::PairAST(string key, string value)
+ : AST()
+{
+ m_key_ptr = new string(key);
+ m_value_ptr = new string(value);
+}
+
+PairAST::~PairAST()
+{
+ delete m_key_ptr;
+ delete m_value_ptr;
+}
+
+void PairAST::print(ostream& out) const
+{
+ out << "[" << *m_key_ptr << "=" << *m_value_ptr << "]" << endl;
+}
+
diff --git a/src/mem/slicc/ast/PairAST.hh b/src/mem/slicc/ast/PairAST.hh
new file mode 100644
index 000000000..4cc297dc1
--- /dev/null
+++ b/src/mem/slicc/ast/PairAST.hh
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * PairAST.h
+ *
+ * Description:
+ *
+ * $Id: PairAST.h,v 3.1 2001/12/12 01:00:24 milo Exp $
+ *
+ */
+
+#ifndef PAIRAST_H
+#define PAIRAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+
+class PairAST : public AST {
+public:
+ // Constructors
+ PairAST(string* key_ptr, string* value_ptr);
+ PairAST(string key, string* value_ptr);
+ PairAST(string key, string value);
+
+ // Destructor
+ ~PairAST();
+
+ // Public Methods
+ string key() const { return *m_key_ptr; }
+ string value() const { return *m_value_ptr; }
+
+ virtual void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ // PairAST(const PairAST& obj);
+ // PairAST& operator=(const PairAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_key_ptr;
+ string* m_value_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const PairAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const PairAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //PAIRAST_H
diff --git a/src/mem/slicc/ast/PairListAST.cc b/src/mem/slicc/ast/PairListAST.cc
new file mode 100644
index 000000000..9af8b3898
--- /dev/null
+++ b/src/mem/slicc/ast/PairListAST.cc
@@ -0,0 +1,49 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * PairListAST.C
+ *
+ * Description: See PairListAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "PairListAST.hh"
+
+void PairListAST::addPair(PairAST* pair_ptr)
+{
+ getPairs().add(pair_ptr->key(), pair_ptr->value());
+}
+
+void PairListAST::print(ostream& out) const
+{
+ out << "[PairListAST] " << getPairs();
+}
diff --git a/src/mem/slicc/ast/PairListAST.hh b/src/mem/slicc/ast/PairListAST.hh
new file mode 100644
index 000000000..9d2700277
--- /dev/null
+++ b/src/mem/slicc/ast/PairListAST.hh
@@ -0,0 +1,82 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * PairListAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef PairListAST_H
+#define PairListAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+#include "PairAST.hh"
+
+
+class PairListAST : public AST {
+public:
+ // Constructors
+ PairListAST() : AST() {}
+
+ // Destructor
+ //~PairListAST();
+
+ // Public Methods
+ void addPair(PairAST* pair_ptr);
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ PairListAST(const PairListAST& obj);
+ PairListAST& operator=(const PairListAST& obj);
+
+ // Data Members (m_ prefix)
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const PairListAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const PairListAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //PairListAST_H
diff --git a/src/mem/slicc/ast/PeekStatementAST.cc b/src/mem/slicc/ast/PeekStatementAST.cc
new file mode 100644
index 000000000..627e85ae8
--- /dev/null
+++ b/src/mem/slicc/ast/PeekStatementAST.cc
@@ -0,0 +1,115 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * PeekStatementAST.C
+ *
+ * Description: See PeekStatementAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "PeekStatementAST.hh"
+#include "SymbolTable.hh"
+#include "StatementListAST.hh"
+#include "TypeAST.hh"
+#include "VarExprAST.hh"
+
+PeekStatementAST::PeekStatementAST(VarExprAST* queue_name_ptr,
+ TypeAST* type_ptr,
+ StatementListAST* statementlist_ptr,
+ string method)
+ : StatementAST()
+{
+ m_queue_name_ptr = queue_name_ptr;
+ m_type_ptr = type_ptr;
+ m_statementlist_ptr = statementlist_ptr;
+ m_method = method;
+}
+
+PeekStatementAST::~PeekStatementAST()
+{
+ delete m_queue_name_ptr;
+ delete m_type_ptr;
+ delete m_statementlist_ptr;
+}
+
+void PeekStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ code += indent_str() + "{\n"; // Start scope
+ inc_indent();
+ g_sym_table.pushFrame();
+
+ Type* msg_type_ptr = m_type_ptr->lookupType();
+
+ // Add new local var to symbol table
+ g_sym_table.newSym(new Var("in_msg", getLocation(), msg_type_ptr, "(*in_msg_ptr)", getPairs()));
+
+ // Check the queue type
+ m_queue_name_ptr->assertType("InPort");
+
+ // Declare the new "in_msg_ptr" variable
+ code += indent_str() + "const " + msg_type_ptr->cIdent() + "* in_msg_ptr;\n"; // Declare message
+ // code += indent_str() + "in_msg_ptr = static_cast<const ";
+ code += indent_str() + "in_msg_ptr = dynamic_cast<const ";
+ code += msg_type_ptr->cIdent() + "*>(";
+ code += "(" + m_queue_name_ptr->getVar()->getCode() + ")";
+ code += ".";
+ code += m_method;
+ code += "());\n";
+
+ code += indent_str() + "assert(in_msg_ptr != NULL);\n"; // Check the cast result
+
+ if(CHECK_INVALID_RESOURCE_STALLS) {
+ // Declare the "in_buffer_rank" variable
+ code += indent_str() + "int in_buffer_rank = "; // Declare message
+ code += "(" + m_queue_name_ptr->getVar()->getCode() + ")";
+ code += ".getPriority();\n";
+ }
+
+ m_statementlist_ptr->generate(code, return_type_ptr); // The other statements
+ dec_indent();
+ g_sym_table.popFrame();
+ code += indent_str() + "}\n"; // End scope
+}
+
+void PeekStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ m_statementlist_ptr->findResources(resource_list);
+}
+
+void PeekStatementAST::print(ostream& out) const
+{
+ out << "[PeekStatementAST: " << m_method
+ << " queue_name: " << *m_queue_name_ptr
+ << " type: " << m_type_ptr->toString()
+ << " " << *m_statementlist_ptr
+ << "]";
+}
diff --git a/src/mem/slicc/ast/PeekStatementAST.hh b/src/mem/slicc/ast/PeekStatementAST.hh
new file mode 100644
index 000000000..e51a0a6a4
--- /dev/null
+++ b/src/mem/slicc/ast/PeekStatementAST.hh
@@ -0,0 +1,91 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * PeekStatementAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef PEEKSTATEMENTAST_H
+#define PEEKSTATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+
+class StatementListAST;
+class TypeAST;
+class VarExprAST;
+
+class PeekStatementAST : public StatementAST {
+public:
+ // Constructors
+ PeekStatementAST(VarExprAST* queue_name_ptr,
+ TypeAST* type_ptr,
+ StatementListAST* statementlist_ptr,
+ string method);
+ // Destructor
+ ~PeekStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ PeekStatementAST(const PeekStatementAST& obj);
+ PeekStatementAST& operator=(const PeekStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ VarExprAST* m_queue_name_ptr;
+ TypeAST* m_type_ptr;
+ StatementListAST* m_statementlist_ptr;
+ string m_method;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const PeekStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const PeekStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //PEEKSTATEMENTAST_H
diff --git a/src/mem/slicc/ast/ReturnStatementAST.cc b/src/mem/slicc/ast/ReturnStatementAST.cc
new file mode 100644
index 000000000..68e81b834
--- /dev/null
+++ b/src/mem/slicc/ast/ReturnStatementAST.cc
@@ -0,0 +1,79 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ReturnStatementAST.C
+ *
+ * Description: See ReturnStatementAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "ReturnStatementAST.hh"
+
+ReturnStatementAST::ReturnStatementAST(ExprAST* expr_ptr)
+ : StatementAST()
+{
+ m_expr_ptr = expr_ptr;
+}
+
+ReturnStatementAST::~ReturnStatementAST()
+{
+ delete m_expr_ptr;
+}
+
+void ReturnStatementAST::generate(string& code, Type* return_type_ptr) const
+{
+ code += indent_str();
+ code += "return ";
+ Type* actual_type_ptr = m_expr_ptr->generate(code);
+ code += ";\n";
+
+ // Is return valid here?
+ if (return_type_ptr == NULL) {
+ error("Invalid 'return' statement");
+ }
+
+ // The return type must match the return_type_ptr
+ if (return_type_ptr != actual_type_ptr) {
+ m_expr_ptr->error("Return type miss-match, expected return type is '" + return_type_ptr->toString() +
+ "', actual is '" + actual_type_ptr->toString() + "'");
+ }
+}
+
+void ReturnStatementAST::findResources(Map<Var*, string>& resource_list) const
+{
+ m_expr_ptr->findResources(resource_list);
+}
+
+void ReturnStatementAST::print(ostream& out) const
+{
+ out << "[ReturnStatementAST: " << *m_expr_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/ReturnStatementAST.hh b/src/mem/slicc/ast/ReturnStatementAST.hh
new file mode 100644
index 000000000..f8c4812cf
--- /dev/null
+++ b/src/mem/slicc/ast/ReturnStatementAST.hh
@@ -0,0 +1,83 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ReturnStatementAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef ReturnStatementAST_H
+#define ReturnStatementAST_H
+
+#include "slicc_global.hh"
+#include "StatementAST.hh"
+#include "ExprAST.hh"
+
+class ReturnStatementAST : public StatementAST {
+public:
+ // Constructors
+ ReturnStatementAST(ExprAST* expr_ptr);
+
+ // Destructor
+ ~ReturnStatementAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ ReturnStatementAST(const ReturnStatementAST& obj);
+ ReturnStatementAST& operator=(const ReturnStatementAST& obj);
+
+ // Data Members (m_ prefix)
+ ExprAST* m_expr_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const ReturnStatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const ReturnStatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //ReturnStatementAST_H
diff --git a/src/mem/slicc/ast/StatementAST.cc b/src/mem/slicc/ast/StatementAST.cc
new file mode 100644
index 000000000..1f3c02474
--- /dev/null
+++ b/src/mem/slicc/ast/StatementAST.cc
@@ -0,0 +1,60 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * StatementAST.C
+ *
+ * Description: See StatementAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "StatementAST.hh"
+
+static int indentation_depth = 1;
+
+void inc_indent()
+{
+ indentation_depth++;
+}
+
+void dec_indent()
+{
+ indentation_depth--;
+}
+
+string indent_str()
+{
+ string temp;
+ for(int i=0; i<indentation_depth; i++) {
+ temp += " ";
+ }
+ return temp;
+}
diff --git a/src/mem/slicc/ast/StatementAST.hh b/src/mem/slicc/ast/StatementAST.hh
new file mode 100644
index 000000000..16a1ecafe
--- /dev/null
+++ b/src/mem/slicc/ast/StatementAST.hh
@@ -0,0 +1,88 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * StatementAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef STATEMENTAST_H
+#define STATEMENTAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+
+void inc_indent();
+void dec_indent();
+string indent_str();
+
+class StatementAST : public AST {
+public:
+ // Constructors
+ StatementAST() : AST() {}
+ StatementAST(Map<string, string> pairs) : AST(pairs) {}
+
+ // Destructor
+ //~StatementAST();
+
+ // Public Methods
+ virtual void generate(string& code, Type* return_type_ptr) const = 0;
+ virtual void findResources(Map<Var*, string>& resource_list) const { }
+
+ //void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ //StatementAST(const StatementAST& obj);
+ //StatementAST& operator=(const StatementAST& obj);
+
+ // Data Members (m_ prefix)
+
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const StatementAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const StatementAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //STATEMENTAST_H
diff --git a/src/mem/slicc/ast/StatementListAST.cc b/src/mem/slicc/ast/StatementListAST.cc
new file mode 100644
index 000000000..f70d5b1fa
--- /dev/null
+++ b/src/mem/slicc/ast/StatementListAST.cc
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * StatementListAST.C
+ *
+ * Description: See StatementListAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "StatementListAST.hh"
+
+StatementListAST::StatementListAST(Vector<StatementAST*>* vec_ptr)
+ : AST()
+{
+ assert(vec_ptr != NULL);
+ m_vec_ptr = vec_ptr;
+}
+
+// Singleton constructor.
+StatementListAST::StatementListAST(StatementAST* statement_ptr)
+ : AST()
+{
+ assert(statement_ptr != NULL);
+ m_vec_ptr = new Vector<StatementAST*>;
+ m_vec_ptr->insertAtTop(statement_ptr);
+}
+
+StatementListAST::~StatementListAST()
+{
+ int size = m_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_vec_ptr)[i];
+ }
+ delete m_vec_ptr;
+}
+
+void StatementListAST::generate(string& code, Type* return_type_ptr) const
+{
+ int size = m_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ (*m_vec_ptr)[i]->generate(code, return_type_ptr);
+ }
+}
+
+void StatementListAST::findResources(Map<Var*, string>& resource_list) const
+{
+ int size = m_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ (*m_vec_ptr)[i]->findResources(resource_list);
+ }
+}
+
+void StatementListAST::print(ostream& out) const
+{
+ assert(m_vec_ptr != NULL);
+ out << "[StatementListAST: " << *m_vec_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/StatementListAST.hh b/src/mem/slicc/ast/StatementListAST.hh
new file mode 100644
index 000000000..3b3968211
--- /dev/null
+++ b/src/mem/slicc/ast/StatementListAST.hh
@@ -0,0 +1,85 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * StatementListAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef STATEMENTLISTAST_H
+#define STATEMENTLISTAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+#include "StatementAST.hh"
+class Var;
+
+class StatementListAST : public AST {
+public:
+ // Constructors
+ StatementListAST(Vector<StatementAST*>* vec_ptr);
+ StatementListAST(StatementAST* statement_ptr);
+
+ // Destructor
+ ~StatementListAST();
+
+ // Public Methods
+ void generate(string& code, Type* return_type_ptr) const;
+ void findResources(Map<Var*, string>& resource_list) const;
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ StatementListAST(const StatementListAST& obj);
+ StatementListAST& operator=(const StatementListAST& obj);
+
+ // Data Members (m_ prefix)
+ Vector<StatementAST*>* m_vec_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const StatementListAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const StatementListAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //STATEMENTLISTAST_H
diff --git a/src/mem/slicc/ast/TransitionDeclAST.cc b/src/mem/slicc/ast/TransitionDeclAST.cc
new file mode 100644
index 000000000..83361e233
--- /dev/null
+++ b/src/mem/slicc/ast/TransitionDeclAST.cc
@@ -0,0 +1,89 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TransitionDeclAST.C
+ *
+ * Description: See TransitionDeclAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "TransitionDeclAST.hh"
+#include "Transition.hh"
+
+TransitionDeclAST::TransitionDeclAST(Vector<string>* state_list_ptr,
+ Vector<string>* event_list_ptr,
+ string* next_state_ptr,
+ PairListAST* pairs_ptr,
+ Vector<string>* action_list_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_state_list_ptr = state_list_ptr;
+ m_event_list_ptr = event_list_ptr;
+ m_next_state_ptr = next_state_ptr;
+ m_action_list_ptr = action_list_ptr;
+}
+
+TransitionDeclAST::~TransitionDeclAST()
+{
+ delete m_state_list_ptr;
+ delete m_event_list_ptr;
+ delete m_next_state_ptr;
+ delete m_action_list_ptr;
+}
+
+void TransitionDeclAST::generate()
+{
+ Vector<string>& states = *m_state_list_ptr;
+ Vector<string>& events = *m_event_list_ptr;
+
+ StateMachine* machine_ptr = g_sym_table.getStateMachine();
+ if (machine_ptr == NULL) {
+ error("Transition declaration not part of a machine.");
+ } else if (m_next_state_ptr == NULL) {
+ for (int i=0; i<states.size(); i++) {
+ for (int j=0; j<events.size(); j++) {
+ machine_ptr->addTransition(new Transition(states[i], events[j], states[i], *m_action_list_ptr, getLocation(), getPairs()));
+ }
+ }
+ } else {
+ for (int i=0; i<states.size(); i++) {
+ for (int j=0; j<events.size(); j++) {
+ machine_ptr->addTransition(new Transition(states[i], events[j], *m_next_state_ptr, *m_action_list_ptr, getLocation(), getPairs()));
+ }
+ }
+ }
+}
+
+void TransitionDeclAST::print(ostream& out) const
+{
+ out << "[TransitionDecl: ]";
+}
diff --git a/src/mem/slicc/ast/TransitionDeclAST.hh b/src/mem/slicc/ast/TransitionDeclAST.hh
new file mode 100644
index 000000000..10ca067d3
--- /dev/null
+++ b/src/mem/slicc/ast/TransitionDeclAST.hh
@@ -0,0 +1,89 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TransistionDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: TransitionDeclAST.h,v 3.2 2003/07/10 18:08:07 milo Exp $
+ *
+ */
+
+#ifndef TransitionDeclAST_H
+#define TransitionDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "StatementListAST.hh"
+
+class TransitionDeclAST : public DeclAST {
+public:
+ // Constructors
+ TransitionDeclAST(Vector<string>* state_list_ptr,
+ Vector<string>* event_list_ptr,
+ string* next_state_ptr,
+ PairListAST* pairs_ptr,
+ Vector<string>* action_list_ptr);
+
+ // Destructor
+ ~TransitionDeclAST();
+
+ // Public Methods
+ void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ TransitionDeclAST(const TransitionDeclAST& obj);
+ TransitionDeclAST& operator=(const TransitionDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ Vector<string>* m_state_list_ptr;
+ Vector<string>* m_event_list_ptr;
+ string* m_next_state_ptr;
+ Vector<string>* m_action_list_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const TransitionDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const TransitionDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //TransitionDeclAST_H
diff --git a/src/mem/slicc/ast/TypeAST.cc b/src/mem/slicc/ast/TypeAST.cc
new file mode 100644
index 000000000..82364732b
--- /dev/null
+++ b/src/mem/slicc/ast/TypeAST.cc
@@ -0,0 +1,67 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeAST.C
+ *
+ * Description: See TypeAST.h
+ *
+ * $Id: TypeAST.C,v 3.1 2003/03/22 15:15:16 xu Exp $
+ *
+ */
+
+#include "TypeAST.hh"
+
+TypeAST::TypeAST(string* ident_ptr)
+ : AST()
+{
+ m_ident_ptr = ident_ptr;
+}
+
+TypeAST::~TypeAST()
+{
+ delete m_ident_ptr;
+
+}
+
+string TypeAST::toString() const
+{
+ return *m_ident_ptr;
+}
+
+Type* TypeAST::lookupType() const
+{
+ Type* type_ptr = g_sym_table.getType(*m_ident_ptr);
+ if (type_ptr != NULL) {
+ return type_ptr;
+ } else {
+ error("Type '" + *m_ident_ptr + "' not declared.");
+ }
+ return NULL; // Not reached
+}
diff --git a/src/mem/slicc/ast/TypeAST.hh b/src/mem/slicc/ast/TypeAST.hh
new file mode 100644
index 000000000..a0fea56c3
--- /dev/null
+++ b/src/mem/slicc/ast/TypeAST.hh
@@ -0,0 +1,83 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeAST.h
+ *
+ * Description:
+ *
+ * $Id: TypeAST.h,v 3.2 2003/03/22 15:15:17 xu Exp $
+ *
+ */
+
+#ifndef TYPEAST_H
+#define TYPEAST_H
+
+#include "slicc_global.hh"
+#include "AST.hh"
+
+class TypeAST : public AST {
+public:
+ // Constructors
+ TypeAST(string* ident_ptr);
+
+ // Destructor
+ ~TypeAST();
+
+ // Public Methods
+ string toString() const;
+ Type* lookupType() const;
+
+ virtual void print(ostream& out) const {}
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ TypeAST(const TypeAST& obj);
+ TypeAST& operator=(const TypeAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_ident_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const TypeAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const TypeAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //TYPEAST_H
diff --git a/src/mem/slicc/ast/TypeDeclAST.cc b/src/mem/slicc/ast/TypeDeclAST.cc
new file mode 100644
index 000000000..5d2b19bac
--- /dev/null
+++ b/src/mem/slicc/ast/TypeDeclAST.cc
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeDeclAST.C
+ *
+ * Description: See TypeDeclAST.h
+ *
+ * $Id: TypeDeclAST.C,v 3.1 2003/03/22 15:15:17 xu Exp $
+ *
+ */
+
+#include "TypeDeclAST.hh"
+#include "main.hh"
+#include "SymbolTable.hh"
+
+TypeDeclAST::TypeDeclAST(TypeAST* type_ast_ptr,
+ PairListAST* pairs_ptr,
+ Vector<TypeFieldAST*>* field_vec_ptr)
+ : DeclAST(pairs_ptr)
+{
+ m_type_ast_ptr = type_ast_ptr;
+ m_field_vec_ptr = field_vec_ptr;
+}
+
+TypeDeclAST::~TypeDeclAST()
+{
+ delete m_type_ast_ptr;
+ if (m_field_vec_ptr != NULL) {
+ int size = m_field_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_field_vec_ptr)[i];
+ }
+ delete m_field_vec_ptr;
+ }
+}
+
+void TypeDeclAST::generate()
+{
+ string machine_name;
+ string id = m_type_ast_ptr->toString();
+
+ // Make the new type
+ Type* new_type_ptr = new Type(id, getLocation(), getPairs(),
+ g_sym_table.getStateMachine());
+ g_sym_table.newSym(new_type_ptr);
+
+ // Add all of the fields of the type to it
+ if (m_field_vec_ptr != NULL) {
+ int size = m_field_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ (*m_field_vec_ptr)[i]->generate(new_type_ptr);
+ }
+ }
+}
+
+void TypeDeclAST::print(ostream& out) const
+{
+ out << "[TypeDecl: " << m_type_ast_ptr->toString() << "]";
+}
diff --git a/src/mem/slicc/ast/TypeDeclAST.hh b/src/mem/slicc/ast/TypeDeclAST.hh
new file mode 100644
index 000000000..1928c1bde
--- /dev/null
+++ b/src/mem/slicc/ast/TypeDeclAST.hh
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeDeclAST.h
+ *
+ * Description:
+ *
+ * $Id: TypeDeclAST.h,v 3.2 2003/03/17 01:55:28 xu Exp $
+ *
+ */
+
+#ifndef TypeDeclAST_H
+#define TypeDeclAST_H
+
+#include "slicc_global.hh"
+#include "DeclAST.hh"
+#include "TypeAST.hh"
+#include "TypeFieldAST.hh"
+
+class TypeDeclAST : public DeclAST {
+public:
+ // Constructors
+ TypeDeclAST(TypeAST* type_ast_ptr,
+ PairListAST* pairs_ptr,
+ Vector<TypeFieldAST*>* field_vec_ptr);
+
+ // Destructor
+ ~TypeDeclAST();
+
+ // Public Methods
+ virtual void generate();
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ TypeDeclAST(const TypeDeclAST& obj);
+ TypeDeclAST& operator=(const TypeDeclAST& obj);
+
+ // Data Members (m_ prefix)
+ TypeAST* m_type_ast_ptr;
+ Vector<TypeFieldAST*>* m_field_vec_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const TypeDeclAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const TypeDeclAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //TypeDeclAST_H
diff --git a/src/mem/slicc/ast/TypeFieldAST.cc b/src/mem/slicc/ast/TypeFieldAST.cc
new file mode 100644
index 000000000..9dfe45397
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldAST.cc
@@ -0,0 +1,44 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldAST.C
+ *
+ * Description: See TypeFieldAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "TypeFieldAST.hh"
+
+TypeFieldAST::TypeFieldAST(PairListAST* pairs_ptr)
+ : AST(pairs_ptr->getPairs()) {
+}
+
diff --git a/src/mem/slicc/ast/TypeFieldAST.hh b/src/mem/slicc/ast/TypeFieldAST.hh
new file mode 100644
index 000000000..69d6d8b87
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldAST.hh
@@ -0,0 +1,83 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef TypeFieldAST_H
+#define TypeFieldAST_H
+
+#include "slicc_global.hh"
+#include "StateMachine.hh"
+#include "StatementListAST.hh"
+#include "PairListAST.hh"
+#include "ExprAST.hh"
+
+class TypeFieldAST : public AST {
+public:
+ // Constructors
+ TypeFieldAST(PairListAST* pairs_ptr);
+
+ // Destructor
+ virtual ~TypeFieldAST() {}
+
+ // Public Methods
+ virtual void generate(Type *type_ptr) = 0;
+ virtual void print(ostream& out) const = 0;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ // TypeFieldAST(const TypeFieldAST& obj);
+ // TypeFieldAST& operator=(const TypeFieldAST& obj);
+
+ // Data Members (m_ prefix)
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const TypeFieldAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const TypeFieldAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //TypeFieldAST_H
diff --git a/src/mem/slicc/ast/TypeFieldEnumAST.cc b/src/mem/slicc/ast/TypeFieldEnumAST.cc
new file mode 100644
index 000000000..dbb27c3ae
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldEnumAST.cc
@@ -0,0 +1,82 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldEnumAST.C
+ *
+ * Description: See TypeFieldEnumAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "TypeFieldEnumAST.hh"
+#include "State.hh"
+#include "Event.hh"
+
+TypeFieldEnumAST::TypeFieldEnumAST(string* field_id_ptr,
+ PairListAST* pairs_ptr)
+ : TypeFieldAST(pairs_ptr)
+{
+ m_field_id_ptr = field_id_ptr;
+ m_pairs_ptr = pairs_ptr;
+}
+
+TypeFieldEnumAST::~TypeFieldEnumAST()
+{
+ delete m_field_id_ptr;
+}
+
+void TypeFieldEnumAST::generate(Type *type_ptr)
+{
+ // Add enumeration
+ if (!type_ptr->enumAdd(*m_field_id_ptr, m_pairs_ptr->getPairs())) {
+ error("Duplicate enumeration: " + type_ptr->toString() + ":" + *m_field_id_ptr);
+ }
+
+ // Fill machine info
+ StateMachine* machine_ptr = g_sym_table.getStateMachine();
+ if (type_ptr->toString() == "State") {
+ if (machine_ptr == NULL) {
+ error("State declaration not part of a machine.");
+ }
+ machine_ptr->addState(new State(*m_field_id_ptr, getLocation(), getPairs()));
+ }
+ if (type_ptr->toString() == "Event") {
+ if (machine_ptr == NULL) {
+ error("Event declaration not part of a machine.");
+ }
+ machine_ptr->addEvent(new Event(*m_field_id_ptr, getLocation(), getPairs()));
+ }
+}
+
+void TypeFieldEnumAST::print(ostream& out) const
+{
+ out << "[TypeFieldEnum: " << *m_field_id_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/TypeFieldEnumAST.hh b/src/mem/slicc/ast/TypeFieldEnumAST.hh
new file mode 100644
index 000000000..f9c111762
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldEnumAST.hh
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldEnumAST.h
+ *
+ * Description:
+ *
+ * $Id: TypeFieldEnumAST.h,v 3.2 2003/07/10 18:08:07 milo Exp $
+ *
+ */
+
+#ifndef TypeFieldEnumAST_H
+#define TypeFieldEnumAST_H
+
+#include "slicc_global.hh"
+#include "StateMachine.hh"
+#include "TypeFieldAST.hh"
+#include "StatementListAST.hh"
+#include "PairListAST.hh"
+
+class TypeFieldEnumAST : public TypeFieldAST {
+public:
+ // Constructors
+ TypeFieldEnumAST(string* field_id_ptr,
+ PairListAST* pairs_ptr);
+
+ // Destructor
+ ~TypeFieldEnumAST();
+
+ // Public Methods
+ void generate(Type *type_ptr);
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ TypeFieldEnumAST(const TypeFieldEnumAST& obj);
+ TypeFieldEnumAST& operator=(const TypeFieldEnumAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_field_id_ptr;
+ PairListAST* m_pairs_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const TypeFieldEnumAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const TypeFieldEnumAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //TypeFieldEnumAST_H
diff --git a/src/mem/slicc/ast/TypeFieldMemberAST.cc b/src/mem/slicc/ast/TypeFieldMemberAST.cc
new file mode 100644
index 000000000..40109851b
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldMemberAST.cc
@@ -0,0 +1,84 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldMemberAST.C
+ *
+ * Description: See TypeFieldMemberAST.h
+ *
+ * $Id: TypeFieldMemberAST.C,v 3.1 2003/03/27 22:58:54 xu Exp $
+ *
+ */
+
+#include "TypeFieldMemberAST.hh"
+
+TypeFieldMemberAST::TypeFieldMemberAST(TypeAST* type_ast_ptr,
+ string* field_id_ptr,
+ PairListAST* pairs_ptr,
+ ExprAST* rvalue_ptr)
+ : TypeFieldAST(pairs_ptr)
+{
+ m_type_ast_ptr = type_ast_ptr;
+ m_field_id_ptr = field_id_ptr;
+ m_rvalue_ptr = rvalue_ptr;
+}
+
+TypeFieldMemberAST::~TypeFieldMemberAST()
+{
+ delete m_type_ast_ptr;
+ delete m_field_id_ptr;
+ if(m_rvalue_ptr) delete m_rvalue_ptr;
+}
+
+void TypeFieldMemberAST::generate(Type *type_ptr)
+{
+ // Lookup type
+ Type* field_type_ptr = m_type_ast_ptr->lookupType();
+
+ // check type if this is a initialization
+ string* init_code = NULL;
+ if(m_rvalue_ptr) {
+ init_code = new string();
+ Type* rvalue_type_ptr = m_rvalue_ptr->generate(*init_code);
+ if(field_type_ptr != rvalue_type_ptr) {
+ error("Initialization type mismatch '" + field_type_ptr->toString() + "' and '" + rvalue_type_ptr->toString() + "'");
+ }
+ }
+
+ // Add data member to the parent type
+ if (!type_ptr->dataMemberAdd(*m_field_id_ptr, field_type_ptr, getPairs(),
+ init_code)) {
+ error("Duplicate data member: " + type_ptr->toString() + ":" + *m_field_id_ptr);
+ }
+}
+
+void TypeFieldMemberAST::print(ostream& out) const
+{
+ out << "[TypeFieldMember: " << *m_field_id_ptr << "]";
+}
diff --git a/src/mem/slicc/ast/TypeFieldMemberAST.hh b/src/mem/slicc/ast/TypeFieldMemberAST.hh
new file mode 100644
index 000000000..5e275bb96
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldMemberAST.hh
@@ -0,0 +1,91 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldMemberAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef TypeFieldMemberAST_H
+#define TypeFieldMemberAST_H
+
+#include "slicc_global.hh"
+#include "TypeFieldAST.hh"
+#include "StateMachine.hh"
+#include "StatementListAST.hh"
+#include "PairListAST.hh"
+#include "ExprAST.hh"
+#include "TypeAST.hh"
+
+class TypeFieldMemberAST : public TypeFieldAST {
+public:
+ // Constructors
+ TypeFieldMemberAST(TypeAST* type_ast_ptr,
+ string* field_id_ptr,
+ PairListAST* pairs_ptr,
+ ExprAST* rvalue_ptr);
+
+ // Destructor
+ ~TypeFieldMemberAST();
+
+ // Public Methods
+ void generate(Type *type_ptr);
+ void print(ostream& out) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ TypeFieldMemberAST(const TypeFieldMemberAST& obj);
+ TypeFieldMemberAST& operator=(const TypeFieldMemberAST& obj);
+
+ // Data Members (m_ prefix)
+ TypeAST* m_type_ast_ptr;
+ string* m_field_id_ptr;
+ ExprAST* m_rvalue_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const TypeFieldMemberAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const TypeFieldMemberAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //TypeFieldMemberAST_H
diff --git a/src/mem/slicc/ast/TypeFieldMethodAST.cc b/src/mem/slicc/ast/TypeFieldMethodAST.cc
new file mode 100644
index 000000000..5229d4a08
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldMethodAST.cc
@@ -0,0 +1,81 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldMethodAST.C
+ *
+ * Description: See TypeFieldMethodAST.h
+ *
+ * $Id: TypeFieldMethodAST.C,v 3.1 2003/07/10 18:08:07 milo Exp $
+ *
+ */
+
+#include "TypeFieldMethodAST.hh"
+
+TypeFieldMethodAST::TypeFieldMethodAST(TypeAST* return_type_ast_ptr,
+ string* ident_ptr,
+ Vector<TypeAST*>* type_ast_vec_ptr,
+ PairListAST* pairs_ptr)
+ : TypeFieldAST(pairs_ptr)
+{
+ m_return_type_ast_ptr = return_type_ast_ptr;
+ m_ident_ptr = ident_ptr;
+ m_type_ast_vec_ptr = type_ast_vec_ptr;
+}
+
+TypeFieldMethodAST::~TypeFieldMethodAST()
+{
+ delete m_return_type_ast_ptr;
+ delete m_ident_ptr;
+
+ int size = m_type_ast_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ delete (*m_type_ast_vec_ptr)[i];
+ }
+ delete m_type_ast_vec_ptr;
+}
+
+void TypeFieldMethodAST::generate(Type *type_ptr)
+{
+ // Lookup return type
+ Type* return_type_ptr = m_return_type_ast_ptr->lookupType();
+
+ // Lookup parameter types
+ Vector<Type*> type_vec;
+ int size = m_type_ast_vec_ptr->size();
+ for(int i=0; i<size; i++) {
+ Type* type_ptr = (*m_type_ast_vec_ptr)[i]->lookupType();
+ type_vec.insertAtBottom(type_ptr);
+ }
+
+ // Add method
+ if (!type_ptr->methodAdd(*m_ident_ptr, return_type_ptr, type_vec)) { // Return false on error
+ error("Duplicate method: " + type_ptr->toString() + ":" + *m_ident_ptr + "()");
+ }
+}
diff --git a/src/mem/slicc/ast/TypeFieldMethodAST.hh b/src/mem/slicc/ast/TypeFieldMethodAST.hh
new file mode 100644
index 000000000..a276cc5f8
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldMethodAST.hh
@@ -0,0 +1,87 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * TypeFieldMethodAST.h
+ *
+ * Description:
+ *
+ * $Id: TypeFieldMethodAST.h,v 3.2 2003/07/10 18:08:07 milo Exp $
+ *
+ */
+
+#ifndef TYPEFIELDMETHODAST_H
+#define TYPEFIELDMETHODAST_H
+
+#include "slicc_global.hh"
+#include "TypeFieldAST.hh"
+#include "TypeAST.hh"
+
+class TypeFieldMethodAST : public TypeFieldAST {
+public:
+ // Constructors
+ TypeFieldMethodAST(TypeAST* return_type_ast_ptr,
+ string* ident_ptr,
+ Vector<TypeAST*>* type_ast_vec_ptr,
+ PairListAST* pairs_ptr);
+ // Destructor
+ ~TypeFieldMethodAST();
+
+ // Public Methods
+
+ void generate(Type *type_ptr);
+ void print(ostream& out) const {}
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ TypeFieldMethodAST(const TypeFieldMethodAST& obj);
+ TypeFieldMethodAST& operator=(const TypeFieldMethodAST& obj);
+
+ // Data Members (m_ prefix)
+ TypeAST* m_return_type_ast_ptr;
+ string* m_ident_ptr;
+ Vector<TypeAST*>* m_type_ast_vec_ptr;
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const TypeFieldMethodAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const TypeFieldMethodAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //TYPEFIELDMETHODAST_H
diff --git a/src/mem/slicc/ast/VarExprAST.cc b/src/mem/slicc/ast/VarExprAST.cc
new file mode 100644
index 000000000..865cc71b0
--- /dev/null
+++ b/src/mem/slicc/ast/VarExprAST.cc
@@ -0,0 +1,76 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * VarExprAST.C
+ *
+ * Description: See VarExprAST.h
+ *
+ * $Id$
+ *
+ */
+
+#include "VarExprAST.hh"
+#include "StatementAST.hh"
+#include "SymbolTable.hh"
+
+VarExprAST::~VarExprAST()
+{
+ delete m_var_ptr;
+}
+
+
+Var* VarExprAST::getVar() const
+{
+ string var = *m_var_ptr;
+ Var* var_ptr = g_sym_table.getVar(var);
+ if (var_ptr == NULL) {
+ error("Unrecognized variable: " + var);
+ }
+ return var_ptr;
+}
+
+void VarExprAST::assertType(string type_ident) const
+{
+ Type* expected_type_ptr = g_sym_table.getType(type_ident);
+ if (expected_type_ptr == NULL) {
+ error("There must be a type '" + type_ident + "' declared in this scope");
+ }
+
+ if (getVar()->getType() != expected_type_ptr) {
+ error("Incorrect type: '" + getVar()->getIdent() + "' is expected to be type '" + expected_type_ptr->toString() + "'");
+ }
+}
+
+Type* VarExprAST::generate(string& code) const
+{
+ Var* var_ptr = getVar();
+ code += var_ptr->getCode();
+ return var_ptr->getType();
+}
diff --git a/src/mem/slicc/ast/VarExprAST.hh b/src/mem/slicc/ast/VarExprAST.hh
new file mode 100644
index 000000000..ce2f68875
--- /dev/null
+++ b/src/mem/slicc/ast/VarExprAST.hh
@@ -0,0 +1,86 @@
+
+/*
+ * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met: redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer;
+ * redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution;
+ * neither the name of the copyright holders nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * VarExprAST.h
+ *
+ * Description:
+ *
+ * $Id$
+ *
+ */
+
+#ifndef VAREXPRAST_H
+#define VAREXPRAST_H
+
+#include "slicc_global.hh"
+#include "ExprAST.hh"
+class Var;
+
+class VarExprAST : public ExprAST {
+public:
+ // Constructors
+ VarExprAST(string* var_ptr) : ExprAST() { m_var_ptr = var_ptr; }
+
+ // Destructor
+ ~VarExprAST();
+
+ // Public Methods
+ Type* generate(string& code) const;
+ void print(ostream& out) const { out << "[VarExprAST: " << *m_var_ptr << "]"; }
+ string getName() const { return *m_var_ptr; }
+ Var* getVar() const;
+ void assertType(string type_ident) const;
+private:
+ // Private Methods
+
+ // Private copy constructor and assignment operator
+ VarExprAST(const VarExprAST& obj);
+ VarExprAST& operator=(const VarExprAST& obj);
+
+ // Data Members (m_ prefix)
+ string* m_var_ptr;
+
+};
+
+// Output operator declaration
+ostream& operator<<(ostream& out, const VarExprAST& obj);
+
+// ******************* Definitions *******************
+
+// Output operator definition
+extern inline
+ostream& operator<<(ostream& out, const VarExprAST& obj)
+{
+ obj.print(out);
+ out << flush;
+ return out;
+}
+
+#endif //VAREXPRAST_H