Commits

matusz  committed 1ecb237

corrected function calling for 0-param functions

  • Participants
  • Parent commits 07c3a96

Comments (0)

Files changed (1)

       if mnemonic in ("FC_SUBPROC","FC_DOPROC"): # subproc call syntax
         called_func = self.expstack.pop()
         parcnt = string.atoi(self.expstack.pop())
-        pars = self.expstack[-parcnt:]
+        if parcnt>0:
+          pars = self.expstack[-parcnt:]
+        else:
+          pars = []
+        #print "DEBUG parcnt",parcnt
+        #print "DEBUG pars",pars
         parstr = ", ".join(pars)
         if mnemonic == "FC_DOPROC":
           if parcnt == 0:
             parstr = ""
           else:
             parstr = "WITH "+parstr
-        self.expstack = self.expstack[:-parcnt] + [called_func, parstr]
+        #print "DEBUG st before", self.expstack
+        if parcnt > 0:
+          del(self.expstack[-parcnt:])
+        self.expstack = self.expstack + [called_func, parstr]
+        #print "DEBUG st after", self.expstack
 
       elif mnemonic == 'SP_INDEX_END':
          self.indstack = []
         
       elif opc_data["OP_STACKPR"] >=2 :
         a = opc_data["OP_STACKPR"]
+        #print "DEBUG a", a
+        #print "DEBUG stack", self.expstack
         p = self.expstack[-a:]
+        #print "DEBUG p", p
         p = tuple(p)
         format=opc_data["OP_STRING"]
         if opc_data["OP_WORDPR"]==-9:
           format=format+prm[1]
         del(self.expstack[-a:])
+        #print "DEBUG del params", self.expstack
+        #print "DEBUG format[", format,"]"
         res = format % p
         
       else:
         declip_line += "%s" % res.rstrip()
       elif has_result == 1:
         self.expstack.append(res.rstrip())
+        #print "DEBUG append res", self.expstack
       if mnemonic == "FC_JMPIFFALSE":
         self.expstack.append(["FC_JMPIFFALSE", pos, pos+string.atoi(prm[1])+3])
     return 1+prm[0], disass_line, declip_line
 
   def getSmb(self, num):
     '''return a symbol and its module from table structure'''
-#    import pprint
-#    pp = pprint.PrettyPrinter(indent=4)
 #    print "GETSMB %d" % num
     if num == 0:
       return "<NULL>", "<NULL>"
     symbols = self.symbdict
     modules = {}
     for ii in symbols.keys():
-      modules[symbols[ii][0]["off2"]] = symbols[ii][0]
+      modules[(symbols[ii][0]["off1"],symbols[ii][0]["off2"])] = symbols[ii][0]
     module_list = modules.keys()
     module_list.sort()
-#    pp.pprint( module_list)
-#    pp.pprint( modules)
+    #import pprint
+    #pp = pprint.PrettyPrinter(indent=4)
+    #print "DEBUG1 module_list"
+    #pp.pprint( module_list)
+    #print "DEBUG2 modules"
+    #pp.pprint( modules)
+    #print "DEBUG fp.tell (%s,%s)" %(self.fp.tell(),self.fp.tell()-self.pcode)
     for ii in module_list:
-      if ii < self.fp.tell() - self.pcode:
+      #print "DEBUG ii", ii
+      if ii[1] < self.fp.tell() - self.pcode:
         module = modules[ii]["symbol"]
-    print "DEBUG: m: %s; n: %s" %(module,num)
+    #print "DEBUG3: m: %s; n: %s" %(module,num)
     return module, symbols[module][num-1]["symbol"]
 
   def getStr(self):