summaryrefslogtreecommitdiff
path: root/src/mem/slicc/ast
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2009-09-22 18:12:39 -0700
committerNathan Binkert <nate@binkert.org>2009-09-22 18:12:39 -0700
commit2278363015a2a5cc850b38213833096d33b496e8 (patch)
tree8f7fea117f40cadbec70e68a0b92e1cb960dafbe /src/mem/slicc/ast
parent30d5d95b6a7c93ccf63ae0cfcc62d17306c31eee (diff)
downloadgem5-2278363015a2a5cc850b38213833096d33b496e8.tar.xz
slicc: Pure python implementation of slicc.
This is simply a translation of the C++ slicc into python with very minimal reorganization of the code. The output can be verified as nearly identical by doing a "diff -wBur". Slicc can easily be run manually by using util/slicc
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/AST.py63
-rw-r--r--src/mem/slicc/ast/ASTs.hh91
-rw-r--r--src/mem/slicc/ast/ActionDeclAST.cc98
-rw-r--r--src/mem/slicc/ast/ActionDeclAST.hh86
-rw-r--r--src/mem/slicc/ast/ActionDeclAST.py72
-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/AssignStatementAST.py59
-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/CheckAllocateStatementAST.py47
-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/CheckStopSlotsStatementAST.py74
-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/ChipComponentAccessAST.py161
-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/CopyHeadStatementAST.py52
-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/DeclAST.py38
-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/DeclListAST.py51
-rw-r--r--src/mem/slicc/ast/EnqueueStatementAST.cc111
-rw-r--r--src/mem/slicc/ast/EnqueueStatementAST.hh93
-rw-r--r--src/mem/slicc/ast/EnqueueStatementAST.py86
-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/EnumDeclAST.py71
-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/EnumExprAST.py53
-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/ExprAST.py45
-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/ExprStatementAST.py52
-rw-r--r--src/mem/slicc/ast/FormalParamAST.cc72
-rw-r--r--src/mem/slicc/ast/FormalParamAST.hh88
-rw-r--r--src/mem/slicc/ast/FormalParamAST.py52
-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/FuncCallExprAST.py168
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.cc112
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.hh91
-rw-r--r--src/mem/slicc/ast/FuncDeclAST.py88
-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/IfStatementAST.py74
-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/InPortDeclAST.py130
-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/InfixOperatorExprAST.py89
-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/LiteralExprAST.py55
-rw-r--r--src/mem/slicc/ast/Location.cc87
-rw-r--r--src/mem/slicc/ast/Location.hh93
-rw-r--r--src/mem/slicc/ast/MachineAST.cc99
-rw-r--r--src/mem/slicc/ast/MachineAST.hh93
-rw-r--r--src/mem/slicc/ast/MachineAST.py81
-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/MemberExprAST.py55
-rw-r--r--src/mem/slicc/ast/MethodCallExprAST.cc160
-rw-r--r--src/mem/slicc/ast/MethodCallExprAST.hh93
-rw-r--r--src/mem/slicc/ast/MethodCallExprAST.py127
-rw-r--r--src/mem/slicc/ast/NewExprAST.cc9
-rw-r--r--src/mem/slicc/ast/NewExprAST.hh20
-rw-r--r--src/mem/slicc/ast/NewExprAST.py47
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.cc137
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.hh86
-rw-r--r--src/mem/slicc/ast/ObjDeclAST.py94
-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/OutPortDeclAST.py57
-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/PairAST.py36
-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/PairListAST.py37
-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/PeekStatementAST.py73
-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/ReturnStatementAST.py54
-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/StatementAST.py34
-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/StatementListAST.py46
-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/TransitionDeclAST.py54
-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/TypeAST.py53
-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/TypeDeclAST.py62
-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/TypeFieldAST.py32
-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/TypeFieldEnumAST.py59
-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/TypeFieldMemberAST.py57
-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/TypeFieldMethodAST.py50
-rw-r--r--src/mem/slicc/ast/VarExprAST.cc76
-rw-r--r--src/mem/slicc/ast/VarExprAST.hh86
-rw-r--r--src/mem/slicc/ast/VarExprAST.py66
-rw-r--r--src/mem/slicc/ast/__init__.py69
127 files changed, 2823 insertions, 7485 deletions
diff --git a/src/mem/slicc/ast/AST.cc b/src/mem/slicc/ast/AST.cc
deleted file mode 100644
index e893c453a..000000000
--- a/src/mem/slicc/ast/AST.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/AST.hh"
diff --git a/src/mem/slicc/ast/AST.hh b/src/mem/slicc/ast/AST.hh
deleted file mode 100644
index 33c9b84ed..000000000
--- a/src/mem/slicc/ast/AST.hh
+++ /dev/null
@@ -1,94 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef AST_H
-#define AST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/gems_common/Vector.hh"
-#include "mem/gems_common/Map.hh"
-#include "mem/slicc/ast/Location.hh"
-#include "mem/slicc/symbols/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/AST.py b/src/mem/slicc/ast/AST.py
new file mode 100644
index 000000000..5b1b124cd
--- /dev/null
+++ b/src/mem/slicc/ast/AST.py
@@ -0,0 +1,63 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.util import PairContainer, Location
+
+class AST(PairContainer):
+ def __init__(self, slicc, pairs=None):
+ self.slicc = slicc
+ self.location = Location(slicc.current_file, slicc.lexer.lineno)
+ self.pairs = {}
+ if pairs:
+ self.pairs.update(getattr(pairs, "pairs", pairs))
+
+ @property
+ def symtab(self):
+ return self.slicc.symtab
+
+ @property
+ def state_machine(self):
+ return self.slicc.symtab.state_machine
+
+ def warning(self, message, *args):
+ self.location.warning(message, *args)
+
+ def error(self, message, *args):
+ self.location.error(message, *args)
+
+ def embedError(self, message, *args):
+ if args:
+ message = message % args
+ code = code_formatter()
+ code('''
+cerr << "Runtime Error at ${{self.location}}, Ruby Time: " << g_eventQueue_ptr->getTime() << ": "<< $message << ", PID: " << getpid() << endl;
+char c; cerr << "press return to continue." << endl; cin.get(c); abort();
+''')
+
+ return code
diff --git a/src/mem/slicc/ast/ASTs.hh b/src/mem/slicc/ast/ASTs.hh
deleted file mode 100644
index 3363fbb09..000000000
--- a/src/mem/slicc/ast/ASTs.hh
+++ /dev/null
@@ -1,91 +0,0 @@
-
-/*
- * 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 "mem/slicc/slicc_global.hh"
-#include "mem/slicc/main.hh"
-#include "mem/slicc/symbols/StateMachine.hh"
-#include "mem/slicc/ast/AST.hh"
-
-#include "mem/slicc/ast/MachineAST.hh"
-
-#include "mem/slicc/ast/TypeAST.hh"
-#include "mem/slicc/ast/FormalParamAST.hh"
-
-#include "mem/slicc/ast/DeclListAST.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/ActionDeclAST.hh"
-#include "mem/slicc/ast/InPortDeclAST.hh"
-#include "mem/slicc/ast/OutPortDeclAST.hh"
-#include "mem/slicc/ast/TransitionDeclAST.hh"
-#include "mem/slicc/ast/EnumDeclAST.hh"
-#include "mem/slicc/ast/TypeDeclAST.hh"
-#include "mem/slicc/ast/ObjDeclAST.hh"
-#include "mem/slicc/ast/FuncDeclAST.hh"
-
-#include "mem/slicc/ast/TypeFieldAST.hh"
-#include "mem/slicc/ast/TypeFieldMethodAST.hh"
-#include "mem/slicc/ast/TypeFieldMemberAST.hh"
-#include "mem/slicc/ast/TypeFieldEnumAST.hh"
-
-#include "mem/slicc/ast/PairAST.hh"
-#include "mem/slicc/ast/PairListAST.hh"
-
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/VarExprAST.hh"
-#include "mem/slicc/ast/EnumExprAST.hh"
-#include "mem/slicc/ast/LiteralExprAST.hh"
-#include "mem/slicc/ast/MemberExprAST.hh"
-#include "mem/slicc/ast/InfixOperatorExprAST.hh"
-#include "mem/slicc/ast/FuncCallExprAST.hh"
-#include "mem/slicc/ast/MethodCallExprAST.hh"
-#include "mem/slicc/ast/NewExprAST.hh"
-
-#include "mem/slicc/ast/ChipComponentAccessAST.hh"
-
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/ExprStatementAST.hh"
-#include "mem/slicc/ast/AssignStatementAST.hh"
-#include "mem/slicc/ast/EnqueueStatementAST.hh"
-#include "mem/slicc/ast/IfStatementAST.hh"
-#include "mem/slicc/ast/PeekStatementAST.hh"
-#include "mem/slicc/ast/CopyHeadStatementAST.hh"
-#include "mem/slicc/ast/CheckAllocateStatementAST.hh"
-#include "mem/slicc/ast/CheckStopSlotsStatementAST.hh"
-#include "mem/slicc/ast/ReturnStatementAST.hh"
-
-#endif //ASTs_H
diff --git a/src/mem/slicc/ast/ActionDeclAST.cc b/src/mem/slicc/ast/ActionDeclAST.cc
deleted file mode 100644
index e46412ff7..000000000
--- a/src/mem/slicc/ast/ActionDeclAST.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-
-#include "mem/slicc/ast/ActionDeclAST.hh"
-#include "mem/slicc/symbols/Action.hh"
-#include "mem/slicc/ast/StatementListAST.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
deleted file mode 100644
index 4970ee254..000000000
--- a/src/mem/slicc/ast/ActionDeclAST.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: ActionDeclAST.hh,v 3.2 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#ifndef ActionDeclAST_H
-#define ActionDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-
-class StatementListAST;
-
-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/ActionDeclAST.py b/src/mem/slicc/ast/ActionDeclAST.py
new file mode 100644
index 000000000..18bf443b9
--- /dev/null
+++ b/src/mem/slicc/ast/ActionDeclAST.py
@@ -0,0 +1,72 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.symbols import Action, Type, Var
+
+class ActionDeclAST(DeclAST):
+ def __init__(self, slicc, ident, pairs, statement_list):
+ super(ActionDeclAST, self).__init__(slicc, pairs)
+ self.ident = ident
+ self.statement_list = statement_list
+
+ def __repr__(self):
+ return "[ActionDecl: %r]" % (self.ident)
+
+ def generate(self):
+ resources = {}
+ if self.statement_list:
+ # Add new local vars
+ self.symtab.pushFrame()
+
+ addr_type = self.symtab.find("Address", Type)
+
+ if addr_type is None:
+ self.error("Type 'Address' not declared.")
+
+ var = Var(self.symtab, "address", self.location, addr_type,
+ "addr", self.pairs)
+ self.symtab.newSymbol(var)
+
+ # Do not allows returns in actions
+ code = code_formatter()
+ self.statement_list.generate(code, None)
+ self.pairs["c_code"] = str(code)
+
+ self.statement_list.findResources(resources)
+
+ self.symtab.popFrame()
+
+ machine = self.symtab.state_machine
+ if machine is None:
+ self.error("Action declaration not part of a machine.")
+
+ action = Action(self.symtab, self.ident, resources, self.location,
+ self.pairs)
+ machine.addAction(action)
diff --git a/src/mem/slicc/ast/AssignStatementAST.cc b/src/mem/slicc/ast/AssignStatementAST.cc
deleted file mode 100644
index 8cf42aa63..000000000
--- a/src/mem/slicc/ast/AssignStatementAST.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: AssignStatementAST.C,v 3.2 2003/08/01 18:38:19 beckmann Exp $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 2c19da831..000000000
--- a/src/mem/slicc/ast/AssignStatementAST.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: AssignStatementAST.hh,v 3.2 2001/12/12 01:00:09 milo Exp $
- *
- */
-
-#ifndef ASSIGNSTATEMENTAST_H
-#define ASSIGNSTATEMENTAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/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/AssignStatementAST.py b/src/mem/slicc/ast/AssignStatementAST.py
new file mode 100644
index 000000000..f8e77b03b
--- /dev/null
+++ b/src/mem/slicc/ast/AssignStatementAST.py
@@ -0,0 +1,59 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.StatementAST import StatementAST
+
+class AssignStatementAST(StatementAST):
+ def __init__(self, slicc, lvalue, rvalue):
+ super(AssignStatementAST, self).__init__(slicc)
+ self.lvalue = lvalue
+ self.rvalue = rvalue
+
+ def __repr__(self):
+ return "[AssignStatementAST: %r := %r]" % (self.lvalue, self.rvalue)
+
+ def generate(self, code, return_type):
+ lcode = code_formatter()
+ rcode = code_formatter()
+
+ ltype = self.lvalue.generate(lcode)
+ rtype = self.rvalue.generate(rcode)
+
+ code("$lcode = $rcode;")
+
+ if ltype != rtype:
+ # 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 str(ltype) != "NetDest" and str(rtype) != "Set":
+ self.error("Assignment type mismatch '%s' and '%s'",
+ ltype, rtype)
diff --git a/src/mem/slicc/ast/CheckAllocateStatementAST.cc b/src/mem/slicc/ast/CheckAllocateStatementAST.cc
deleted file mode 100644
index 1f498efe2..000000000
--- a/src/mem/slicc/ast/CheckAllocateStatementAST.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-
-/*
- * 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 "mem/slicc/ast/CheckAllocateStatementAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/ast/VarExprAST.hh"
-#include "mem/gems_common/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
deleted file mode 100644
index 1df853514..000000000
--- a/src/mem/slicc/ast/CheckAllocateStatementAST.hh
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/*
- * 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 "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/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/CheckAllocateStatementAST.py b/src/mem/slicc/ast/CheckAllocateStatementAST.py
new file mode 100644
index 000000000..b96153b0a
--- /dev/null
+++ b/src/mem/slicc/ast/CheckAllocateStatementAST.py
@@ -0,0 +1,47 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.StatementAST import StatementAST
+
+class CheckAllocateStatementAST(StatementAST):
+ def __init__(self, slicc, variable):
+ super(StatementAST, self).__init__(slicc)
+ self.variable = variable
+
+ def __repr__(self):
+ return "[CheckAllocateStatementAst: %r]" % self.variable
+
+ def generate(self, code, return_type):
+ # FIXME - check the type of the variable
+
+ # Make sure the variable is valid
+ self.variable.var
+
+ def findResources(self, resources):
+ var = self.variable.var
+ res_count = int(resources.get(var, 0))
+ resources[var] = str(res_count + 1)
diff --git a/src/mem/slicc/ast/CheckStopSlotsStatementAST.cc b/src/mem/slicc/ast/CheckStopSlotsStatementAST.cc
deleted file mode 100644
index 38dc449d6..000000000
--- a/src/mem/slicc/ast/CheckStopSlotsStatementAST.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-
-/*
- * 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 "mem/slicc/ast/CheckStopSlotsStatementAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/ast/VarExprAST.hh"
-#include "mem/slicc/ast/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
deleted file mode 100644
index 6de068caa..000000000
--- a/src/mem/slicc/ast/CheckStopSlotsStatementAST.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * 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 "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/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/CheckStopSlotsStatementAST.py b/src/mem/slicc/ast/CheckStopSlotsStatementAST.py
new file mode 100644
index 000000000..307fbd6a1
--- /dev/null
+++ b/src/mem/slicc/ast/CheckStopSlotsStatementAST.py
@@ -0,0 +1,74 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.StatementAST import StatementAST
+
+class CheckStopSlotsStatementAST(StatementAST):
+ def __init__(self, slicc, variable, condStr, bankStr):
+ super(StatementAST, self).__init__(slicc)
+ self.variable = variable
+ self.condStr = condStr
+ self.bankStr = bankStr
+
+ def __repr__(self):
+ return "[CheckStopSlotsStatementAst: %r]" % self.variable
+
+ def generate(self, code, return_type):
+ # Make sure the variable is valid
+ self.variable.var
+
+ def findResources(self, resources):
+ var = self.variable.var
+ assert var not in self.resources
+
+ check_code = code_formatter()
+ if self.condStr == "((*in_msg_ptr)).m_isOnChipSearch":
+ check_code('''
+const Response9Msg* in_msg_ptr =
+ dynamic_cast<const Response9Msg*>(((*(m_chip_ptr.m_L2Cache_responseToL2Cache9_vec[m_version]))).peek());
+assert(in_msg_ptr != NULL);
+''')
+
+ vcode = self.variable.inline()
+ bank = self.bankStr
+ cond = self.condStr
+
+ check_code('''
+if ($cond) {
+ auto pos = m_chip_ptr.m_DNUCAmover_ptr->getBankPos($bank)
+
+ if (!$vcode.isDisableSPossible(pos)) {
+ return TransitionResult_ResourceStall;
+ }
+} else {
+ if (!$vcode.isDisableFPossible(pos)) {
+ return TransitionResult_ResourceStall;
+ }
+}
+''')
+
+ resources[var] = str(check_code)
diff --git a/src/mem/slicc/ast/ChipComponentAccessAST.cc b/src/mem/slicc/ast/ChipComponentAccessAST.cc
deleted file mode 100644
index 61dccf2c0..000000000
--- a/src/mem/slicc/ast/ChipComponentAccessAST.cc
+++ /dev/null
@@ -1,244 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: ChipComponentAccessAST.C 1.9 04/06/18 21:00:08-00:00 beckmann@cottons.cs.wisc.edu $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 1f22a79e4..000000000
--- a/src/mem/slicc/ast/ChipComponentAccessAST.hh
+++ /dev/null
@@ -1,101 +0,0 @@
-
-/*
- * 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.hh 1.8 04/06/18 21:00:08-00:00 beckmann@cottons.cs.wisc.edu $
- *
- */
-
-#ifndef ChipComponentAccessAST_H
-#define ChipComponentAccessAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/VarExprAST.hh"
-#include "mem/slicc/ast/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/ChipComponentAccessAST.py b/src/mem/slicc/ast/ChipComponentAccessAST.py
new file mode 100644
index 000000000..841220c94
--- /dev/null
+++ b/src/mem/slicc/ast/ChipComponentAccessAST.py
@@ -0,0 +1,161 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+import re
+
+from slicc.ast.ExprAST import ExprAST
+from slicc.symbols import Type
+
+class ChipComponentAccessAST(ExprAST):
+ def __init__(self, slicc, machine, mach_version, component):
+ super(ChipComponentAccessAST, self).__init__(slicc)
+ self.mach_var = machine
+ self.comp_var = component
+ self.mach_ver_expr = mach_version
+
+ def __repr__(self):
+ return "[ChipAccessExpr: %r]" % self.expr_vec
+
+ def generate(self, code):
+ void_type = self.symtab.find("void", Type)
+
+ mname = self.mach_var.name
+ cname = self.comp_var.name
+ var = self.symtab.machine_components[mname][cname]
+
+ vcode = str(var.code)
+
+ if self.chip_ver_expr is not None:
+ # replace self.chip with specified chip
+ gcode = "g_system.getChip(%s)" % self.chip_ver_expr.inline()
+ vcode = re.sub("m_chip", gcode, vcode)
+
+ # replace default "m_version" with the version we really want
+ gcode = "(%s)" % self.mach_ver_expr.inline()
+ vcode = re.sub("m_version", gcode, vcode)
+
+ return_type, gcode = self.generate_access(var)
+ code("($vcode)$gcode")
+ return return_type
+
+class ChipMethodAccessAST(ChipComponentAccessAST):
+ def __init__(self, slicc, chip_version, machine, mach_version, component,
+ proc_name, expr_vec):
+ s = super(ChipMethodAccessAST, self)
+ s.__init__(slicc, machine, mach_version, component)
+
+ self.chip_ver_expr = chip_version
+ self.expr_vec = expr_vec
+ self.proc_name = proc_name
+
+ def generate_access(self, var):
+ # generate code
+ paramTypes = []
+ gcode = []
+ for expr in self.expr_vec:
+ t,c = expr.generate()
+ paramTypes.append(t)
+ gcode.append(c)
+
+ methodId = var.type.methodId(self.proc_name, paramTypes)
+
+ # Verify that this is a method of the object
+ if not var.type.methodExist(methodId):
+ error("%s: Type '%s' does not have a method '%s'" % \
+ ("Invalid method call", var.type, methodId))
+
+ expected_size = len(var.type.methodParamType(methodId))
+ if len(self.expr_vec) != expected_size:
+ # Right number of parameters
+ self.error("Wrong number of parameters for function name: " +\
+ "'%s', expected: %d, actual: %d",
+ self.proc_name, expected_size, len(self.expr_vec))
+
+ for expr,expected,actual in zip(self.expr_vec,
+ var.type.methodParamType(methodId),
+ paramTypes):
+ # Check the types of the parameter
+ if actual != expected:
+ expr.error("Type mismatch: expected: %s actual: %s",
+ expected, actual)
+
+ # method call
+ code = ".%s(%s)" % (self.proc_name, ', '.join(gcode))
+
+ # Return the return type of the method
+ return var.type.methodReturnType(methodId), code
+
+class LocalChipMethodAST(ChipMethodAccessAST):
+ # method call from local chip
+ def __init__(self, slicc, machine, mach_version, component, proc_name,
+ expr_vec):
+ s = super(LocalChipMethodAST, self)
+ s.__init__(slicc, None, machine, mach_version, component, proc_name,
+ expr_vec)
+
+class SpecifiedChipMethodAST(ChipMethodAccessAST):
+ # method call from specified chip
+ def __init__(self, slicc, chip_version, machine, mach_version, component,
+ proc_name, expr_vec):
+ s = super(SpecifiedChipMethodAST, self)
+ s.__init__(slicc, chip_version, machine, mach_version, component,
+ proc_name, expr_vec)
+
+class ChipMemberAccessAST(ChipComponentAccessAST):
+ # member access from specified chip
+ def __init__(self, chip_version, machine, mach_version, component,
+ field_name):
+ s = super(ChipMemberAccessAST, self)
+ s.__init__(slicc, machine, mach_version, component)
+
+ self.chip_ver_expr = chip_version
+ self.field_name = field_name
+
+ def generate_access(self, var):
+ # Verify that this is a valid field name for this type
+ if not var.type.dataMemberExist(self.field_name):
+ self.error("Invalid object field: " +\
+ "Type '%s' does not have data member %s",
+ var.type, self.field_name)
+
+ code += ").m_%s" % self.field_name
+
+ return var.type.dataMemberType(self.field_name), code
+
+class LocalChipMemberAST(ChipMemberAccessAST):
+ # member access from local chip
+ def __init__(self, slicc, machine, mach_version, component, field_name):
+ s = super(LocalChipMemberAST, self)
+ s.__init__(slicc, None, machine, mach_version, component, field_name)
+
+class SpecifiedChipMemberAST(ChipMemberAccessAST):
+ # member access from specified chip
+ def __init__(self, chip_version, machine, mach_version, component,
+ field_name):
+ s = super(SpecifiedChipMemberAST, self)
+ s.__init__(slicc, chip_version, machine, mach_version, component,
+ field_name)
diff --git a/src/mem/slicc/ast/CopyHeadStatementAST.cc b/src/mem/slicc/ast/CopyHeadStatementAST.cc
deleted file mode 100644
index 8d455eb9d..000000000
--- a/src/mem/slicc/ast/CopyHeadStatementAST.cc
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * 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 "mem/slicc/ast/CopyHeadStatementAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/ast/VarExprAST.hh"
-#include "mem/gems_common/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
deleted file mode 100644
index 53d479136..000000000
--- a/src/mem/slicc/ast/CopyHeadStatementAST.hh
+++ /dev/null
@@ -1,87 +0,0 @@
-
-/*
- * 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 "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/TypeAST.hh"
-#include "mem/slicc/ast/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/CopyHeadStatementAST.py b/src/mem/slicc/ast/CopyHeadStatementAST.py
new file mode 100644
index 000000000..ba9970975
--- /dev/null
+++ b/src/mem/slicc/ast/CopyHeadStatementAST.py
@@ -0,0 +1,52 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.StatementAST import StatementAST
+
+class CopyHeadStatementAST(StatementAST):
+ def __init__(self, slicc, in_queue, out_queue, pairs):
+ super(CopyHeadStatementAST, self).__init__(slicc, pairs)
+
+ self.in_queue = in_queue
+ self.out_queue_ptr = out_queue
+
+ def __repr__(self):
+ return "[CopyHeadStatementAst: %r %r]" % (self.in_queue,
+ self.out_queue)
+
+ def generate(self, code, return_type):
+ self.in_queue.assertType("InPort")
+ self.out_queue.assertType("OutPort")
+
+ out_code = self.out_queue.var.code
+ in_code = self.in_queue.var.code
+ latency = self.get("latency", "COPY_HEAD_LATENCY")
+ code("$out_code.enqueue($in_code.getMsgPtrCopy(), $latency);")
+
+ def findResources(self, resources):
+ var = self.out_queue.var
+ resources[var] = str(int(resources.get(var, "0")) + 1)
diff --git a/src/mem/slicc/ast/DeclAST.cc b/src/mem/slicc/ast/DeclAST.cc
deleted file mode 100644
index 6ccf9a9d6..000000000
--- a/src/mem/slicc/ast/DeclAST.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/DeclAST.hh"
diff --git a/src/mem/slicc/ast/DeclAST.hh b/src/mem/slicc/ast/DeclAST.hh
deleted file mode 100644
index d9e4555b4..000000000
--- a/src/mem/slicc/ast/DeclAST.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef DECLAST_H
-#define DECLAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/AST.hh"
-#include "mem/slicc/ast/PairListAST.hh"
-#include "mem/slicc/symbols/StateMachine.hh"
-#include "mem/slicc/ast/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/DeclAST.py b/src/mem/slicc/ast/DeclAST.py
new file mode 100644
index 000000000..2303725a3
--- /dev/null
+++ b/src/mem/slicc/ast/DeclAST.py
@@ -0,0 +1,38 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+class DeclAST(AST):
+ def __init__(self, slicc, pairs):
+ super(DeclAST, self).__init__(slicc, pairs)
+
+ def files(self, hh, cc, parent=None):
+ pass
+
+ def findMachines(self):
+ return
diff --git a/src/mem/slicc/ast/DeclListAST.cc b/src/mem/slicc/ast/DeclListAST.cc
deleted file mode 100644
index 8337d714b..000000000
--- a/src/mem/slicc/ast/DeclListAST.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 1c2bc3c05..000000000
--- a/src/mem/slicc/ast/DeclListAST.hh
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: DeclListAST.hh,v 3.1 2001/12/12 01:00:12 milo Exp $
- *
- */
-
-#ifndef DeclListAST_H
-#define DeclListAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/AST.hh"
-#include "mem/slicc/ast/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/DeclListAST.py b/src/mem/slicc/ast/DeclListAST.py
new file mode 100644
index 000000000..42f98afc7
--- /dev/null
+++ b/src/mem/slicc/ast/DeclListAST.py
@@ -0,0 +1,51 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+class DeclListAST(AST):
+ def __init__(self, slicc, decls):
+ super(DeclListAST, self).__init__(slicc)
+
+ if not isinstance(decls, (list, tuple)):
+ decls = [ decls ]
+ self.decls = decls
+
+ def __repr__(self):
+ return "[DeclListAST: %s]" % (', '.join(repr(d) for d in self.decls))
+
+ def files(self, hh, cc, parent=None):
+ for decl in self.decls:
+ decl.files(hh, cc, parent)
+
+ def generate(self):
+ for decl in self.decls:
+ decl.generate()
+
+ def findMachines(self):
+ for decl in self.decls:
+ decl.findMachines()
diff --git a/src/mem/slicc/ast/EnqueueStatementAST.cc b/src/mem/slicc/ast/EnqueueStatementAST.cc
deleted file mode 100644
index a422d8a28..000000000
--- a/src/mem/slicc/ast/EnqueueStatementAST.cc
+++ /dev/null
@@ -1,111 +0,0 @@
-
-/*
- * 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 "mem/slicc/ast/EnqueueStatementAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/ast/VarExprAST.hh"
-#include "mem/slicc/ast/PairListAST.hh"
-#include "mem/gems_common/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")) {
- bool is_number = true;
- string val = getPairs().lookup("latency");
- for (int i=0; i<val.size(); i++)
- if (!isdigit(val[i])) is_number = false;
- if (is_number)
- code += ", " + getPairs().lookup("latency");
- else
- code += ", m_" + 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
deleted file mode 100644
index fc2776ed7..000000000
--- a/src/mem/slicc/ast/EnqueueStatementAST.hh
+++ /dev/null
@@ -1,93 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef ENQUEUESTATEMENTAST_H
-#define ENQUEUESTATEMENTAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/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/EnqueueStatementAST.py b/src/mem/slicc/ast/EnqueueStatementAST.py
new file mode 100644
index 000000000..faf966460
--- /dev/null
+++ b/src/mem/slicc/ast/EnqueueStatementAST.py
@@ -0,0 +1,86 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.StatementAST import StatementAST
+from slicc.symbols import Var
+
+class EnqueueStatementAST(StatementAST):
+ def __init__(self, slicc, queue_name, type_ast, pairs, statements):
+ super(EnqueueStatementAST, self).__init__(slicc, pairs)
+
+ self.queue_name = queue_name
+ self.type_ast = type_ast
+ self.statements = statements
+
+ def __repr__(self):
+ return "[EnqueueStatementAst: %s %s %s]" % \
+ (self.queue_name, self.type_ast.ident, self.statements)
+
+ def generate(self, code, return_type):
+ code("{")
+ code.indent()
+ self.symtab.pushFrame()
+
+ msg_type = self.type_ast.type
+
+ # Add new local var to symbol table
+ v = Var(self.symtab, "out_msg", self.location, msg_type, "out_msg",
+ self.pairs)
+ self.symtab.newSymbol(v)
+
+ # Declare message
+ code("${{msg_type.ident}} out_msg;")
+
+ # The other statements
+ t = self.statements.generate(code, None)
+
+ self.queue_name.assertType("OutPort")
+
+ args = [ "out_msg" ]
+ if "latency" in self:
+ latency = self["latency"]
+ try:
+ # see if this is an integer
+ latency = int(latency)
+ args.append("%s" % latency)
+ except ValueError:
+ # if not, it should be a member
+ args.append("m_%s" % latency)
+
+ args = ", ".join(args)
+ code('(${{self.queue_name.var.code}}).enqueue($args);')
+
+
+ # End scope
+ self.symtab.popFrame()
+ code.dedent()
+ code("}")
+
+ def findResources(self, resources):
+ var = self.queue_name.var
+ res_count = int(resources.get(var, 0))
+ resources[var] = str(res_count + 1)
diff --git a/src/mem/slicc/ast/EnumDeclAST.cc b/src/mem/slicc/ast/EnumDeclAST.cc
deleted file mode 100644
index b051f3c8f..000000000
--- a/src/mem/slicc/ast/EnumDeclAST.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/EnumDeclAST.hh"
-#include "mem/slicc/main.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index 2af650e83..000000000
--- a/src/mem/slicc/ast/EnumDeclAST.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef EnumDeclAST_H
-#define EnumDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/TypeAST.hh"
-#include "mem/slicc/ast/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/EnumDeclAST.py b/src/mem/slicc/ast/EnumDeclAST.py
new file mode 100644
index 000000000..c16fc8a75
--- /dev/null
+++ b/src/mem/slicc/ast/EnumDeclAST.py
@@ -0,0 +1,71 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.symbols import Func, Type
+
+class EnumDeclAST(DeclAST):
+ def __init__(self, slicc, type_ast, pairs, fields):
+ super(EnumDeclAST, self).__init__(slicc, pairs)
+
+ self.type_ast = type_ast
+ self.fields = fields
+
+ def __repr__(self):
+ return "[EnumDecl: %s]" % (self.type_ast)
+
+ def files(self, hh, cc, parent=None):
+ if "external" in self:
+ return
+
+ if parent:
+ ident = "%s_%s" % (parent, self.type_ast.ident)
+ else:
+ ident = self.type_ast.ident
+ hh.add("%s.hh" % ident)
+ cc.add("%s.cc" % ident)
+
+ def generate(self):
+ ident = str(self.type_ast)
+
+ # Make the new type
+ t = Type(self.symtab, ident, self.location, self.pairs,
+ self.state_machine)
+ self.symtab.newSymbol(t)
+
+ # Add all of the fields of the type to it
+ for field in self.fields:
+ field.generate(t)
+
+ # Add the implicit State_to_string method - FIXME, this is a bit dirty
+ func_id = "%s_to_string" % t.c_ident
+
+ pairs = { "external" : "yes" }
+ func = Func(self.symtab, func_id, self.location,
+ self.symtab.find("string", Type), [ t ], [], "",
+ pairs, None)
+ self.symtab.newSymbol(func)
diff --git a/src/mem/slicc/ast/EnumExprAST.cc b/src/mem/slicc/ast/EnumExprAST.cc
deleted file mode 100644
index 0d8af0e9f..000000000
--- a/src/mem/slicc/ast/EnumExprAST.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: EnumExprAST.C,v 3.1 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 8af1c8891..000000000
--- a/src/mem/slicc/ast/EnumExprAST.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: EnumExprAST.hh,v 3.2 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#ifndef EnumExprAST_H
-#define EnumExprAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/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/EnumExprAST.py b/src/mem/slicc/ast/EnumExprAST.py
new file mode 100644
index 000000000..9cb76a8a1
--- /dev/null
+++ b/src/mem/slicc/ast/EnumExprAST.py
@@ -0,0 +1,53 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.ExprAST import ExprAST
+
+class EnumExprAST(ExprAST):
+ def __init__(self, slicc, type_ast, value):
+ super(EnumExprAST, self).__init__(slicc)
+
+ assert type_ast
+ assert value
+
+ self.type_ast = type_ast
+ self.value = value
+
+ def __repr__(self):
+ return "[EnumExpr: %s:%s]" % (self.type_ast, self.value)
+
+ def generate(self, code):
+ fix = code.nofix()
+ code('${{self.type_ast.type.c_ident}}_${{self.value}}')
+ code.fix(fix)
+
+ # Make sure the enumeration value exists
+ if self.value not in self.type_ast.type.enums:
+ self.error("Type '%s' does not have enumeration '%s'",
+ self.type_ast, self.value)
+
+ return self.type_ast.type
diff --git a/src/mem/slicc/ast/ExprAST.cc b/src/mem/slicc/ast/ExprAST.cc
deleted file mode 100644
index 3427d4dd9..000000000
--- a/src/mem/slicc/ast/ExprAST.cc
+++ /dev/null
@@ -1,39 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/ExprAST.hh"
diff --git a/src/mem/slicc/ast/ExprAST.hh b/src/mem/slicc/ast/ExprAST.hh
deleted file mode 100644
index 9566541da..000000000
--- a/src/mem/slicc/ast/ExprAST.hh
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef EXPRAST_H
-#define EXPRAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/ExprAST.py b/src/mem/slicc/ast/ExprAST.py
new file mode 100644
index 000000000..70a0aa0b5
--- /dev/null
+++ b/src/mem/slicc/ast/ExprAST.py
@@ -0,0 +1,45 @@
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.AST import AST
+
+class ExprAST(AST):
+ def __init__(self, slicc):
+ super(ExprAST, self).__init__(slicc)
+
+ def findResources(self, resources):
+ # The default is no resources
+ pass
+
+ def inline(self, get_type=False):
+ code = code_formatter(fix_newlines=False)
+ return_type = self.generate(code)
+ if get_type:
+ return return_type, code
+ else:
+ return code
diff --git a/src/mem/slicc/ast/ExprStatementAST.cc b/src/mem/slicc/ast/ExprStatementAST.cc
deleted file mode 100644
index f4bffaab3..000000000
--- a/src/mem/slicc/ast/ExprStatementAST.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index a47e86af5..000000000
--- a/src/mem/slicc/ast/ExprStatementAST.hh
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef ExprStatementAST_H
-#define ExprStatementAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/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/ExprStatementAST.py b/src/mem/slicc/ast/ExprStatementAST.py
new file mode 100644
index 000000000..b16d1d072
--- /dev/null
+++ b/src/mem/slicc/ast/ExprStatementAST.py
@@ -0,0 +1,52 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.StatementAST import StatementAST
+from slicc.symbols import Type
+
+class ExprStatementAST(StatementAST):
+ def __init__(self, slicc, expr):
+ super(ExprStatementAST, self).__init__(slicc)
+ self.expr = expr
+
+ def __repr__(self):
+ return "[ExprStatementAST: %s]" % (self.expr)
+
+ def generate(self, code, return_type):
+ actual_type,rcode = self.expr.inline(True)
+ code("$rcode;")
+
+ # The return type must be void
+ if actual_type != self.symtab.find("void", Type):
+ self.expr.error("Non-void return must not be ignored, " + \
+ "return type is '%s'", actual_type.ident)
+
+ def findResources(self, resources):
+ self.expr.findResources(resources)
+
diff --git a/src/mem/slicc/ast/FormalParamAST.cc b/src/mem/slicc/ast/FormalParamAST.cc
deleted file mode 100644
index 529811f25..000000000
--- a/src/mem/slicc/ast/FormalParamAST.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: FormalParamAST.C,v 3.1 2000/10/05 21:22:20 milo Exp $
- *
- */
-
-#include "mem/slicc/ast/FormalParamAST.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/TypeAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-
-FormalParamAST::~FormalParamAST()
-{
- delete m_ident_ptr;
- delete m_type_ast_ptr;
-}
-
-string FormalParamAST::getTypeName() const
-{
- return m_type_ast_ptr->toString();
-}
-
-Type* FormalParamAST::getType() const
-{
- return m_type_ast_ptr->lookupType();
-}
-
-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
deleted file mode 100644
index ca27948b7..000000000
--- a/src/mem/slicc/ast/FormalParamAST.hh
+++ /dev/null
@@ -1,88 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: FormalParamAST.hh,v 3.1 2001/12/12 01:00:15 milo Exp $
- *
- */
-
-#ifndef FORMALPARAMAST_H
-#define FORMALPARAMAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/AST.hh"
-
-class TypeAST;
-
-
-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; }
- string getTypeName() const;
- Type* getType() const;
-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/FormalParamAST.py b/src/mem/slicc/ast/FormalParamAST.py
new file mode 100644
index 000000000..b169cbb1c
--- /dev/null
+++ b/src/mem/slicc/ast/FormalParamAST.py
@@ -0,0 +1,52 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+from slicc.symbols import Var
+
+class FormalParamAST(AST):
+ def __init__(self, slicc, type_ast, ident):
+ super(FormalParamAST, self).__init__(slicc)
+ self.type_ast = type_ast
+ self.ident = ident
+
+ def __repr__(self):
+ return "[FormalParamAST: %s]" % self.ident
+
+ @property
+ def name(self):
+ return self.ident
+
+ def generate(self):
+ type = self.type_ast.type
+ param = "param_%s" % self.ident
+
+ # Add to symbol table
+ v = Var(self.symtab, self.ident, self.location, type, param,
+ self.pairs)
+ self.symtab.newSymbol(v)
+ return type, "%s %s" % (type.c_ident, param)
diff --git a/src/mem/slicc/ast/FuncCallExprAST.cc b/src/mem/slicc/ast/FuncCallExprAST.cc
deleted file mode 100644
index 5b19017e9..000000000
--- a/src/mem/slicc/ast/FuncCallExprAST.cc
+++ /dev/null
@@ -1,224 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/FuncCallExprAST.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index 6c02122ee..000000000
--- a/src/mem/slicc/ast/FuncCallExprAST.hh
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef FUNCCALLEXPRAST_H
-#define FUNCCALLEXPRAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/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/FuncCallExprAST.py b/src/mem/slicc/ast/FuncCallExprAST.py
new file mode 100644
index 000000000..abf7eec7b
--- /dev/null
+++ b/src/mem/slicc/ast/FuncCallExprAST.py
@@ -0,0 +1,168 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.ExprAST import ExprAST
+from slicc.symbols import Func, Type
+
+class FuncCallExprAST(ExprAST):
+ def __init__(self, slicc, proc_name, exprs):
+ super(FuncCallExprAST, self).__init__(slicc)
+ self.proc_name = proc_name
+ self.exprs = exprs
+
+ def __repr__(self):
+ return "[FuncCallExpr: %s %s]" % (self.proc_name, self.exprs)
+
+ def generate(self, code):
+ machine = self.state_machine
+
+ # DEBUG_EXPR is strange since it takes parameters of multiple types
+ if self.proc_name == "DEBUG_EXPR":
+ # FIXME - check for number of parameters
+ code('DEBUG_SLICC(MedPrio, "$0: ", $1)',
+ self.exprs[0].location, self.exprs[0].inline())
+
+ return self.symtab.find("void", Type)
+
+ # hack for adding comments to profileTransition
+ if self.proc_name == "APPEND_TRANSITION_COMMENT":
+ # FIXME - check for number of parameters
+ code("APPEND_TRANSITION_COMMENT($0)", self.exprs[0].inline())
+ return self.symtab.find("void", Type)
+
+ # Look up the function in the symbol table
+ func = self.symtab.find(self.proc_name, Func)
+
+ # Check the types and get the code for the parameters
+ if func is None:
+ self.error("Unrecognized function name: '%s'", self.proc_name)
+
+ if len(self.exprs) != len(func.param_types):
+ self.error("Wrong number of arguments passed to function : '%s'" +\
+ " Expected %d, got %d", self.proc_name,
+ len(func.param_types), len(self.exprs))
+
+ cvec = []
+ for expr,expected_type in zip(self.exprs, func.param_types):
+ # Check the types of the parameter
+ actual_type,param_code = expr.inline(True)
+ if actual_type != expected_type:
+ expr.error("Type mismatch: expected: %s actual: %s" % \
+ (expected_type, actual_type))
+ cvec.append(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 self.proc_name == "trigger":
+ code('''
+{
+ Address addr = ${{cvec[1]}};
+ TransitionResult result = doTransition(${{cvec[0]}}, ${machine}_getState(addr), addr);
+
+ if (result == TransitionResult_Valid) {
+ counter++;
+ continue; // Check the first port again
+ }
+
+ if (result == TransitionResult_ResourceStall) {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+
+ // Cannot do anything with this transition, go check next doable transition (mostly likely of next port)
+ }
+}
+''')
+ elif self.proc_name == "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 len(cvec) == 4
+ code('''
+{
+ Address addr1 = ${{cvec[1]}};
+ TransitionResult result1 =
+ doTransition(${{cvec[0]}}, ${machine}_getState(addr1), addr1);
+
+ if (result1 == TransitionResult_Valid) {
+ //this second event cannont fail because the first event
+ // already took effect
+ Address addr2 = ${{cvec[3]}};
+ TransitionResult result2 = doTransition(${{cvec[2]}}, ${machine}_getState(addr2), addr2);
+
+ // ensure the event suceeded
+ assert(result2 == TransitionResult_Valid);
+
+ counter++;
+ continue; // Check the first port again
+ }
+
+ if (result1 == TransitionResult_ResourceStall) {
+ g_eventQueue_ptr->scheduleEvent(this, 1);
+ // Cannot do anything with this transition, go check next
+ // doable transition (mostly likely of next port)
+ }
+}
+''')
+ elif self.proc_name == "error":
+ code("$0", self.exprs[0].embedError(cvec[0]))
+ elif self.proc_name == "assert":
+ error = self.exprs[0].embedError('"assert failure"')
+ code('''
+if (ASSERT_FLAG && !(${{cvec[0]}})) {
+ $error
+}
+''')
+
+ elif self.proc_name == "continueProcessing":
+ code("counter++;")
+ code("continue; // Check the first port again")
+ else:
+ # Normal function
+
+ # if the func is internal to the chip but not the machine
+ # then it can only be accessed through the chip pointer
+ internal = ""
+ if "external" not in func and not func.isInternalMachineFunc:
+ internal = "m_chip_ptr->"
+
+ params = ', '.join(str(c) for c in cvec)
+ fix = code.nofix()
+ code('(${internal}${{func.c_ident}}($params))')
+ code.fix(fix)
+
+ return func.return_type
diff --git a/src/mem/slicc/ast/FuncDeclAST.cc b/src/mem/slicc/ast/FuncDeclAST.cc
deleted file mode 100644
index 2a0905f06..000000000
--- a/src/mem/slicc/ast/FuncDeclAST.cc
+++ /dev/null
@@ -1,112 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: FuncDeclAST.C,v 3.4 2003/08/22 18:19:34 beckmann Exp $
- *
- */
-
-#include "mem/slicc/ast/FuncDeclAST.hh"
-#include "mem/slicc/ast/FormalParamAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/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
deleted file mode 100644
index 205e71a85..000000000
--- a/src/mem/slicc/ast/FuncDeclAST.hh
+++ /dev/null
@@ -1,91 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: FuncDeclAST.hh,v 3.2 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#ifndef FuncDeclAST_H
-#define FuncDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/TypeFieldAST.hh"
-#include "mem/slicc/ast/TypeAST.hh"
-
-class FormalParamsAST;
-
-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/FuncDeclAST.py b/src/mem/slicc/ast/FuncDeclAST.py
new file mode 100644
index 000000000..7ff3bf8a7
--- /dev/null
+++ b/src/mem/slicc/ast/FuncDeclAST.py
@@ -0,0 +1,88 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util.code_formatter import code_formatter
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.symbols import Func, Type
+
+class FuncDeclAST(DeclAST):
+ def __init__(self, slicc, return_type, ident, formals, pairs, statements):
+ super(FuncDeclAST, self).__init__(slicc, pairs)
+
+ self.return_type = return_type
+ self.ident = ident
+ self.formals = formals
+ self.statements = statements
+
+ def __repr__(self):
+ return "[FuncDecl: %s]" % self.ident
+
+ def files(self, hh, cc, parent=None):
+ if "external" in self or self.statements is None:
+ return
+
+ if parent:
+ ident = "%s_%s" % (parent, self.ident)
+ else:
+ ident = self.ident
+ cc.add("%s.cc" % ident)
+
+ def generate(self):
+ types = []
+ params = []
+ void_type = self.symtab.find("void", Type)
+
+ # Generate definition code
+ self.symtab.pushFrame()
+
+ # Lookup return type
+ return_type = self.return_type.type
+
+ # Generate function header
+ for formal in self.formals:
+ # Lookup parameter types
+ type, ident = formal.generate()
+ types.append(type)
+ params.append(ident)
+
+ body = code_formatter()
+ if self.statements is None:
+ self["external"] = "yes"
+ else:
+ rtype = self.statements.generate(body, return_type)
+
+ self.symtab.popFrame()
+
+ machine = self.state_machine
+ func = Func(self.symtab, self.ident, self.location, return_type,
+ types, params, str(body), self.pairs, machine)
+
+ if machine is not None:
+ machine.addFunc(func)
+ else:
+ self.symtab.newSymbol(func)
diff --git a/src/mem/slicc/ast/IfStatementAST.cc b/src/mem/slicc/ast/IfStatementAST.cc
deleted file mode 100644
index 40942a58d..000000000
--- a/src/mem/slicc/ast/IfStatementAST.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 2c168913a..000000000
--- a/src/mem/slicc/ast/IfStatementAST.hh
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef IFSTATEMENTAST_H
-#define IFSTATEMENTAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/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/IfStatementAST.py b/src/mem/slicc/ast/IfStatementAST.py
new file mode 100644
index 000000000..788876fd1
--- /dev/null
+++ b/src/mem/slicc/ast/IfStatementAST.py
@@ -0,0 +1,74 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.StatementAST import StatementAST
+from slicc.symbols import Type
+
+class IfStatementAST(StatementAST):
+ def __init__(self, slicc, cond, then, else_):
+ super(IfStatementAST, self).__init__(slicc)
+
+ assert cond is not None
+ assert then is not None
+
+ self.cond = cond
+ self.then = then
+ self.else_ = else_
+
+ def __repr__(self):
+ return "[IfStatement: %r%r%r]" % (self.cond, self.then, self.else_)
+
+ def generate(self, code, return_type):
+ cond_code = code_formatter()
+ cond_type = self.cond.generate(cond_code)
+
+ if cond_type != self.symtab.find("bool", Type):
+ self.cond.error("Condition of if stmt must be bool, type was '%s'",
+ ctype)
+
+ # Conditional
+ code.indent()
+ code('if ($cond_code) {')
+ # Then part
+ code.indent()
+ self.then.generate(code, return_type)
+ code.dedent()
+ # Else part
+ if self.else_:
+ code('} else {')
+ code.indent()
+ self.else_.generate(code, return_type)
+ code.dedent()
+ code('}') # End scope
+
+ def findResources(self, resources):
+ # Take a worse case look at both paths
+ self.then.findResources(resources)
+ if self.else_ is not None:
+ self.else_.findResources(resources)
diff --git a/src/mem/slicc/ast/InPortDeclAST.cc b/src/mem/slicc/ast/InPortDeclAST.cc
deleted file mode 100644
index f62af9921..000000000
--- a/src/mem/slicc/ast/InPortDeclAST.cc
+++ /dev/null
@@ -1,149 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/InPortDeclAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index e6295a6e2..000000000
--- a/src/mem/slicc/ast/InPortDeclAST.hh
+++ /dev/null
@@ -1,91 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: InPortDeclAST.hh,v 3.2 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#ifndef InPortDeclAST_H
-#define InPortDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/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/InPortDeclAST.py b/src/mem/slicc/ast/InPortDeclAST.py
new file mode 100644
index 000000000..3dde24557
--- /dev/null
+++ b/src/mem/slicc/ast/InPortDeclAST.py
@@ -0,0 +1,130 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.ast.TypeAST import TypeAST
+from slicc.symbols import Func, Type, Var
+
+class InPortDeclAST(DeclAST):
+ def __init__(self, slicc, ident, msg_type, var_expr, pairs, statements):
+ super(InPortDeclAST, self).__init__(slicc, pairs)
+
+ self.ident = ident
+ self.msg_type = msg_type
+ self.var_expr = var_expr
+ self.statements = statements
+ self.queue_type = TypeAST(slicc, "InPort")
+
+ def __repr__(self):
+ return "[InPortDecl: %s]" % self.ident
+
+ def generate(self):
+ symtab = self.symtab
+ void_type = symtab.find("void", Type)
+
+ code = code_formatter()
+ queue_type = self.var_expr.generate(code)
+ if not queue_type.isInPort:
+ self.error("The inport queue's type must have the 'inport' " + \
+ "attribute. Type '%s' does not have this attribute.",
+ queue_type)
+
+ type = self.queue_type.type
+ in_port = Var(self.symtab, self.ident, self.location, type, str(code),
+ self.pairs)
+ symtab.newSymbol(in_port)
+
+ symtab.pushFrame()
+ param_types = []
+
+ # Check for Event
+ type = symtab.find("Event", Type)
+ if type is None:
+ self.error("in_port decls require 'Event' enumeration defined")
+ param_types.append(type)
+
+ # Check for Address
+ type = symtab.find("Address", Type)
+ if type is None:
+ self.error("in_port decls require 'Address' type to be defined")
+
+ param_types.append(type)
+
+ # Add the trigger method - FIXME, this is a bit dirty
+ pairs = { "external" : "yes" }
+ func = Func(self.symtab, "trigger", self.location, void_type,
+ param_types, [], "", pairs, None)
+ symtab.newSymbol(func)
+
+ param_types = []
+ # Check for Event2
+ type = symtab.find("Event", Type)
+ if type is None:
+ self.error("in_port decls require 'Event' enumeration")
+
+ param_types.append(type)
+
+ # Check for Address2
+ type = symtab.find("Address", Type)
+ if type is None:
+ self.error("in_port decls require 'Address' type to be defined")
+
+ param_types.append(type)
+
+ # 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
+ func = Func(self.symtab, "doubleTrigger", self.location, void_type,
+ param_types, [], "", pairs, None)
+ symtab.newSymbol(func)
+
+ # Add the continueProcessing method - this hack supports
+ # messages that don't trigger events
+ func = Func(self.symtab, "continueProcessing", self.location,
+ void_type, [], [], "", pairs, None)
+ symtab.newSymbol(func)
+
+ if self.statements is not None:
+ rcode = code_formatter()
+ rcode.indent()
+ rcode.indent()
+ self.statements.generate(rcode, None)
+ in_port["c_code_in_port"] = str(rcode)
+ symtab.popFrame()
+
+ # Add port to state machine
+ machine = symtab.state_machine
+ if machine is None:
+ self.error("InPort declaration not part of a machine.")
+
+ machine.addInPort(in_port)
diff --git a/src/mem/slicc/ast/InfixOperatorExprAST.cc b/src/mem/slicc/ast/InfixOperatorExprAST.cc
deleted file mode 100644
index 40719fc66..000000000
--- a/src/mem/slicc/ast/InfixOperatorExprAST.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: InfixOperatorExprAST.C,v 3.2 2004/01/31 20:46:15 milo Exp $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index f97ab8805..000000000
--- a/src/mem/slicc/ast/InfixOperatorExprAST.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: InfixOperatorExprAST.hh,v 3.1 2001/12/12 01:00:19 milo Exp $
- *
- */
-
-#ifndef INFIXOPERATOREXPRAST_H
-#define INFIXOPERATOREXPRAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/InfixOperatorExprAST.py b/src/mem/slicc/ast/InfixOperatorExprAST.py
new file mode 100644
index 000000000..c4fb4a4db
--- /dev/null
+++ b/src/mem/slicc/ast/InfixOperatorExprAST.py
@@ -0,0 +1,89 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.ExprAST import ExprAST
+from slicc.symbols import Type
+
+class InfixOperatorExprAST(ExprAST):
+ def __init__(self, slicc, left, op, right):
+ super(InfixOperatorExprAST, self).__init__(slicc)
+
+ self.left = left
+ self.op = op
+ self.right = right
+
+ def __repr__(self):
+ return "[InfixExpr: %r %s %r]" % (self.left, self.op, self.right)
+
+ def generate(self, code):
+ lcode = code_formatter()
+ rcode = code_formatter()
+
+ ltype = self.left.generate(lcode)
+ rtype = self.right.generate(rcode)
+
+ # Figure out what the input and output types should be
+ if self.op in ("==", "!="):
+ output = "bool"
+ if (ltype != rtype):
+ self.error("Type mismatch: left and right operands of " +
+ "operator '%s' must be the same type. " +
+ "left: '%s', right: '%s'",
+ self.op, ltype, rtype)
+ else:
+ if self.op in ("&&", "||"):
+ # boolean inputs and output
+ inputs = "bool"
+ output = "bool"
+ elif self.op in ("==", "!=", ">=", "<=", ">", "<"):
+ # Integer inputs, boolean output
+ inputs = "int"
+ output = "bool"
+ else:
+ # integer inputs and output
+ inputs = "int"
+ output = "int"
+
+ inputs_type = self.symtab.find(inputs, Type)
+
+ if inputs_type != ltype:
+ self.left.error("Type mismatch: left operand of operator " +
+ "'%s' expects type '%s', actual was '%s'",
+ self.op, inputs, ltype)
+
+ if inputs_type != rtype:
+ self.right.error("Type mismatch: right operand of operator " +
+ "'%s' expects type '%s', actual was '%s'",
+ self.op, inputs, rtype)
+
+ # All is well
+ fix = code.nofix()
+ code("($lcode ${{self.op}} $rcode)")
+ code.fix(fix)
+ return self.symtab.find(output, Type)
diff --git a/src/mem/slicc/ast/LiteralExprAST.cc b/src/mem/slicc/ast/LiteralExprAST.cc
deleted file mode 100644
index 4e384a3b3..000000000
--- a/src/mem/slicc/ast/LiteralExprAST.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: LiteralExprAST.C,v 3.1 2002/10/22 21:27:52 milo Exp $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index c895fa9ae..000000000
--- a/src/mem/slicc/ast/LiteralExprAST.hh
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: LiteralExprAST.hh,v 3.1 2001/12/12 01:00:20 milo Exp $
- *
- */
-
-#ifndef LITERALEXPRAST_H
-#define LITERALEXPRAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/LiteralExprAST.py b/src/mem/slicc/ast/LiteralExprAST.py
new file mode 100644
index 000000000..773e8f35c
--- /dev/null
+++ b/src/mem/slicc/ast/LiteralExprAST.py
@@ -0,0 +1,55 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.ExprAST import ExprAST
+from slicc.symbols import Type
+
+class LiteralExprAST(ExprAST):
+ def __init__(self, slicc, literal, type):
+ super(LiteralExprAST, self).__init__(slicc)
+ self.literal = literal
+ self.type = type
+
+ def __repr__(self):
+ return "[Literal: %s]" % self.literal
+
+ def generate(self, code):
+ fix = code.nofix()
+ if self.type == "string":
+ code('("${{self.literal}}")')
+ elif self.type == "bool":
+ code('(${{str(self.literal).lower()}})')
+ else:
+ code('(${{self.literal}})')
+ code.fix(fix)
+
+ type = self.symtab.find(self.type, Type)
+ if type is None:
+ # Can't find the type
+ self.error("Internal: can't primitive type '%s'" % self.type)
+
+ return type
diff --git a/src/mem/slicc/ast/Location.cc b/src/mem/slicc/ast/Location.cc
deleted file mode 100644
index fd224fe2f..000000000
--- a/src/mem/slicc/ast/Location.cc
+++ /dev/null
@@ -1,87 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: Location.C,v 3.3 2004/05/30 22:19:02 kmoore Exp $
- *
- */
-
-#include "mem/slicc/ast/Location.hh"
-
-int g_line_number = 0;
-string &g_file_name()
-{
- static string the_string;
- return the_string;
-}
-
-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
deleted file mode 100644
index c9e20418e..000000000
--- a/src/mem/slicc/ast/Location.hh
+++ /dev/null
@@ -1,93 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: Location.hh,v 3.1 2001/12/12 01:00:20 milo Exp $
- *
- */
-
-#ifndef LOCATION_H
-#define LOCATION_H
-
-#include "mem/slicc/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
deleted file mode 100644
index ae8026458..000000000
--- a/src/mem/slicc/ast/MachineAST.cc
+++ /dev/null
@@ -1,99 +0,0 @@
-
-/*
- * 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.cc
- *
- * Description: See MachineAST.hh
- *
- * $Id: MachineAST.cc,v 3.1 2003/03/17 01:54:25 xu Exp $
- *
- */
-
-#include "mem/slicc/ast/MachineAST.hh"
-#include "mem/slicc/ast/FormalParamAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-
-MachineAST::MachineAST(string* ident_ptr,
- PairListAST* pairs_ptr,
- Vector<FormalParamAST*>* config_parameters,
- DeclListAST* decl_list_ptr)
-
- : DeclAST(pairs_ptr)
-{
- m_ident_ptr = ident_ptr;
- m_pairs_ptr = pairs_ptr;
- m_config_parameters = config_parameters;
- 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(), m_config_parameters);
- 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
deleted file mode 100644
index 5d1bc2a1c..000000000
--- a/src/mem/slicc/ast/MachineAST.hh
+++ /dev/null
@@ -1,93 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: MachineAST.hh,v 3.2 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#ifndef MachineAST_H
-#define MachineAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/DeclListAST.hh"
-#include "mem/slicc/ast/TypeFieldAST.hh"
-#include "mem/slicc/symbols/StateMachine.hh"
-
-class FormalParamAST;
-
-class MachineAST : public DeclAST {
-public:
- // Constructors
- MachineAST(string* ident_ptr,
- PairListAST* pairs_ptr,
- Vector<FormalParamAST*>* config_parameters,
- 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)
- Vector<FormalParamAST*>* m_config_parameters;
- 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/MachineAST.py b/src/mem/slicc/ast/MachineAST.py
new file mode 100644
index 000000000..8d48ccbf5
--- /dev/null
+++ b/src/mem/slicc/ast/MachineAST.py
@@ -0,0 +1,81 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.symbols import StateMachine, Type
+
+class MachineAST(DeclAST):
+ def __init__(self, slicc, ident, pairs_ast, config_parameters, decls):
+ super(MachineAST, self).__init__(slicc, pairs_ast)
+
+ self.ident = ident
+ self.pairs_ast = pairs_ast
+ self.config_parameters = config_parameters
+ self.decls = decls
+
+ def __repr__(self):
+ return "[Machine: %r]" % self.ident
+
+ def files(self, hh, cc, parent=None):
+ hh.add('%s_Controller.hh' % self.ident)
+ hh.add('%s_Profiler.hh' % self.ident)
+
+ cc.add('%s_Controller.cc' % self.ident)
+ cc.add('%s_Profiler.cc' % self.ident)
+ cc.add('%s_Transitions.cc' % self.ident)
+ cc.add('%s_Wakeup.cc' % self.ident)
+
+ self.decls.files(hh, cc, self.ident)
+
+ def generate(self):
+ # Make a new frame
+ self.symtab.pushFrame()
+
+ # Create a new machine
+ machine = StateMachine(self.symtab, self.ident, self.location,
+ self.pairs, self.config_parameters)
+
+ self.symtab.newCurrentMachine(machine)
+
+ # Generate code for all the internal decls
+ self.decls.generate()
+
+ # Build the transition table
+ machine.buildTable()
+
+ # Pop the frame
+ self.symtab.popFrame()
+
+ def findMachines(self):
+ # Add to MachineType enumeration
+ machine_type = self.symtab.find("MachineType", Type)
+ if not machine_type.enumAdd(self.ident, self.pairs_ast.pairs):
+ self.error("Duplicate machine name: %s:%s" % (machine_type,
+ self.ident))
+
+ # Generate code for all the internal decls
+ self.decls.findMachines()
diff --git a/src/mem/slicc/ast/MemberExprAST.cc b/src/mem/slicc/ast/MemberExprAST.cc
deleted file mode 100644
index 1bcfdc7f1..000000000
--- a/src/mem/slicc/ast/MemberExprAST.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 34b694882..000000000
--- a/src/mem/slicc/ast/MemberExprAST.hh
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: MemberExprAST.hh,v 3.1 2001/12/12 01:00:21 milo Exp $
- *
- */
-
-#ifndef MemberExprAST_H
-#define MemberExprAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/MemberExprAST.py b/src/mem/slicc/ast/MemberExprAST.py
new file mode 100644
index 000000000..113bb188a
--- /dev/null
+++ b/src/mem/slicc/ast/MemberExprAST.py
@@ -0,0 +1,55 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.ExprAST import ExprAST
+
+class MemberExprAST(ExprAST):
+ def __init__(self, slicc, expr_ast, field):
+ super(MemberExprAST, self).__init__(slicc)
+
+ self.expr_ast = expr_ast
+ self.field = field
+
+ def __repr__(self):
+ return "[MemberExprAST: %r.%r]" % (self.expr_ast, self.field)
+
+ def generate(self, code):
+ return_type, gcode = self.expr_ast.inline(True)
+ fix = code.nofix()
+ code("($gcode).m_${{self.field}}")
+ code.fix(fix)
+
+ # Verify that this is a valid field name for this type
+ if self.field not in return_type.data_members:
+ error("Invalid object field: " +
+ "Type '%s' does not have data member %s" % \
+ (return_type, self.field))
+
+ # Return the type of the field
+ return return_type.data_members[self.field].type
diff --git a/src/mem/slicc/ast/MethodCallExprAST.cc b/src/mem/slicc/ast/MethodCallExprAST.cc
deleted file mode 100644
index 1bfe312ff..000000000
--- a/src/mem/slicc/ast/MethodCallExprAST.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-
-/*
- * 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.cc
- *
- * Description: See MethodCallExprAST.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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;
-
- string methodId;
- Vector <Type*> paramTypes;
-
- int actual_size = m_expr_vec_ptr->size();
- for(int i=0; i<actual_size; i++) {
- string tmp;
- Type* actual_type_ptr = (*m_expr_vec_ptr)[i]->generate(tmp);
- paramTypes.insertAtBottom(actual_type_ptr);
- }
-
- if(m_obj_expr_ptr) {
- // member method call
- string tmp;
- obj_type_ptr = m_obj_expr_ptr->generate(tmp);
- methodId = obj_type_ptr->methodId(*m_proc_name_ptr, paramTypes);
- if (obj_type_ptr->methodReturnType(methodId)->isInterface())
- code += "static_cast<" + obj_type_ptr->methodReturnType(methodId)->cIdent() + "&>";
- code += "((";
- code += tmp;
- code += ").";
- } else if (m_type_ptr) {
- // class method call
- code += "(" + m_type_ptr->toString() + "::";
- obj_type_ptr = m_type_ptr->lookupType();
- methodId = obj_type_ptr->methodId(*m_proc_name_ptr, paramTypes);
- } else {
- // impossible
- assert(0);
- }
-
- // generate code
- 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);
- }
- code += "))";
-
- // 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
deleted file mode 100644
index d248e6ba4..000000000
--- a/src/mem/slicc/ast/MethodCallExprAST.hh
+++ /dev/null
@@ -1,93 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef MethodCallExprAST_H
-#define MethodCallExprAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/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/MethodCallExprAST.py b/src/mem/slicc/ast/MethodCallExprAST.py
new file mode 100644
index 000000000..ecfe43cdb
--- /dev/null
+++ b/src/mem/slicc/ast/MethodCallExprAST.py
@@ -0,0 +1,127 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.ExprAST import ExprAST
+
+class MethodCallExprAST(ExprAST):
+ def __init__(self, slicc, proc_name, expr_ast_vec):
+ super(MethodCallExprAST, self).__init__(slicc)
+ self.proc_name = proc_name
+ self.expr_ast_vec = expr_ast_vec
+
+ def generate(self, code):
+ tmp = code_formatter()
+ paramTypes = []
+ for expr_ast in self.expr_ast_vec:
+ return_type = expr_ast.generate(tmp)
+ paramTypes.append(return_type)
+
+ obj_type, methodId, prefix = self.generate_prefix(paramTypes)
+
+ # generate code
+ params = []
+ for expr_ast in self.expr_ast_vec:
+ return_type,tcode = expr_ast.inline(True)
+ params.append(str(tcode))
+ fix = code.nofix()
+ code("$prefix${{self.proc_name}}(${{', '.join(params)}}))")
+ code.fix(fix)
+
+ # Verify that this is a method of the object
+ if methodId not in obj_type.methods:
+ error("Invalid method call: Type '%s' does not have a method '%s'",
+ obj_type, methodId)
+
+ if len(self.expr_ast_vec) != \
+ len(obj_type.methods[methodId].param_types):
+ # Right number of parameters
+ error("Wrong number of parameters for function name: '%s', " + \
+ "expected: , actual: ", proc_name,
+ len(obj_type.methods[methodId].param_types),
+ len(self.expr_ast_vec))
+
+ for actual_type, expected_type in \
+ zip(paramTypes, obj_type.methods[methodId].param_types):
+ if actual_type != expected_type:
+ error("Type mismatch: expected: %s actual: %s",
+ expected_type, actual_type)
+
+ # Return the return type of the method
+ return obj_type.methods[methodId].return_type
+
+ def findResources(self, resources):
+ pass
+
+class MemberMethodCallExprAST(MethodCallExprAST):
+ def __init__(self, slicc, obj_expr_ast, proc_name, expr_ast_vec):
+ s = super(MemberMethodCallExprAST, self)
+ s.__init__(slicc, proc_name, expr_ast_vec)
+
+ self.obj_expr_ast = obj_expr_ast
+
+ def __repr__(self):
+ return "[MethodCallExpr: %r%r %r]" % (self.proc_name,
+ self.obj_expr_ast,
+ self.expr_ast_vec)
+ def generate_prefix(self, paramTypes):
+ code = code_formatter()
+
+ # member method call
+ obj_type = self.obj_expr_ast.generate(code)
+ methodId = obj_type.methodId(self.proc_name, paramTypes)
+
+ prefix = ""
+ return_type = obj_type.methods[methodId].return_type
+ if return_type.isInterface:
+ prefix = "static_cast<%s &>" % return_type.c_ident
+ prefix = "%s((%s)." % (prefix, code)
+
+ return obj_type, methodId, prefix
+
+
+class ClassMethodCallExprAST(MethodCallExprAST):
+ def __init__(self, slicc, type_ast, proc_name, expr_ast_vec):
+ s = super(ClassMethodCallExprAST, self)
+ s.__init__(slicc, proc_name, expr_ast_vec)
+
+ self.type_ast = type_ast
+
+ def __repr__(self):
+ return "[MethodCallExpr: %r %r]" % (self.proc_name, self.expr_ast_vec)
+
+ def generate_prefix(self, paramTypes):
+
+ # class method call
+ prefix = "(%s::" % self.type_ast
+ obj_type = self.type_ast.type
+ methodId = obj_type.methodId(self.proc_name, paramTypes)
+
+ return obj_type, methodId, prefix
+
+__all__ = [ "MemberMethodCallExprAST", "ClassMethodCallExprAST" ]
diff --git a/src/mem/slicc/ast/NewExprAST.cc b/src/mem/slicc/ast/NewExprAST.cc
deleted file mode 100644
index 95e57192f..000000000
--- a/src/mem/slicc/ast/NewExprAST.cc
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#include "mem/slicc/ast/NewExprAST.hh"
-
-Type* NewExprAST::generate(string & code) const
-{
- Type* type = m_type_ptr->lookupType();
- code += "new " + type->cIdent();
- return type;
-}
diff --git a/src/mem/slicc/ast/NewExprAST.hh b/src/mem/slicc/ast/NewExprAST.hh
deleted file mode 100644
index 375f130d6..000000000
--- a/src/mem/slicc/ast/NewExprAST.hh
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef NEWEXPRAST_H
-#define NEWEXPRAST_H
-
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/TypeAST.hh"
-#include "mem/slicc/symbols/Type.hh"
-
-class NewExprAST : public ExprAST
-{
-public:
- NewExprAST(TypeAST* type_ptr) : ExprAST() { m_type_ptr = type_ptr; }
- Type* generate(string & code) const;
- void print(ostream & out) const { out << "[NewExprAST: " << *m_type_ptr << "]"; }
- string getName() const { return m_type_ptr->toString(); }
-
-private:
- TypeAST* m_type_ptr;
-};
-
-#endif
diff --git a/src/mem/slicc/ast/NewExprAST.py b/src/mem/slicc/ast/NewExprAST.py
new file mode 100644
index 000000000..a42350768
--- /dev/null
+++ b/src/mem/slicc/ast/NewExprAST.py
@@ -0,0 +1,47 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.ExprAST import ExprAST
+
+class NewExprAST(ExprAST):
+ def __init__(self, slicc, type_ast):
+ super(NewExprAST, self).__init__(slicc)
+ self.type_ast = type_ast
+
+ def __repr__(self):
+ return "[NewExprAST: %r]" % self.type_ast
+
+ @property
+ def name(self):
+ return str(self.type_ast)
+
+ def generate(self, code):
+ type = self.type_ast.type
+ fix = code.nofix()
+ code("new ${{type.c_ident}}")
+ code.fix(fix)
+ return type
diff --git a/src/mem/slicc/ast/ObjDeclAST.cc b/src/mem/slicc/ast/ObjDeclAST.cc
deleted file mode 100644
index 3569395db..000000000
--- a/src/mem/slicc/ast/ObjDeclAST.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-
-/*
- * 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.cc
- *
- * Description: See ObjDeclAST.hh
- *
- * $Id: ObjDeclAST.cc,v 3.13 2004/06/24 15:56:14 beckmann Exp $
- *
- */
-
-#include "mem/slicc/ast/ObjDeclAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/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 {
- c_code = "(*m_" + machine + *m_ident_ptr + "_ptr)";
- // c_code = "(*(m_chip_ptr->m_" + machine + *m_ident_ptr + "_ptr))";
- // machineComponentSym = true;
- }
-
- Var* v = new Var(*m_ident_ptr, getLocation(), type_ptr, c_code,
- getPairs(), g_sym_table.getStateMachine());
-
- StateMachine* machine_ptr = g_sym_table.getStateMachine();
- if (machine_ptr != NULL) {
- machine_ptr->addObj(v);
- }// else {
- 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
deleted file mode 100644
index 0b808f472..000000000
--- a/src/mem/slicc/ast/ObjDeclAST.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: ObjDeclAST.hh,v 3.2 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#ifndef ObjDeclAST_H
-#define ObjDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/TypeFieldAST.hh"
-#include "mem/slicc/ast/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/ObjDeclAST.py b/src/mem/slicc/ast/ObjDeclAST.py
new file mode 100644
index 000000000..8a967f7b8
--- /dev/null
+++ b/src/mem/slicc/ast/ObjDeclAST.py
@@ -0,0 +1,94 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.symbols import Var
+
+class ObjDeclAST(DeclAST):
+ def __init__(self, slicc, type_ast, ident, pairs):
+ super(ObjDeclAST, self).__init__(slicc, pairs)
+
+ self.type_ast = type_ast
+ self.ident = ident
+
+ def __repr__(self):
+ return "[ObjDecl: %r]" % self.ident
+
+ def generate(self):
+ machineComponentSym = False
+
+ self["chip_object"] = "yes"
+
+ if "hack" in self:
+ warning("'hack=' is now deprecated")
+
+ if "network" in self and "virtual_network" not in self:
+ self.error("Network queues require a 'virtual_network' attribute")
+
+ type = self.type_ast.type
+ if type.isBuffer and "ordered" not in self:
+ self.error("Buffer object decls require an 'ordered' attribute")
+
+ if "ordered" in self:
+ value = self["ordered"]
+
+ if value not in ("true", "false"):
+ self.error("The 'ordered' attribute is '%s' " + \
+ "must be 'true' or 'false'.", value)
+
+ if "random" in self:
+ value = self["random"]
+ if value not in ("true", "false"):
+ self.error("The 'random' attribute is '%s' " + \
+ "must be 'true' or 'false'.", value)
+
+ machine = self.symtab.state_machine
+
+ # FIXME : should all use accessors here to avoid public member
+ # variables
+ if self.ident == "id":
+ c_code = "m_chip_ptr.getID()"
+ elif self.ident == "version":
+ c_code = "m_version"
+ elif self.ident == "machineID":
+ c_code = "m_machineID"
+ elif machine:
+ c_code = "(*m_%s_%s_ptr)" % (machine.ident, self.ident)
+ else:
+ c_code = "(*m_%s_ptr)" % (self.ident)
+
+ v = Var(self.symtab, self.ident, self.location, type, c_code,
+ self.pairs, machine)
+
+ if machine:
+ machine.addObject(v)
+
+ self.symtab.newSymbol(v)
+
+ # used to cheat-- that is, access components in other machines
+ if machineComponentSym:
+ self.symtab.newMachComponentSym(v)
diff --git a/src/mem/slicc/ast/OutPortDeclAST.cc b/src/mem/slicc/ast/OutPortDeclAST.cc
deleted file mode 100644
index 56a377f23..000000000
--- a/src/mem/slicc/ast/OutPortDeclAST.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: OutPortDeclAST.C,v 3.3 2004/02/02 22:37:51 milo Exp $
- *
- */
-
-#include "mem/slicc/ast/OutPortDeclAST.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index 0aa0172d3..000000000
--- a/src/mem/slicc/ast/OutPortDeclAST.hh
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: OutPortDeclAST.hh,v 3.2 2003/07/10 18:08:06 milo Exp $
- *
- */
-
-#ifndef OutPortDeclAST_H
-#define OutPortDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/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/OutPortDeclAST.py b/src/mem/slicc/ast/OutPortDeclAST.py
new file mode 100644
index 000000000..e6ef31928
--- /dev/null
+++ b/src/mem/slicc/ast/OutPortDeclAST.py
@@ -0,0 +1,57 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from m5.util import code_formatter
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.ast.TypeAST import TypeAST
+from slicc.symbols import Var
+
+class OutPortDeclAST(DeclAST):
+ def __init__(self, slicc, ident, msg_type, var_expr, pairs):
+ super(OutPortDeclAST, self).__init__(slicc, pairs)
+
+ self.ident = ident
+ self.msg_type = msg_type
+ self.var_expr = var_expr
+ self.queue_type = TypeAST(slicc, "OutPort")
+
+ def __repr__(self):
+ return "[OutPortDecl: %r]" % self.ident
+
+ def generate(self):
+ code = code_formatter(newlines=False)
+
+ queue_type = self.var_expr.generate(code)
+ if not queue_type.isOutPort:
+ self.error("The outport queue's type must have the 'outport' " +
+ "attribute. Type '%s' does not have this attribute.",
+ (queue_type))
+
+ var = Var(self.symtab, self.ident, self.location, self.queue_type.type,
+ str(code), self.pairs)
+ self.symtab.newSymbol(var)
diff --git a/src/mem/slicc/ast/PairAST.cc b/src/mem/slicc/ast/PairAST.cc
deleted file mode 100644
index c42843cce..000000000
--- a/src/mem/slicc/ast/PairAST.cc
+++ /dev/null
@@ -1,72 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index d1bb99b93..000000000
--- a/src/mem/slicc/ast/PairAST.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: PairAST.hh,v 3.1 2001/12/12 01:00:24 milo Exp $
- *
- */
-
-#ifndef PAIRAST_H
-#define PAIRAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/PairAST.py b/src/mem/slicc/ast/PairAST.py
new file mode 100644
index 000000000..347f4d361
--- /dev/null
+++ b/src/mem/slicc/ast/PairAST.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+class PairAST(AST):
+ def __init__(self, slicc, key, value):
+ super(PairAST, self).__init__(slicc)
+ self.key = key
+ self.value = value
+
+ def __repr__(self):
+ return '[%s=%s]' % (self.key, self.value)
diff --git a/src/mem/slicc/ast/PairListAST.cc b/src/mem/slicc/ast/PairListAST.cc
deleted file mode 100644
index 76892d437..000000000
--- a/src/mem/slicc/ast/PairListAST.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 7edcdc1e7..000000000
--- a/src/mem/slicc/ast/PairListAST.hh
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef PairListAST_H
-#define PairListAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/AST.hh"
-#include "mem/slicc/ast/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/PairListAST.py b/src/mem/slicc/ast/PairListAST.py
new file mode 100644
index 000000000..6afe3f4fa
--- /dev/null
+++ b/src/mem/slicc/ast/PairListAST.py
@@ -0,0 +1,37 @@
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+class PairListAST(AST):
+ def __init__(self, slicc):
+ super(PairListAST, self).__init__(slicc)
+
+ def __repr__(self):
+ return "[PairListAST] %r" % self.pairs
+
+ def addPair(self, pair_ast):
+ self[pair_ast.key] = pair_ast.value
diff --git a/src/mem/slicc/ast/PeekStatementAST.cc b/src/mem/slicc/ast/PeekStatementAST.cc
deleted file mode 100644
index 3e92446dd..000000000
--- a/src/mem/slicc/ast/PeekStatementAST.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/PeekStatementAST.hh"
-#include "mem/slicc/symbols/SymbolTable.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/TypeAST.hh"
-#include "mem/slicc/ast/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
deleted file mode 100644
index e8c65ce4f..000000000
--- a/src/mem/slicc/ast/PeekStatementAST.hh
+++ /dev/null
@@ -1,91 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef PEEKSTATEMENTAST_H
-#define PEEKSTATEMENTAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/PeekStatementAST.py b/src/mem/slicc/ast/PeekStatementAST.py
new file mode 100644
index 000000000..5186bf0d5
--- /dev/null
+++ b/src/mem/slicc/ast/PeekStatementAST.py
@@ -0,0 +1,73 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.StatementAST import StatementAST
+from slicc.symbols import Var
+
+class PeekStatementAST(StatementAST):
+ def __init__(self, slicc, queue_name, type_ast, statements, method):
+ super(PeekStatementAST, self).__init__(slicc)
+
+ self.queue_name = queue_name
+ self.type_ast = type_ast
+ self.statements = statements
+ self.method = method
+
+ def __repr__(self):
+ return "[PeekStatementAST: %r queue_name: %r type: %r %r]" % \
+ (self.method, self.queue_name, self.type_ast, self.statements)
+
+ def generate(self, code, return_type):
+ self.symtab.pushFrame()
+
+ msg_type = self.type_ast.type
+
+ # Add new local var to symbol table
+ var = Var(self.symtab, "in_msg", self.location, msg_type, "(*in_msg_ptr)",
+ self.pairs)
+ self.symtab.newSymbol(var)
+
+ # Check the queue type
+ self.queue_name.assertType("InPort")
+
+ # Declare the new "in_msg_ptr" variable
+ mtid = msg_type.ident
+ qcode = self.queue_name.var.code
+ code('''
+{
+ const $mtid* in_msg_ptr;
+ in_msg_ptr = dynamic_cast<const $mtid *>(($qcode).${{self.method}}());
+ assert(in_msg_ptr != NULL);
+''')
+
+ # The other statements
+ self.statements.generate(code, return_type)
+ self.symtab.popFrame()
+ code("}")
+
+ def findResources(self, resources):
+ self.statements.findResources(resources)
diff --git a/src/mem/slicc/ast/ReturnStatementAST.cc b/src/mem/slicc/ast/ReturnStatementAST.cc
deleted file mode 100644
index 8ec937c87..000000000
--- a/src/mem/slicc/ast/ReturnStatementAST.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 1fa1b36d6..000000000
--- a/src/mem/slicc/ast/ReturnStatementAST.hh
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef ReturnStatementAST_H
-#define ReturnStatementAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/ast/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/ReturnStatementAST.py b/src/mem/slicc/ast/ReturnStatementAST.py
new file mode 100644
index 000000000..1d08a7234
--- /dev/null
+++ b/src/mem/slicc/ast/ReturnStatementAST.py
@@ -0,0 +1,54 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.StatementAST import StatementAST
+
+class ReturnStatementAST(StatementAST):
+ def __init__(self, slicc, expr_ast):
+ super(ReturnStatementAST, self).__init__(slicc)
+
+ self.expr_ast = expr_ast
+
+ def __repr__(self):
+ return "[ReturnStatementAST: %r]" % self.expr_ast
+
+ def generate(self, code, return_type):
+ actual_type, ecode = self.expr_ast.inline(True)
+ code('return $ecode;')
+
+ # Is return valid here?
+ if return_type is None:
+ error("Invalid 'return' statement")
+
+ # The return type must match
+ if return_type != actual_type:
+ self.expr_ast.error("Return type miss-match, expected return " +
+ "type is '%s', actual is '%s'",
+ return_type, actual_type)
+
+ def findResources(self, resources):
+ self.expr_ast.findResources(resources)
diff --git a/src/mem/slicc/ast/StatementAST.cc b/src/mem/slicc/ast/StatementAST.cc
deleted file mode 100644
index 35627722a..000000000
--- a/src/mem/slicc/ast/StatementAST.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 9946541d3..000000000
--- a/src/mem/slicc/ast/StatementAST.hh
+++ /dev/null
@@ -1,88 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef STATEMENTAST_H
-#define STATEMENTAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/StatementAST.py b/src/mem/slicc/ast/StatementAST.py
new file mode 100644
index 000000000..017b2b1ed
--- /dev/null
+++ b/src/mem/slicc/ast/StatementAST.py
@@ -0,0 +1,34 @@
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+class StatementAST(AST):
+ def __init__(self, slicc, pairs=None):
+ super(StatementAST, self).__init__(slicc, pairs)
+
+ def findResources(self, resources):
+ pass
diff --git a/src/mem/slicc/ast/StatementListAST.cc b/src/mem/slicc/ast/StatementListAST.cc
deleted file mode 100644
index 0f5817f7c..000000000
--- a/src/mem/slicc/ast/StatementListAST.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 831e2481a..000000000
--- a/src/mem/slicc/ast/StatementListAST.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef STATEMENTLISTAST_H
-#define STATEMENTLISTAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/AST.hh"
-#include "mem/slicc/ast/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/StatementListAST.py b/src/mem/slicc/ast/StatementListAST.py
new file mode 100644
index 000000000..1475c5c97
--- /dev/null
+++ b/src/mem/slicc/ast/StatementListAST.py
@@ -0,0 +1,46 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+class StatementListAST(AST):
+ def __init__(self, slicc, statements):
+ super(StatementListAST, self).__init__(slicc)
+ if not isinstance(statements, (list, tuple)):
+ statements = [ statements ]
+ self.statements = statements
+
+ def __repr__(self):
+ return "[StatementListAST: %r]" % self.statements
+
+ def generate(self, code, return_type):
+ for statement in self.statements:
+ statement.generate(code, return_type)
+
+ def findResources(self, resources):
+ for statement in self.statements:
+ statement.findResources(resources)
diff --git a/src/mem/slicc/ast/TransitionDeclAST.cc b/src/mem/slicc/ast/TransitionDeclAST.cc
deleted file mode 100644
index 66b7ca132..000000000
--- a/src/mem/slicc/ast/TransitionDeclAST.cc
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/TransitionDeclAST.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index f07f0a3c2..000000000
--- a/src/mem/slicc/ast/TransitionDeclAST.hh
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: TransitionDeclAST.hh,v 3.2 2003/07/10 18:08:07 milo Exp $
- *
- */
-
-#ifndef TransitionDeclAST_H
-#define TransitionDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/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/TransitionDeclAST.py b/src/mem/slicc/ast/TransitionDeclAST.py
new file mode 100644
index 000000000..ef745fd50
--- /dev/null
+++ b/src/mem/slicc/ast/TransitionDeclAST.py
@@ -0,0 +1,54 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.symbols import Transition
+
+class TransitionDeclAST(DeclAST):
+ def __init__(self, slicc, states, events, next_state, pairs, actions):
+ super(TransitionDeclAST, self).__init__(slicc, pairs)
+
+ self.states = states
+ self.events = events
+ self.next_state = next_state
+ self.actions = actions
+
+ def __repr__(self):
+ return "[TransitionDecl: ]"
+
+ def generate(self):
+ machine = self.symtab.state_machine
+
+ if machine is None:
+ self.error("Transition declaration not part of a machine.")
+
+ for state in self.states:
+ next_state = self.next_state or state
+ for event in self.events:
+ t = Transition(self.symtab, machine, state, event, next_state,
+ self.actions, self.location, self.pairs)
+ machine.addTransition(t)
diff --git a/src/mem/slicc/ast/TypeAST.cc b/src/mem/slicc/ast/TypeAST.cc
deleted file mode 100644
index 7590b4e7c..000000000
--- a/src/mem/slicc/ast/TypeAST.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: TypeAST.C,v 3.1 2003/03/22 15:15:16 xu Exp $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index f8e1fdc24..000000000
--- a/src/mem/slicc/ast/TypeAST.hh
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: TypeAST.hh,v 3.2 2003/03/22 15:15:17 xu Exp $
- *
- */
-
-#ifndef TYPEAST_H
-#define TYPEAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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/TypeAST.py b/src/mem/slicc/ast/TypeAST.py
new file mode 100644
index 000000000..209859b8d
--- /dev/null
+++ b/src/mem/slicc/ast/TypeAST.py
@@ -0,0 +1,53 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+from slicc.symbols import Type
+
+class TypeAST(AST):
+ def __init__(self, slicc, ident):
+ super(TypeAST, self).__init__(slicc)
+
+ self.ident = ident
+
+ def __repr__(self):
+ return self.ident
+
+ def __str__(self):
+ return self.ident
+
+ @property
+ def type(self, assert_type=None):
+ type = self.symtab.find(self.ident, Type)
+ if not type:
+ self.error("Type '%s' not declared.", self)
+
+ if assert_type is not None and type != assert_type:
+ self.error("Type '%s' is should be type '%s'", self, assert_type)
+
+ return type
diff --git a/src/mem/slicc/ast/TypeDeclAST.cc b/src/mem/slicc/ast/TypeDeclAST.cc
deleted file mode 100644
index bbf2f8491..000000000
--- a/src/mem/slicc/ast/TypeDeclAST.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: TypeDeclAST.C,v 3.1 2003/03/22 15:15:17 xu Exp $
- *
- */
-
-#include "mem/slicc/ast/TypeDeclAST.hh"
-#include "mem/slicc/main.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index 8a72c0406..000000000
--- a/src/mem/slicc/ast/TypeDeclAST.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: TypeDeclAST.hh,v 3.2 2003/03/17 01:55:28 xu Exp $
- *
- */
-
-#ifndef TypeDeclAST_H
-#define TypeDeclAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/DeclAST.hh"
-#include "mem/slicc/ast/TypeAST.hh"
-#include "mem/slicc/ast/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/TypeDeclAST.py b/src/mem/slicc/ast/TypeDeclAST.py
new file mode 100644
index 000000000..d2cc04eff
--- /dev/null
+++ b/src/mem/slicc/ast/TypeDeclAST.py
@@ -0,0 +1,62 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.DeclAST import DeclAST
+from slicc.symbols.Type import Type
+
+class TypeDeclAST(DeclAST):
+ def __init__(self, slicc, type_ast, pairs, field_asts):
+ super(TypeDeclAST, self).__init__(slicc, pairs)
+
+ self.type_ast = type_ast
+ self.field_asts = field_asts
+
+ def __repr__(self):
+ return "[TypeDecl: %r]" % (self.type_ast)
+
+ def files(self, hh, cc, parent=None):
+ if "external" in self:
+ return
+
+ if parent:
+ ident = "%s_%s" % (parent, self.type_ast.ident)
+ else:
+ ident = self.type_ast.ident
+ hh.add("%s.hh" % ident)
+ cc.add("%s.cc" % ident)
+
+ def generate(self):
+ ident = str(self.type_ast)
+
+ # Make the new type
+ new_type = Type(self.symtab, ident, self.location, self.pairs,
+ self.state_machine)
+ self.symtab.newSymbol(new_type)
+
+ # Add all of the fields of the type to it
+ for field in self.field_asts:
+ field.generate(new_type)
diff --git a/src/mem/slicc/ast/TypeFieldAST.cc b/src/mem/slicc/ast/TypeFieldAST.cc
deleted file mode 100644
index 5657d023c..000000000
--- a/src/mem/slicc/ast/TypeFieldAST.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 144372047..000000000
--- a/src/mem/slicc/ast/TypeFieldAST.hh
+++ /dev/null
@@ -1,83 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef TypeFieldAST_H
-#define TypeFieldAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/symbols/StateMachine.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/PairListAST.hh"
-#include "mem/slicc/ast/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/TypeFieldAST.py b/src/mem/slicc/ast/TypeFieldAST.py
new file mode 100644
index 000000000..7dd4c74aa
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldAST.py
@@ -0,0 +1,32 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import AST
+
+class TypeFieldAST(AST):
+ def __init__(self, slicc, pairs):
+ super(TypeFieldAST, self).__init__(slicc, pairs)
diff --git a/src/mem/slicc/ast/TypeFieldEnumAST.cc b/src/mem/slicc/ast/TypeFieldEnumAST.cc
deleted file mode 100644
index 1a02f7edd..000000000
--- a/src/mem/slicc/ast/TypeFieldEnumAST.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/TypeFieldEnumAST.hh"
-#include "mem/slicc/symbols/State.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index cd02f03bb..000000000
--- a/src/mem/slicc/ast/TypeFieldEnumAST.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: TypeFieldEnumAST.hh,v 3.2 2003/07/10 18:08:07 milo Exp $
- *
- */
-
-#ifndef TypeFieldEnumAST_H
-#define TypeFieldEnumAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/symbols/StateMachine.hh"
-#include "mem/slicc/ast/TypeFieldAST.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/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/TypeFieldEnumAST.py b/src/mem/slicc/ast/TypeFieldEnumAST.py
new file mode 100644
index 000000000..d068666ad
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldEnumAST.py
@@ -0,0 +1,59 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.TypeFieldAST import TypeFieldAST
+from slicc.symbols import Event, State
+
+class TypeFieldEnumAST(TypeFieldAST):
+ def __init__(self, slicc, field_id, pairs_ast):
+ super(TypeFieldEnumAST, self).__init__(slicc, pairs_ast)
+
+ self.field_id = field_id
+ self.pairs_ast = pairs_ast
+
+ def __repr__(self):
+ return "[TypeFieldEnum: %r]" % self.field_id
+
+ def generate(self, type):
+ # Add enumeration
+ if not type.enumAdd(self.field_id, self.pairs_ast.pairs):
+ error("Duplicate enumeration: %s:%s" % (type, self.field_id))
+
+ # Fill machine info
+ machine = self.symtab.state_machine
+
+ if str(type) == "State":
+ if not machine:
+ error("State declaration not part of a machine.")
+ s = State(self.symtab, self.field_id, self.location, self.pairs)
+ machine.addState(s)
+
+ if str(type) == "Event":
+ if not machine:
+ error("Event declaration not part of a machine.")
+ e = Event(self.symtab, self.field_id, self.location, self.pairs)
+ machine.addEvent(e)
diff --git a/src/mem/slicc/ast/TypeFieldMemberAST.cc b/src/mem/slicc/ast/TypeFieldMemberAST.cc
deleted file mode 100644
index 1fe0f6d4b..000000000
--- a/src/mem/slicc/ast/TypeFieldMemberAST.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: TypeFieldMemberAST.C,v 3.1 2003/03/27 22:58:54 xu Exp $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 47355f3ac..000000000
--- a/src/mem/slicc/ast/TypeFieldMemberAST.hh
+++ /dev/null
@@ -1,91 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef TypeFieldMemberAST_H
-#define TypeFieldMemberAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/TypeFieldAST.hh"
-#include "mem/slicc/symbols/StateMachine.hh"
-#include "mem/slicc/ast/StatementListAST.hh"
-#include "mem/slicc/ast/PairListAST.hh"
-#include "mem/slicc/ast/ExprAST.hh"
-#include "mem/slicc/ast/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/TypeFieldMemberAST.py b/src/mem/slicc/ast/TypeFieldMemberAST.py
new file mode 100644
index 000000000..285d5b622
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldMemberAST.py
@@ -0,0 +1,57 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.TypeFieldAST import TypeFieldAST
+
+class TypeFieldMemberAST(TypeFieldAST):
+ def __init__(self, slicc, type_ast, field_id, pairs, rvalue):
+ super(TypeFieldMemberAST, self).__init__(slicc, pairs)
+
+ self.type_ast = type_ast
+ self.field_id = field_id
+ self.rvalue = rvalue
+
+ def __repr__(self):
+ return "[TypeFieldMember: %r]" % self.field_id
+
+ def generate(self, type):
+ # Lookup type
+ field_type = self.type_ast.type
+
+ # check type if this is a initialization
+ init_code = ""
+ if self.rvalue:
+ rvalue_type,init_code = self.rvalue.inline(True)
+ if field_type != rvalue_type:
+ self.error("Initialization type mismatch '%s' and '%s'" % \
+ (field_type, rvalue_type))
+
+ # Add data member to the parent type
+ if not type.dataMemberAdd(self.field_id, field_type, self.pairs,
+ init_code):
+
+ error("Duplicate data member: %s:%s" % (type_ptr, field_id))
diff --git a/src/mem/slicc/ast/TypeFieldMethodAST.cc b/src/mem/slicc/ast/TypeFieldMethodAST.cc
deleted file mode 100644
index 03c528f87..000000000
--- a/src/mem/slicc/ast/TypeFieldMethodAST.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id: TypeFieldMethodAST.C,v 3.1 2003/07/10 18:08:07 milo Exp $
- *
- */
-
-#include "mem/slicc/ast/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
deleted file mode 100644
index 10d53ef80..000000000
--- a/src/mem/slicc/ast/TypeFieldMethodAST.hh
+++ /dev/null
@@ -1,87 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id: TypeFieldMethodAST.hh,v 3.2 2003/07/10 18:08:07 milo Exp $
- *
- */
-
-#ifndef TYPEFIELDMETHODAST_H
-#define TYPEFIELDMETHODAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/TypeFieldAST.hh"
-#include "mem/slicc/ast/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/TypeFieldMethodAST.py b/src/mem/slicc/ast/TypeFieldMethodAST.py
new file mode 100644
index 000000000..337b15597
--- /dev/null
+++ b/src/mem/slicc/ast/TypeFieldMethodAST.py
@@ -0,0 +1,50 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.TypeFieldAST import TypeFieldAST
+
+class TypeFieldMethodAST(TypeFieldAST):
+ def __init__(self, slicc, return_type_ast, ident, type_asts, pairs):
+ super(TypeFieldMethodAST, self).__init__(slicc, pairs)
+
+ self.return_type_ast = return_type_ast
+ self.ident = ident
+ self.type_asts = type_asts
+
+ def __repr__(self):
+ return ""
+
+ def generate(self, type):
+ # Lookup return type
+ return_type = self.return_type_ast.type
+
+ # Lookup parameter types
+ types = [ t.type for t in self.type_asts ]
+
+ # Add method
+ if not type.methodAdd(self.ident, return_type, types):
+ error("Duplicate method: %s:%s()" % (type, self.ident))
diff --git a/src/mem/slicc/ast/VarExprAST.cc b/src/mem/slicc/ast/VarExprAST.cc
deleted file mode 100644
index 13e265540..000000000
--- a/src/mem/slicc/ast/VarExprAST.cc
+++ /dev/null
@@ -1,76 +0,0 @@
-
-/*
- * 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.hh
- *
- * $Id$
- *
- */
-
-#include "mem/slicc/ast/VarExprAST.hh"
-#include "mem/slicc/ast/StatementAST.hh"
-#include "mem/slicc/symbols/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
deleted file mode 100644
index ea32582a2..000000000
--- a/src/mem/slicc/ast/VarExprAST.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-
-/*
- * 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.hh
- *
- * Description:
- *
- * $Id$
- *
- */
-
-#ifndef VAREXPRAST_H
-#define VAREXPRAST_H
-
-#include "mem/slicc/slicc_global.hh"
-#include "mem/slicc/ast/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
diff --git a/src/mem/slicc/ast/VarExprAST.py b/src/mem/slicc/ast/VarExprAST.py
new file mode 100644
index 000000000..ac440bb68
--- /dev/null
+++ b/src/mem/slicc/ast/VarExprAST.py
@@ -0,0 +1,66 @@
+# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.ExprAST import ExprAST
+from slicc.symbols import Type, Var
+
+class VarExprAST(ExprAST):
+ def __init__(self, slicc, var):
+ super(VarExprAST, self).__init__(slicc)
+ self._var = var
+
+ def __repr__(self):
+ return "[VarExprAST: %r]" % self._var
+
+ @property
+ def name(self):
+ return str(self._var)
+
+ @property
+ def var(self):
+ var = self.symtab.find(self._var, Var)
+ if not var:
+ self.error("Unrecognized variable: %s", self._var)
+ return var
+
+ def assertType(self, type_ident):
+ expected_type = self.symtab.find(type_ident, Type)
+
+ if not expected_type:
+ self.error("There must be a type '%s' declared in this scope",
+ type_ident)
+
+ if self.var.type != expected_type:
+ self.error("Incorrect type: " + \
+ "'%s' is expected to be type '%s' not '%s'",
+ self.var.ident, expected_type, self.var.type)
+
+ def generate(self, code):
+ fix = code.nofix()
+ code("${{self.var.code}}")
+ code.fix(fix)
+ return self.var.type
diff --git a/src/mem/slicc/ast/__init__.py b/src/mem/slicc/ast/__init__.py
new file mode 100644
index 000000000..de50cbd49
--- /dev/null
+++ b/src/mem/slicc/ast/__init__.py
@@ -0,0 +1,69 @@
+# Copyright (c) 2009 The Hewlett-Packard Development Company
+# 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.
+
+from slicc.ast.AST import *
+
+# actual ASTs
+from slicc.ast.ActionDeclAST import *
+from slicc.ast.AssignStatementAST import *
+from slicc.ast.CheckAllocateStatementAST import *
+from slicc.ast.CheckStopSlotsStatementAST import *
+from slicc.ast.ChipComponentAccessAST import *
+from slicc.ast.CopyHeadStatementAST import *
+from slicc.ast.DeclAST import *
+from slicc.ast.DeclListAST import *
+from slicc.ast.EnqueueStatementAST import *
+from slicc.ast.EnumDeclAST import *
+from slicc.ast.EnumExprAST import *
+from slicc.ast.ExprAST import *
+from slicc.ast.ExprStatementAST import *
+from slicc.ast.FormalParamAST import *
+from slicc.ast.FuncCallExprAST import *
+from slicc.ast.FuncDeclAST import *
+from slicc.ast.IfStatementAST import *
+from slicc.ast.InPortDeclAST import *
+from slicc.ast.InfixOperatorExprAST import *
+from slicc.ast.LiteralExprAST import *
+from slicc.ast.MachineAST import *
+from slicc.ast.MemberExprAST import *
+from slicc.ast.MethodCallExprAST import *
+from slicc.ast.NewExprAST import *
+from slicc.ast.ObjDeclAST import *
+from slicc.ast.OutPortDeclAST import *
+from slicc.ast.PairAST import *
+from slicc.ast.PairListAST import *
+from slicc.ast.PeekStatementAST import *
+from slicc.ast.ReturnStatementAST import *
+from slicc.ast.StatementAST import *
+from slicc.ast.StatementListAST import *
+from slicc.ast.TransitionDeclAST import *
+from slicc.ast.TypeAST import *
+from slicc.ast.TypeDeclAST import *
+from slicc.ast.TypeFieldAST import *
+from slicc.ast.TypeFieldEnumAST import *
+from slicc.ast.TypeFieldMemberAST import *
+from slicc.ast.TypeFieldMethodAST import *
+from slicc.ast.VarExprAST import *