Skip to content
This repository
Browse code

consolidate insert_multiple and insert_single on the Asm class

  • Loading branch information...
commit 6ff6f93397f18f8764caa4e4de4a85c23942ef81 1 parent 03ce919
Bryan Bishop authored

Showing 1 changed file with 35 additions and 28 deletions. Show diff stats Hide diff stats

  1. +35 28 extras/crystal.py
63 extras/crystal.py
@@ -5731,35 +5731,42 @@ def insert(self, new_object):
5731 5731 raise Exception, "unable to insert object into Asm"
5732 5732 self.labels.append(new_object.label)
5733 5733 return True
5734   - def insert_single_with_dependencies(self, object0):
5735   - global_dependencies = set([object0])
5736   - poopbutt = get_dependencies_for(object0, global_dependencies=global_dependencies, recompute=False)
5737   - objects = global_dependencies
5738   - objects.update(poopbutt)
5739   - new_objects = copy(objects)
5740   - for object in objects:
5741   - if hasattr(object, "dependencies") and object.dependencies == None:
5742   - new_objects.update(object.get_dependencies())
5743   - for object in new_objects:
5744   - if isinstance(object, ScriptPointerLabelParam):
5745   - continue
5746   - #if object in self.parts:
5747   - # if self.debug:
5748   - # print "already inserted -- object.__class__="+str(object.__class__)+" object is: "+str(object)+\
5749   - # " for object.__class__="+str(object0.__class__)+" object="+str(object0)
5750   - # continue
5751   - if self.debug:
5752   - print " object is: " + str(object)
5753   - self.insert(object)
5754   -
5755   - #just some old debugging
5756   - #if object.label.name == "UnknownText_0x60128":
5757   - # raise Exception, "debugging..."
5758   - #elif object.label.name == "UnknownScript_0x60011":
5759   - # raise Exception, "debugging.. dependencies are: " + str(object.dependencies) + " versus: " + str(object.get_dependencies())
  5734 + def insert_with_dependencies(self, input):
  5735 + if type(input) == list:
  5736 + input_objects = input
  5737 + else:
  5738 + input_objects = [input]
  5739 +
  5740 + for object0 in input_objects:
  5741 + global_dependencies = set([object0])
  5742 + poopbutt = get_dependencies_for(object0, global_dependencies=global_dependencies, recompute=False)
  5743 + objects = global_dependencies
  5744 + objects.update(poopbutt)
  5745 + new_objects = copy(objects)
  5746 + for object in objects:
  5747 + if hasattr(object, "dependencies") and object.dependencies == None:
  5748 + new_objects.update(object.get_dependencies())
  5749 + for object in new_objects:
  5750 + if isinstance(object, ScriptPointerLabelParam):
  5751 + continue
  5752 + #if object in self.parts:
  5753 + # if self.debug:
  5754 + # print "already inserted -- object.__class__="+str(object.__class__)+" object is: "+str(object)+\
  5755 + # " for object.__class__="+str(object0.__class__)+" object="+str(object0)
  5756 + # continue
  5757 + if self.debug:
  5758 + print " object is: " + str(object)
  5759 + self.insert(object)
  5760 +
  5761 + #just some old debugging
  5762 + #if object.label.name == "UnknownText_0x60128":
  5763 + # raise Exception, "debugging..."
  5764 + #elif object.label.name == "UnknownScript_0x60011":
  5765 + # raise Exception, "debugging.. dependencies are: " + str(object.dependencies) + " versus: " + str(object.get_dependencies())
  5766 + def insert_single_with_dependencies(self, object):
  5767 + self.insert_with_dependencies(object)
5760 5768 def insert_multiple_with_dependencies(self, objects):
5761   - for object in objects:
5762   - self.insert_single_with_dependencies(object)
  5769 + self.insert_with_dependencies(objects)
5763 5770 def insert_all(self, limit=100):
5764 5771 count = 0
5765 5772 for each in script_parse_table.items():

0 comments on commit 6ff6f93

Please sign in to comment.
Something went wrong with that request. Please try again.