ruby: slicc: slight code refactoring
authorNilay Vaish <nilay@cs.wisc.edu>
Thu, 20 Feb 2014 23:26:49 +0000 (17:26 -0600)
committerNilay Vaish <nilay@cs.wisc.edu>
Thu, 20 Feb 2014 23:26:49 +0000 (17:26 -0600)
src/mem/slicc/ast/MethodCallExprAST.py
src/mem/slicc/ast/ObjDeclAST.py

index cf30cfa964bb3430a66ed7201b1813f497b8abcf..bf133b3741d467de4b29605f49caa4b01b77b71b 100644 (file)
@@ -140,23 +140,21 @@ class MemberMethodCallExprAST(MethodCallExprAST):
 
                       implemented_paramTypes.append(implemented_paramType)
 
+                  implementedMethodId = ""
                   if implements_interface:
-                      implementedMethodId = obj_type.methodIdAbstract(self.proc_name,
-                                                                      implemented_paramTypes)
-                  else:
-                      implementedMethodId = ""
+                      implementedMethodId = obj_type.methodIdAbstract(
+                              self.proc_name, implemented_paramTypes)
 
                   if implementedMethodId not in obj_type.methods:
-                      self.error("Invalid method call: " \
-                                 "Type '%s' does not have a method %s, '%s' nor '%s'",
-                                 obj_type, self.proc_name, methodId, implementedMethodId)
-                  else:
-                      #
-                      # Replace the methodId with the implementedMethodId found in
-                      # the method list.
-                      #
-                      methodId = implementedMethodId
-                      return_type = obj_type.methods[methodId].return_type
+                      self.error("Invalid method call: Type '%s' " \
+                                 "does not have a method %s, '%s' nor '%s'",
+                                 obj_type, self.proc_name, methodId,
+                                 implementedMethodId)
+
+                  # Replace the methodId with the implementedMethodId
+                  # found in the method list.
+                  methodId = implementedMethodId
+                  return_type = obj_type.methods[methodId].return_type
 
         if return_type.isInterface:
             prefix = "static_cast<%s &>" % return_type.c_ident
index a87ede72454130ff1dfff39ccb11c98366380eb0..4fd85d1430edd7c6b7d44b340a6494d0921d774a 100644 (file)
@@ -39,8 +39,6 @@ class ObjDeclAST(DeclAST):
         return "[ObjDecl: %r]" % self.ident
 
     def generate(self):
-        machineComponentSym = False
-
         if "network" in self and not ("virtual_network" in self or
                                       "physical_network" in self) :
             self.error("Network queues require a 'virtual_network' attribute")
@@ -84,7 +82,3 @@ class ObjDeclAST(DeclAST):
             machine.addObject(v)
 
         self.symtab.newSymbol(v)
-
-        # used to cheat-- that is, access components in other machines
-        if machineComponentSym:
-            self.symtab.newMachComponentSym(v)