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

added Instruction class (#6)

parent 5e272eef
Branches
No related tags found
1 merge request!9Infrastructure: Type Hints, Instruction class and lists of instructions
#! /usr/bin/python3 #! /usr/bin/python3
from typing_extensions import override
from scripts.Infrastructure.Instruction import Instruction
alloc_template = """ alloc_template = """
@{TYPE}@* @{NAME}@ = (@{TYPE}@*) @{FUNCTION}@(@{NUM}@ @{SEP}@ sizeof(@{TYPE}@)); @{TYPE}@* @{NAME}@ = (@{TYPE}@*) @{FUNCTION}@(@{NUM}@ @{SEP}@ sizeof(@{TYPE}@));
...@@ -20,8 +22,8 @@ alloc_template = """ ...@@ -20,8 +22,8 @@ alloc_template = """
""" """
class AllocCall: class AllocCall (Instruction):
@override
def __init__(self, type, num_elements, name="buf", use_malloc=False): def __init__(self, type, num_elements, name="buf", use_malloc=False):
""" """
Creates a New allocation Call Creates a New allocation Call
...@@ -37,6 +39,7 @@ class AllocCall: ...@@ -37,6 +39,7 @@ class AllocCall:
self._num_elements = num_elements self._num_elements = num_elements
self._name = name self._name = name
@override
def __str__(self): def __str__(self):
if self._use_malloc: if self._use_malloc:
delim = '*' delim = '*'
......
#! /usr/bin/python3
class Instruction(object):
"""
Base class to represent an Instruction
"""
def __init__(self, str_representation):
self._str_representation = str_representation
def __str__(self):
return self._str_representation
#! /usr/bin/python3 #! /usr/bin/python3
from typing_extensions import override
from scripts.Infrastructure.Instruction import Instruction
from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT from scripts.Infrastructure.Variables import ERROR_MARKER_COMMENT
class MPI_Call: class MPI_Call (Instruction):
@override
def __init__(self, function, args, version): def __init__(self, function, args, version):
self._function = function self._function = function
self._args = args self._args = args
self._version = version self._version = version
self._has_error = False self._has_error = False
@override
def __str__(self): def __str__(self):
s = self._function + "(" s = self._function + "("
for k, v in self._args.items(): for k, v in self._args.items():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment