Skip to content
Snippets Groups Projects
Commit 7b684fd6 authored by Jammer, Tim's avatar Jammer, Tim
Browse files

added identifier for instructions

parent d918d38f
No related branches found
No related tags found
1 merge request!14Infrastructure: Remove Instructionblock
...@@ -25,7 +25,8 @@ alloc_template = """ ...@@ -25,7 +25,8 @@ alloc_template = """
class AllocCall(Instruction): class AllocCall(Instruction):
@override @override
def __init__(self, type: str, num_elements: str, name: str = "buf", use_malloc: bool = False): def __init__(self, type: str, num_elements: str, name: str = "buf", use_malloc: bool = False,
identifier: str = None):
""" """
Creates a New allocation Call Creates a New allocation Call
...@@ -35,7 +36,7 @@ class AllocCall(Instruction): ...@@ -35,7 +36,7 @@ class AllocCall(Instruction):
name: name of buffer variable name: name of buffer variable
use_malloc: True: use Malloc, False: use calloc for allocation use_malloc: True: use Malloc, False: use calloc for allocation
""" """
super().__init__("") super().__init__("", identifier)
self._use_malloc = use_malloc self._use_malloc = use_malloc
self._type = type self._type = type
self._num_elements = num_elements self._num_elements = num_elements
......
#! /usr/bin/python3 #! /usr/bin/python3
from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_MARKER_COMMENT_END
class Instruction(object): class Instruction(object):
""" """
Base class to represent an Instruction Base class to represent an Instruction
the identifier is used, in order to reference that instruction in the Template Manager (e.g. to change it). can be None
""" """
def __init__(self, str_representation): def __init__(self, str_representation: str, identifier: str = None):
self._str_representation = str_representation self._str_representation = str_representation
self._has_error = False self._has_error = False
self._identifier = identifier
def set_has_error(self, has_error: bool = True): def set_has_error(self, has_error: bool = True):
self._has_error = has_error self._has_error = has_error
def get_identifier(self) -> str:
return self._identifier
def set_identifier(self, identifier: str):
self._identifier = identifier
def __str__(self): def __str__(self):
if self._has_error: if self._has_error:
return ERROR_MARKER_COMMENT_BEGIN + self._str_representation + ERROR_MARKER_COMMENT_END return ERROR_MARKER_COMMENT_BEGIN + self._str_representation + ERROR_MARKER_COMMENT_END
......
...@@ -9,12 +9,11 @@ from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_M ...@@ -9,12 +9,11 @@ from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT_BEGIN, ERROR_M
class MPICall(Instruction): class MPICall(Instruction):
@override @override
def __init__(self, function: str, args: typing.OrderedDict[str, str], version: str): def __init__(self, function: str, args: typing.OrderedDict[str, str], version: str, identifier: str = None):
super().__init__("") super().__init__("", identifier)
self._function = function self._function = function
self._args = args self._args = args
self._version = version self._version = version
self._has_error = False
@override @override
def __str__(self): def __str__(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment