Module: HDLRuby::Low::Low2HDR

Defined in:
lib/HDLRuby/hruby_low2hdr.rb

Overview

Provides tools for converting HDLRuby::Low objects to hdr text.

Class Method Summary collapse

Class Method Details

.hdr_call_name(name, args) ⇒ Object

Convert a HDLRuby::Low +name+ for instantiation to hdr text with args as argument.



46
47
48
49
50
51
52
53
54
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 46

def self.hdr_call_name(name,args)
    if hdr_name?(name) then
        # Compatible name return it as is.
        return "#{name} #{[*args].join(",")}"
    else
        # Incompatible, use the ruby "send" operator.
        return "send(:\"#{name}\",#{[*args].join(",")})"
    end
end

.hdr_decl_name(name) ⇒ Object

Converts a HDLRuby::Low +name+ for declaration to hdr tex.



22
23
24
25
26
27
28
29
30
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 22

def self.hdr_decl_name(name)
    if hdr_name?(name) then
        # Compatible name return it as is.
        return name.to_s
    else
        # Incompatible, use quotes.
        return "\"#{name}\""
    end
end

.hdr_name?(name) ⇒ Boolean

Tells if an HDLRuby::Low +name+ syntax is compatible for hdr text.

Returns:

  • (Boolean)


17
18
19
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 17

def self.hdr_name?(name)
    return name =~ /^[a-zA-Z_][a-zA-Z_0-9]*$/
end

.hdr_use_name(name) ⇒ Object

Converts a HDLRuby::Low +name+ for usage to hdr text.



33
34
35
36
37
38
39
40
41
42
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 33

def self.hdr_use_name(name)
    if hdr_name?(name) then
        # Compatible name return it as is.
        return name.to_s
    else
        # Incompatible, use the hdr "send" operator.
        # return "(+:\"#{name}\")"
        return "send(:\"#{name}\")"
    end
end