# Path: x86tokenizer.py
# class tokenizeError(Exception):pass
# REGISTER,OPCODE,COMMA,OPERAND,LBRACKET,RBRACKET,NUMBER,SYMBOL,STRING = range(1,10)
# def tokenizeString(s,reToProcess):
# def tokenizeInstDef(s):
# def tokenizeInst(s):
# 
# Path: x86inst.py
# class OpcodeTooShort(Exception):pass
# class OpcodeNeedsModRM(Exception):pass # for /d info and SIB calculation
# class x86instError(Exception):pass
# class OpcodeDict(dict):
# class MnemonicDict(dict):
# class ModRM:
# class instruction:
# class instructionInstance:
#     def __getitem__(self,key):
#     def __setitem__(self,key,value):
#     def GetOp(self,opcode,modRM=None):
#     def __setitem__(self,key,val):
# def longToBytes(long, bytes=4):
# def longToString(long, bytes=4):
# def longToBytesRepr(long,bytes=4):
#     def __init__(self,byte=None):
#     def LoadFromByte(self,byte):
#     def SaveToByte(self):
#     def HasSIB(self):
#     def RegOpString(self,typ):
#     def RMString(self,typ=None):
#     def GetDisplacementSize(self):
#     def __init__(self,opstr,inststr,desc):
#     def loadRBWD(self,plus,reg):
#     def setOpcodeAndFlags(self):
#     def setHasFlags(self):
#     def GetInstance(self):
#     def __str__(self):
#     def __init__(self,inst):
#     def GetSymbolPatchins(self,modrm=None):
#     def GetSuffixSize(self,modrm=None):
#     def GetInstructionSize(self):
#     def NextInstructionLoc(self):
#     def LoadData(self, data):
#     def DataText(self,data,size,skip=False):
#     def LoadConcreteValues(self, toks):
#     def OpDataAsString(self):
#     def OpText(self):
#             OS = self.OpcodeString
#             IS = self.InstructionString
#             ID = self.Description
#             OS = OS.replace(plus,plus[1:])
#             OS = OS.replace("%X" % self.Opcode[0], '%X' % (self.Opcode[0] + i))
#             IS = IS.replace(reg, regOpcode[reg][i])
# RELATIVE,DIRECT = range(1,3)


from x86tokenizer import (tokenizeInst,
                          REGISTER,OPCODE,COMMA,OPERAND,
                          LBRACKET,RBRACKET,NUMBER,SYMBOL,STRING,
                          symbolRe,stringRe)
from x86inst import mnemonicDict, rb, rw, rd, instructionInstance
from tokenize import Number
from pyasm.loggers import x86asmLogger, x86sourceLogger, x86apiLogger
import types, re

def printBestMatch(s):
    print "Best match for '%s' => '%s'" % (s,findBestMatch(s).InstructionString)

##################################################################
## END OF Find right instruction def based on concrete instruction
##################################################################

class labelRef:
    def __init__(self, name):
        self.Name = name
        
class label:
    def __init__(self, name,typ=0):
        self.Name = name
        self.Address = 0x0
        self.Type = typ

class labelDict(dict):
    def __setitem__(self,key,val):
        if self.has_key(key):
            raise x86asmError("Duplicate Label Declaration '%s'" % key)
        else:
            dict.__setitem__(self,key,val)

class constDict(dict):
    def __setitem__(self,key,val):
        if self.has_key(key):
            raise x86asmError("Duplicate Constant Declaration '%s'" % key)
        else:

# Path: x86tokenizer.py
# class tokenizeError(Exception):pass
# REGISTER,OPCODE,COMMA,OPERAND,LBRACKET,RBRACKET,NUMBER,SYMBOL,STRING = range(1,10)
# def tokenizeString(s,reToProcess):
# def tokenizeInstDef(s):
# def tokenizeInst(s):
# 
# Path: x86inst.py
# class OpcodeTooShort(Exception):pass
# class OpcodeNeedsModRM(Exception):pass # for /d info and SIB calculation
# class x86instError(Exception):pass
# class OpcodeDict(dict):
# class MnemonicDict(dict):
# class ModRM:
# class instruction:
# class instructionInstance:
#     def __getitem__(self,key):
#     def __setitem__(self,key,value):
#     def GetOp(self,opcode,modRM=None):
#     def __setitem__(self,key,val):
# def longToBytes(long, bytes=4):
# def longToString(long, bytes=4):
# def longToBytesRepr(long,bytes=4):
#     def __init__(self,byte=None):
#     def LoadFromByte(self,byte):
#     def SaveToByte(self):
#     def HasSIB(self):
#     def RegOpString(self,typ):
#     def RMString(self,typ=None):
#     def GetDisplacementSize(self):
#     def __init__(self,opstr,inststr,desc):
#     def loadRBWD(self,plus,reg):
#     def setOpcodeAndFlags(self):
#     def setHasFlags(self):
#     def GetInstance(self):
#     def __str__(self):
#     def __init__(self,inst):
#     def GetSymbolPatchins(self,modrm=None):
#     def GetSuffixSize(self,modrm=None):
#     def GetInstructionSize(self):
#     def NextInstructionLoc(self):
#     def LoadData(self, data):
#     def DataText(self,data,size,skip=False):
#     def LoadConcreteValues(self, toks):
#     def OpDataAsString(self):
#     def OpText(self):
#             OS = self.OpcodeString
#             IS = self.InstructionString
#             ID = self.Description
#             OS = OS.replace(plus,plus[1:])
#             OS = OS.replace("%X" % self.Opcode[0], '%X' % (self.Opcode[0] + i))
#             IS = IS.replace(reg, regOpcode[reg][i])
# RELATIVE,DIRECT = range(1,3)


# Path: x86asm.py
from x86tokenizer import (tokenizeInst,
                          REGISTER,OPCODE,COMMA,OPERAND,
                          LBRACKET,RBRACKET,NUMBER,SYMBOL,STRING,
                          symbolRe,stringRe)
from x86inst import mnemonicDict, rb, rw, rd, instructionInstance
from tokenize import Number
from pyasm.loggers import x86asmLogger, x86sourceLogger, x86apiLogger
import types, re


def printBestMatch(s):
    print "Best match for '%s' => '%s'" % (s,findBestMatch(s).InstructionString)

##################################################################
## END OF Find right instruction def based on concrete instruction
##################################################################

class labelRef:
    def __init__(self, name):
        self.Name = name
        
class label:
    def __init__(self, name,typ=0):
        self.Name = name
        self.Address = 0x0
        self.Type = typ

class labelDict(dict):
    def __setitem__(self,key,val):
        if self.has_key(key):
            raise x86asmError("Duplicate Label Declaration '%s'" % key)
        else:
            dict.__setitem__(self,key,val)

class constDict(dict):
    def __setitem__(self,key,val):
        if self.has_key(key):
            raise x86asmError("Duplicate Constant Declaration '%s'" % key)
        else:

            dict.__setitem__(self,key, (NUMBER,val) )