def extractFreeFunctions2_impl(self, FuncArgs ): if hasMissingSymbol(FuncArgs): return None self.astParser.push_scope("function") self.astParser.reset_buffers() dummy_DefaultVarSig = getDefaultVarSig() setDefaultVarSig(varSig.variable_t) self.astParser.parent = self.package self.astParser.FuncArgs = FuncArgs self.astParser.local_function = self.freeFunction.__init__.__globals__ FuncArgsLocal = copy.copy(FuncArgs) body = self.body_unfold() bodystr= self.convert_to_string(body) ret = self.make_function_or_procedure( returnType=body.get_type() , bodystr=bodystr, FuncArgsLocal=FuncArgsLocal ) setDefaultVarSig(dummy_DefaultVarSig) self.astParser.pop_scope() return ret
def get_architechtures(self): ClassInstance = self.ClassInstance parent = self.parent setDefaultVarSig(varSig.signal_t) ClassName = type(ClassInstance).__name__ cl = self.astParser.getClassByName(ClassName) for f in cl.body: if f.name in self.astParser.functionNameVetoList: continue self.astParser.Missing_template = False ClassInstance.__hdl_converter__.reset_TemplateMissing( ClassInstance) self.astParser.reset_buffers() self.astParser.parent = parent self.astParser.FuncArgs.append({ "name": "self", "symbol": ClassInstance, "ScopeType": InOut_t.InOut_tt }) self.astParser.local_function = ClassInstance.__init__.__globals__ if sort_archetecture(): self.astParser.Archetecture_vars = sorted( ClassInstance.__local_symbols__, key=lambda element_: element_["type_name"]) else: self.astParser.Archetecture_vars = ClassInstance.__local_symbols__ try: body = self.astParser.Unfold_body(f) ## get local vars except Exception as inst: err_msg = argg_hdl_error( self.astParser.sourceFileName, f.lineno, f.col_offset, ClassName, "Function Name: " + f.name + ", Unable to Unfold AST, Error In extractArchetectureForEntity: body = self.Unfold_body(f)" ) raise Exception(err_msg, ClassInstance, inst) if self.astParser.Missing_template: ClassInstance.__hdl_converter__.FlagFor_TemplateMissing( ClassInstance) ClassInstance.__hdl_converter__.MissingTemplate = True else: proc = v_Arch(body=body, Symbols=self.astParser.LocalVar, Arch_vars=self.astParser.Archetecture_vars, ports=ClassInstance.getMember()) ClassInstance.__processList__.append(proc)
def convert_to_string(self, body): dummy_DefaultVarSig = getDefaultVarSig() setDefaultVarSig(varSig.variable_t) try: bodystr = str(body) return bodystr except Exception as inst: err_msg = argg_hdl_error( self.astParser.sourceFileName, funcDef.lineno, funcDef.col_offset, type(ClassInstance).__name__, "Function Name: " + funcDef.name + ", Unable to Convert AST to String, Error In extractFunctionsForClass_impl: bodystr= str(body)" ) raise Exception(err_msg, ClassInstance, inst) finally: setDefaultVarSig(dummy_DefaultVarSig)
def unfold_body(self, Function_node): dummy_DefaultVarSig = getDefaultVarSig() setDefaultVarSig(varSig.variable_t) try: body = self.astParser.Unfold_body(Function_node) return body except Exception as inst: err_msg = argg_hdl_error( self.astParser.sourceFileName, Function_node.lineno, Function_node.col_offset, type(self.ClassInstance).__name__, "Function Name: " + Function_node.name + ", Unable to Unfold AST. Error In extractFunctionsForClass_impl: body = self.Unfold_body(funcDef)" ) raise Exception(err_msg, ClassInstance, inst) finally: setDefaultVarSig(dummy_DefaultVarSig)
def body_unfold_porcess_body(astParser, Node): if astParser.get_scope_name() != "process": return body_unfold_porcess(astParser, Node=Node, Body=Node) localContext = astParser.Context dummy_DefaultVarSig = getDefaultVarSig() setDefaultVarSig(varSig.variable_t) decorator_l = astParser.Unfold_body(Node.decorator_list) ret = list() astParser.Context = ret for x in Node.body: ret.append(astParser.Unfold_body(x)) astParser.Context = localContext setDefaultVarSig(dummy_DefaultVarSig) return v_process_body_Def(ret, Node.name, astParser.LocalVar, decorator_l)
def body_unfold_porcess(astParser, Node, Body=None): localContext = astParser.Context astParser.push_scope("process") dummy_DefaultVarSig = getDefaultVarSig() setDefaultVarSig(varSig.variable_t) ret = list() astParser.Context = ret if Body is None: for x in Node.body: ret.append(astParser.Unfold_body(x)) else: ret.append(astParser.Unfold_body(Body)) astParser.Context = localContext setDefaultVarSig(dummy_DefaultVarSig) astParser.pop_scope() return v_process_Def(ret, Node.name)
def body_unfold_porcess_body_combinational(astParser, Node): localContext = astParser.Context astParser.push_scope("process") dummy_DefaultVarSig = getDefaultVarSig() setDefaultVarSig(varSig.signal_t) #decorator_l = astParser.Unfold_body(Node.decorator_list) ret = list() astParser.Context = ret for x in Node.body: ret.append(astParser.Unfold_body(x)) astParser.Context = localContext setDefaultVarSig(dummy_DefaultVarSig) astParser.pop_scope() return porcess_combinational(Node.name, ret)
def body_unfold_architecture_body(astParser, Node): localContext = astParser.Context astParser.push_scope("architecture") dummy_DefaultVarSig = getDefaultVarSig() setDefaultVarSig(varSig.signal_t) #decorator_l = astParser.Unfold_body(Node.decorator_list) ret = list() astParser.Context = ret for x in Node.body: if type(x).__name__ == "FunctionDef": ret.append(astParser.Unfold_body(x)) elif type(x).__name__ == "Assign": ret.append(astParser.Unfold_body(x)) astParser.Context = localContext setDefaultVarSig(dummy_DefaultVarSig) astParser.pop_scope() return architecure_body(Node.name, ret)