merge into main
This commit is contained in:
24
interpreter/Function_scope.py
Normal file
24
interpreter/Function_scope.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from typing import Iterable, List
|
||||
from draw.Iinstruction import Iinstruction
|
||||
|
||||
class Function_scope(Iterable):
|
||||
def __init__(self, child_instructions: List[Iinstruction], name: str, return_type: str, args: List[str]) -> None:
|
||||
self.contents = child_instructions
|
||||
self.name = name
|
||||
self.return_type = return_type
|
||||
self.args = args
|
||||
|
||||
def get_height(self) -> int:
|
||||
h = 0.0
|
||||
for inst in self.contents:
|
||||
h += inst.getblkheight()
|
||||
return int(h)
|
||||
|
||||
def get_width(self) -> int:
|
||||
w = 200.0
|
||||
for inst in self.contents:
|
||||
w = max(w, inst.getblkwidth())
|
||||
return int(w)
|
||||
|
||||
def __iter__(self):
|
||||
return self.contents.__iter__()
|
||||
@@ -10,7 +10,11 @@ from typing import Dict, List, Match, Tuple, Union, Iterable
|
||||
|
||||
from errors.custom import InterpreterException, JavaSyntaxError, ScopeNotFoundException
|
||||
from draw.Iinstruction import *
|
||||
<<<<<<< HEAD
|
||||
from interpreter.function_scope import *
|
||||
=======
|
||||
from interpreter.Function_scope import Function_scope
|
||||
>>>>>>> main
|
||||
|
||||
logging.warning("""Because the Interpreter is still WIP, some Java language features are not supported. These include:
|
||||
*foreach loops (will throw JavaSyntaxError)
|
||||
|
||||
Reference in New Issue
Block a user