-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6987f9
commit ab68709
Showing
1 changed file
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,52 @@ | ||
|
||
from parser.cfg_block import CFGBlock | ||
|
||
class CFGFunction: | ||
pass | ||
def __init__(self,name, args, ret, entry): | ||
self.name = name | ||
self.blocks : Dict[str, CFGBlock] = {} | ||
self.arguments = args | ||
self.returns = ret | ||
self.entry = entry | ||
self.exits = [] | ||
|
||
|
||
def add_block(self, block:CFGBlock) -> None: | ||
block_id = block.get_block_id() | ||
|
||
if block_id in self.blocks: | ||
if block_id in self.blocks: | ||
print("WARNING: You are overwritting an existing block") | ||
|
||
self.blocks[block_id] = block | ||
|
||
def get_block(self, block_id): | ||
return self.blocks[block_id] | ||
|
||
def get_name(self): | ||
return self.name | ||
|
||
def get_arguments(self): | ||
return self.arguments | ||
|
||
def get_exit_points(self): | ||
return self.exits | ||
|
||
def get_entry_point(self): | ||
return self.entry | ||
|
||
def get_return_arguments(self): | ||
return self.returns | ||
|
||
def add_exit_point(self, block_id): | ||
if block_id not in self.exits: | ||
self.exits.append(block_id) | ||
|
||
def build_spec(self): | ||
list_spec = [] | ||
for b in self.blocks: | ||
block = self.blocks[b] | ||
spec = block.build_spec() | ||
list_spec.append(spec) | ||
|
||
return list_spec | ||
|