1 /*
2 
3     This file is part of the Maude 2 interpreter.
4 
5     Copyright 1997-2003 SRI International, Menlo Park, CA 94025, USA.
6 
7     This program is free software; you can redistribute it and/or modify
8     it under the terms of the GNU General Public License as published by
9     the Free Software Foundation; either version 2 of the License, or
10     (at your option) any later version.
11 
12     This program is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16 
17     You should have received a copy of the GNU General Public License
18     along with this program; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
20 
21 */
22 
23 //
24 //      Implementation for VariableLhsAutomaton.
25 //
26 
27 //      utility stuff
28 #include "macros.hh"
29 #include "vector.hh"
30 #include "indent.hh"
31 
32 //      forward declarations
33 #include "interface.hh"
34 #include "core.hh"
35 
36 //      interface class definitions
37 #include "symbol.hh"
38 #include "dagNode.hh"
39 #include "lhsAutomaton.hh"
40 
41 //      core class definitions
42 #include "variableSymbol.hh"
43 #include "variableInfo.hh"
44 #include "substitution.hh"
45 #include "variableLhsAutomaton.hh"
46 
VariableLhsAutomaton(int index,const Sort * sort,bool copyToAvoidOverwriting)47 VariableLhsAutomaton::VariableLhsAutomaton(int index,
48 					   const Sort* sort,
49 					   bool copyToAvoidOverwriting)
50   : index(index),
51     sort(sort),
52     copyToAvoidOverwriting(copyToAvoidOverwriting)
53 {
54 }
55 
56 bool
match(DagNode * subject,Substitution & solution,Subproblem * & returnedSubproblem,ExtensionInfo * extensionInfo)57 VariableLhsAutomaton::match(DagNode* subject,
58 			    Substitution& solution,
59 			    Subproblem*& returnedSubproblem,
60 			    ExtensionInfo* extensionInfo)
61 {
62   return subject->matchVariable(index,
63 				sort,
64 				copyToAvoidOverwriting,
65 				solution,
66 				returnedSubproblem,
67 				extensionInfo);
68 }
69 
70 #ifdef DUMP
71 void
dump(ostream & s,const VariableInfo & variableInfo,int indentLevel)72 VariableLhsAutomaton::dump(ostream& s, const VariableInfo& variableInfo, int indentLevel)
73 {
74   s << Indent(indentLevel) << "Begin{VariableLhsAutomaton}\n";
75   s << Indent(indentLevel + 1) << "index = " << index <<
76     " \"" << variableInfo.index2Variable(index) <<
77     "\"\tsort = " <<  sort <<
78     "\tcopyToAvoidOverwriting = " << copyToAvoidOverwriting << '\n';
79   s << Indent(indentLevel) << "End{VariableLhsAutomaton}\n";
80 }
81 #endif
82