changeset 6f433e7f9767 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=6f433e7f9767
description:
        slicc: improve support for prefix operations

        This patch fixes the type handling when prefix operations are used.  
Previously
        prefix operators would assume a void return type, which made it 
impossible to
        combine prefix operations with other expressions.  This patch allows 
SLICC
        programmers to use prefix operations more naturally.

diffstat:

 src/mem/slicc/ast/OperatorExprAST.py |  16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diffs (27 lines):

diff -r 2b4fe083d17b -r 6f433e7f9767 src/mem/slicc/ast/OperatorExprAST.py
--- a/src/mem/slicc/ast/OperatorExprAST.py      Mon Jul 20 09:15:18 2015 -0500
+++ b/src/mem/slicc/ast/OperatorExprAST.py      Mon Jul 20 09:15:18 2015 -0500
@@ -107,8 +107,22 @@
         opcode = self.slicc.codeFormatter()
         optype = self.operand.generate(opcode)
 
+        # Figure out what the input and output types should be
+        opmap = {"!": "bool", "-": "int", "++": "Scalar"}
+        if self.op in opmap:
+            output = opmap[self.op]
+            type_in_symtab = self.symtab.find(opmap[self.op], Type)
+            if (optype != type_in_symtab):
+                self.error("Type mismatch: right operand of " +
+                           "unary operator '%s' must be of type '%s'. ",
+                           self.op, type_in_symtab)
+        else:
+            self.error("Invalid prefix operator '%s'",
+                       self.op)
+
+        # All is well
         fix = code.nofix()
         code("(${{self.op}} $opcode)")
         code.fix(fix)
 
-        return self.symtab.find("void", Type)
+        return self.symtab.find(output, Type)
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to