Module: HDLRuby::Low::Low2High

Defined in:
lib/HDLRuby/hruby_low2high.rb

Overview

Provides tools for converting HDLRuby::Low objects to HDLRuby::High.

Class Method Summary collapse

Class Method Details

.high_call_name(name, args) ⇒ Object

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



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

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

.high_decl_name(name) ⇒ Object

Converts a HDLRuby::Low +name+ for declaration to HDLRuby::High.



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

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

.high_name?(name) ⇒ Boolean

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

Returns:

  • (Boolean)


18
19
20
# File 'lib/HDLRuby/hruby_low2high.rb', line 18

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

.high_use_name(name) ⇒ Object

Converts a HDLRuby::Low +name+ for usage to HDLRuby::High.



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

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