class ClassHDL::HDLFunction

Attributes

belong_to_module[R]
name[RW]
open_ivoke[RW]
opertor_chains[RW]
return_type[R]

Public Class Methods

new(belong_to_module,name,return_type,*argvs) click to toggle source
# File lib/tdl/class_hdl/hdl_function.rb, line 62
def initialize(belong_to_module,name,return_type,*argvs)
    @opertor_chains = []
    @name = name
    @argvs = argvs
    @return_type = return_type
    @belong_to_module = belong_to_module
end

Public Instance Methods

inst_port() click to toggle source
# File lib/tdl/class_hdl/hdl_function.rb, line 70
def inst_port
    return @argvs.map{|e| "#{e.inst_port[0]} #{e.inst_port[1]}" }.join(',')
end
instance() click to toggle source
# File lib/tdl/class_hdl/hdl_function.rb, line 74
def instance
    str = []
    if @return_type
        if @return_type.is_a? EnumStruct
            str.push "function #{@return_type.typedef_name} #{@name}(#{inst_port}); "
        elsif @return_type.is_a? StructMeta
            str.push "function #{@return_type.name} #{@name}(#{inst_port}); "
        else
            str.push "function #{@return_type.to_s} #{@name}(#{inst_port}); "
        end
    else
        str.push "function #{@name}(#{inst_port}); "
    end

    opertor_chains.each do |op|
        unless op.is_a? OpertorChain
            str.push op.instance(:assign).gsub(/^./){ |m| "    #{m}"}
        else 
            unless op.slaver
                rel_str = ClassHDL.compact_op_ch(op.instance(:assign,belong_to_module))
                str.push "    #{rel_str};"
            end
        end
        
    end
    str.push "endfunction:#{@name}\n"
    str.join("\n")
end
ivoked(*fargvs) click to toggle source
# File lib/tdl/class_hdl/hdl_function.rb, line 103
def ivoked(*fargvs)
    str = fargvs.map do |e| 
        if e.is_a? OpertorChain
            e.slaver = true 
        end
        
        if e.instance_of? String
            "\"#{e}\""
        else 
            e.to_s 
        end
    end.join(",")

    return "#{@name}(#{str})".to_nq
end