mirror of
https://github.com/RRZE-HPC/OSACA.git
synced 2026-01-07 03:30:06 +01:00
singelton for isa parsers
This commit is contained in:
@@ -15,9 +15,12 @@ class BaseParser(object):
|
||||
SEGMENT_EXT_ID = 'segment_extension'
|
||||
INSTRUCTION_ID = 'instruction'
|
||||
OPERANDS_ID = 'operands'
|
||||
_parser_constructed = False
|
||||
|
||||
def __init__(self):
|
||||
self.construct_parser()
|
||||
if not self._parser_constructed:
|
||||
self.construct_parser()
|
||||
self._parser_constructed = True
|
||||
|
||||
@staticmethod
|
||||
def detect_ISA(file_content):
|
||||
|
||||
@@ -7,6 +7,14 @@ from osaca.parser import AttrDict, BaseParser
|
||||
|
||||
|
||||
class ParserAArch64(BaseParser):
|
||||
_instance = None
|
||||
|
||||
# Singelton pattern, as this is created very many times
|
||||
def __new__(cls):
|
||||
if cls._instance is None:
|
||||
cls._instance = super(ParserAArch64, cls).__new__(cls)
|
||||
return cls._instance
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.isa = 'aarch64'
|
||||
|
||||
@@ -8,6 +8,14 @@ from osaca.parser import AttrDict, BaseParser
|
||||
|
||||
|
||||
class ParserX86ATT(BaseParser):
|
||||
_instance = None
|
||||
|
||||
# Singelton pattern, as this is created very many times
|
||||
def __new__(cls):
|
||||
if cls._instance is None:
|
||||
cls._instance = super(ParserX86ATT, cls).__new__(cls)
|
||||
return cls._instance
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.isa = 'x86'
|
||||
|
||||
Reference in New Issue
Block a user