Skip to content

Commit

Permalink
Backwards compatibility for biome topping
Browse files Browse the repository at this point in the history
  • Loading branch information
dalbothek committed Apr 4, 2012
1 parent f0f9b2a commit f5e7d17
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 8 additions & 5 deletions burger/toppings/biomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ class BiomeTopping(Topping):

@staticmethod
def act(aggregate, jar, verbose=False):
biomes = aggregate.setdefault("biomes", {})
if "biome.superclass" not in aggregate["classes"]:
return
superclass = aggregate["classes"]["biome.superclass"]
cf = jar.open_class(superclass)
method = cf.methods.find_one(name="<clinit>")
tmp = None
stack = None
biomes = aggregate.setdefault("biomes", {})
for ins in method.instructions:
if ins.opcode == 187: # new
if tmp is not None:
biomes[tmp["id"]] = tmp
biomes[tmp["name"]] = tmp
stack = []
tmp = {
"calls": {},
Expand All @@ -60,13 +62,13 @@ def act(aggregate, jar, verbose=False):
elif tmp is None:
continue
elif ins.opcode == 183: # invokespecial
const = cf.constants[ins.operands[0][1]]
name = const["name_and_type"]["name"]["value"]
if len(stack) == 1:
tmp["id"] = stack.pop()
elif len(stack) >= 2:
const = cf.constants[ins.operands[0][1]]
name = const["name_and_type"]["name"]["value"]
tmp["calls"][name] = [stack.pop(), stack.pop()]
else:
elif name != "<init>":
tmp["rainfall"] = 0
elif ins.opcode == 182: # invokevirtual
if len(stack) == 1 and "color" not in tmp:
Expand Down Expand Up @@ -107,3 +109,4 @@ def map_methods(biomes):
keys = biome["calls"].keys()
keys.remove(call)
return (call, keys[0])
return (None, None)
3 changes: 1 addition & 2 deletions burger/toppings/identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ def identify(cf):
# Biome
const = cf.constants.find_one(
ConstantType.STRING,
lambda c: ("Please avoid temperatures in the range 0.1 - 0.2 " +
"because of snow") in c["string"]["value"]
lambda c: ("Plains") in c["string"]["value"]
)

if const:
Expand Down

0 comments on commit f5e7d17

Please sign in to comment.