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
Beispiel #2
0
    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)
Beispiel #3
0
    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)
Beispiel #4
0
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)
Beispiel #5
0
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)
Beispiel #6
0
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)