def __init__(self, id, nodeInit, condition, nodeAfter, nodeBlock, resolver_util): super().__init__(id, condition, nodeBlock) from ADT.Utils.ResolverUtil import resolveNodeViaType self.condition = resolveNodeViaType(condition["$type"], condition, resolver_util) self.nodeInit = resolveNodeViaType(nodeInit["$type"], nodeInit, resolver_util) self.nodeAfter = resolveNodeViaType(nodeAfter["$type"], nodeAfter, resolver_util) self.nodeBlock = resolveNodeViaType(nodeBlock["$type"], nodeBlock, resolver_util)
def __init__(self, id, operation, leftOperand, rightOperand, resolver_util): super().__init__(id) from ADT.Utils.ResolverUtil import resolveNodeViaType self.operation = operation self.rightOperand = resolveNodeViaType(rightOperand["$type"], rightOperand, resolver_util) self.leftOperand = resolveNodeViaType(leftOperand["$type"], leftOperand, resolver_util)
def __init__(self, id, returnType, name, arguments, body, resolverUtil): super().__init__(id) self.name = name if resolverUtil.mainFuncName is None: resolverUtil.mainFuncName = name self.arguments = resolveArguments(arguments, resolverUtil) from ADT.Utils.ResolverUtil import resolveNodeViaType self.returnType = resolveNodeViaType(returnType["$type"], returnType, resolverUtil) self.body = resolveNodeViaType(body["$type"], body["Nodes"], resolverUtil)
def __init__(self, id, condition, nodeThen, resolver_util, nodeElse=None): super().__init__(id) from ADT.Utils.ResolverUtil import resolveNodeViaType self.condition = resolveNodeViaType(condition["$type"], condition, resolver_util) self.nodeThen = resolveNodeViaType(nodeThen["$type"], nodeThen, resolver_util) if nodeElse is not None: self.nodeElse = resolveNodeViaType(condition["$type"], condition, resolver_util) else: self.nodeElse = None
def __init__(self, id, nodes, resolverUtil): super().__init__(id) self.nodes = [] if "Nodes" in nodes: from ADT.Utils.ResolverUtil import resolveNodeViaType self.nodes.append( resolveNodeViaType(nodes["Nodes"]["$type"], nodes["Nodes"], resolverUtil)) if "$values" in nodes: for node in nodes["$values"]: from ADT.Utils.ResolverUtil import resolveNodeViaType self.nodes.append( resolveNodeViaType(node["$type"], node, resolverUtil))
def __init__(self, id, variableName, array, subscript, resolverUtil, variableDeclaration=None): VariableNode.__init__(self, id, resolverUtil, variableName, variableDeclaration) from ADT.Utils.ResolverUtil import resolveNodeViaType self.array = resolveNodeViaType(array["$type"], array, resolverUtil) self.subscript = resolveNodeViaType(subscript["$type"], subscript, resolverUtil)
def __init__(self, id, variableType, resolverUtil, initialValue=None): super().__init__(id) from ADT.Utils.ResolverUtil import resolveNodeViaType if variableType is None: from ADT.UnknowNode import UnknownNode self.variableType = UnknownNode("unknown") else: self.variableType = resolveNodeViaType(variableType["$type"], variableType, resolverUtil) self.variable = None if isinstance(initialValue, dict) and "$type" in initialValue: self.initialValue = resolveNodeViaType(initialValue["$type"], initialValue, resolverUtil) else: self.initialValue = initialValue
def resolveArguments(arguments, resolverUtil): args = [] for value in arguments["$values"]: from ADT.Utils.ResolverUtil import resolveNodeViaType variable = resolveNodeViaType(value["$type"], value, resolverUtil) args.append(variable) return args
def __init__(self, id, variableName, operator, resolverUtil, variableDeclaration=None): VariableNode.__init__(self, id, resolverUtil, variableName, variableDeclaration) from ADT.Utils.ResolverUtil import resolveNodeViaType self.operator = resolveNodeViaType(operator["$type"], operator, resolverUtil)
def __init__(self, id, name, arguments, declaration, resolverUtil): super().__init__(id) self.name = name from ADT.Utils.ArgumentResolver import resolveArguments self.arguments = resolveArguments(arguments, resolverUtil) from ADT.Utils.ResolverUtil import resolveNodeViaType # TODO: Replace entire tree with variables from arguments.. also if there exist variables with this name in the body of the function - replace it if declaration is None: from ADT.UnknowNode import UnknownNode self.functionDeclaration = UnknownNode("unknown") else: self.functionDeclaration = resolveNodeViaType( declaration["$type"], declaration, resolverUtil)
def __init__(self, id, variableName, variable, dereference, field, resolverUtil, variableDeclaration=None): VariableNode.__init__(self, id, resolverUtil, variableName, variableDeclaration) from ADT.Utils.ResolverUtil import resolveNodeViaType self.variable = resolveNodeViaType(variable["$type"], variable, resolverUtil) self.dereference = dereference self.field = field
def __init__(self, id, resolverUtil, variableName=None, variableDeclaration=None): super().__init__(id) self.variableName = variableName if variableDeclaration is not None: if isinstance(variableDeclaration, VariableDeclarationStatement): self.variableDeclaration = variableDeclaration else: from ADT.Utils.ResolverUtil import resolveNodeViaType self.variableDeclaration = resolveNodeViaType( variableDeclaration["$type"], variableDeclaration, resolverUtil) else: self.variableDeclaration = None self.variableDeclaration = variableDeclaration
def __init__(self, id, operation, operand, resolver_util): super().__init__(id) self.operation = operation from ADT.Utils.ResolverUtil import resolveNodeViaType self.operand = resolveNodeViaType(operand["$type"], operand, resolver_util)
def __init__(self, id, variable, value, resolverUtil): super().__init__(id) from ADT.Utils.ResolverUtil import resolveNodeViaType self.variable = resolveNodeViaType(variable["$type"], variable, resolverUtil) self.value = resolveNodeViaType(value["$type"], value, resolverUtil)
def extractFunctionParams(self): arguments = self.rootAdtNode["Arguments"] for value in arguments["$values"]: variableDecl = resolveNodeViaType(value["$type"], value, self.resolverUtil) self.arguments[variableDecl.variable.variableName] = variableDecl