# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):
# 
# Path: awake/operand.py
# class ProcAddress(AddressConstant):
#     link_prefix = "/proc/"
#     html_class = "proc-addr"
# 
# class DataAddress(AddressConstant):
#     link_prefix = "/data/"
#     html_class = "data-addr"
# 
# Path: awake/procedure.py
# def loadProcedureRange(proj, addr):
#     return ProcedureRangeAnalysis(proj, addr, getLimit(proj, addr))
# 
# Path: awake/jumptable.py
# class JumpTable(object):
#     def __init__(self, proj, addr):
#         self.addr = addr
#         self.targets = []
# 
#         for i in range(256):
#             a = addr.offset(i*2)
#             lo = proj.rom.get(a)
#             hi = proj.rom.get(a.offset(1))
#             value = address.fromVirtualAndCurrent((hi<<8) | lo, addr)
# 
#             if not value.inPhysicalMem():
#                 break
# 
#             self.targets.append(ProcAddress(value))
# 
#     def render(self, renderer):
#         with renderer.lineAddress(self.addr):
#             with renderer.comment():
#                 renderer.hline()
#                 renderer.startNewLine()
#                 renderer.write('jumptable ')
#                 renderer.writeSymbol(self.addr, 'jumptable')
#                 renderer.hline()
#         with renderer.indent():
#             i = 0
#             for t in self.targets:
#                 with renderer.lineAddress(self.addr.offset(i*2)):
#                     renderer.startNewLine()
#                     renderer.write(str(i) + ' -> ')
#                     t.render(renderer)
#                 i += 1


from awake import address
from awake.operand import ProcAddress, DataAddress
from awake.procedure import loadProcedureRange
from awake.jumptable import JumpTable
# This file is part of Awake - GB decompiler.
# Copyright (C) 2014  Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Page(object):
    has_name_form = False

    def __init__(self, proj, url):
        self.proj = proj
        self.url = url
        self.load()

class ProcedureFlowPage(Page):
    has_name_form = True

    def load(self):
        p = self.url.split('/')

# Path: awake/address.py
# BANK_SIZE = 0x4000
# class BadAddressException(Exception):
# class Address(object):
#     def __init__(self, addr):
#     def __str__(self):
# def fromVirtual(virtual):
# def fromVirtualAndBank(virtual, bank):
# def fromVirtualAndCurrent(virtual, current):
# def fromPhysical(physical):
# def fromConventional(conventional):
#     def __init__(self, address):
#     def virtual(self):
#     def bank(self):
#     def isAmbiguous(self):
#     def inBankedSpace(self):
#     def inPhysicalMem(self):
#     def physical(self):
#     def offset(self, offset):
#     def withBankSpecified(self, bank):
#     def __lt__(self, other):
#     def __eq__(self, other):
#     def __ne__(self, other):
#     def __hash__(self):
#     def __str__(self):
#     def __repr__(self):
# 
# Path: awake/operand.py
# class ProcAddress(AddressConstant):
#     link_prefix = "/proc/"
#     html_class = "proc-addr"
# 
# class DataAddress(AddressConstant):
#     link_prefix = "/data/"
#     html_class = "data-addr"
# 
# Path: awake/procedure.py
# def loadProcedureRange(proj, addr):
#     return ProcedureRangeAnalysis(proj, addr, getLimit(proj, addr))
# 
# Path: awake/jumptable.py
# class JumpTable(object):
#     def __init__(self, proj, addr):
#         self.addr = addr
#         self.targets = []
# 
#         for i in range(256):
#             a = addr.offset(i*2)
#             lo = proj.rom.get(a)
#             hi = proj.rom.get(a.offset(1))
#             value = address.fromVirtualAndCurrent((hi<<8) | lo, addr)
# 
#             if not value.inPhysicalMem():
#                 break
# 
#             self.targets.append(ProcAddress(value))
# 
#     def render(self, renderer):
#         with renderer.lineAddress(self.addr):
#             with renderer.comment():
#                 renderer.hline()
#                 renderer.startNewLine()
#                 renderer.write('jumptable ')
#                 renderer.writeSymbol(self.addr, 'jumptable')
#                 renderer.hline()
#         with renderer.indent():
#             i = 0
#             for t in self.targets:
#                 with renderer.lineAddress(self.addr.offset(i*2)):
#                     renderer.startNewLine()
#                     renderer.write(str(i) + ' -> ')
#                     t.render(renderer)
#                 i += 1


# Path: awake/pages.py
from awake import address
from awake.operand import ProcAddress, DataAddress
from awake.procedure import loadProcedureRange
from awake.jumptable import JumpTable

# This file is part of Awake - GB decompiler.
# Copyright (C) 2014  Wojciech Marczenko (devdri) <wojtek.marczenko@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Page(object):
    has_name_form = False

    def __init__(self, proj, url):
        self.proj = proj
        self.url = url
        self.load()

class ProcedureFlowPage(Page):
    has_name_form = True

    def load(self):
        p = self.url.split('/')

        self.addr = address.fromConventional(p[2])