Class: RetroIDL::ASN::BaseType

Inherits:
Object
  • Object
show all
Defined in:
lib/retro_idl/asn/base_type.rb

Overview

Copyright © 2016 Cameron Harper

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ BaseType

Common type object initialisation

Parameters:

  • opts (Hash)

Options Hash (**opts):

  • :id (String, NilClass)

    object identifer or type reference (nil for anon objects)

  • :location (Location)
  • :tag (Hash)

Raises:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/retro_idl/asn/base_type.rb', line 34

def initialize(**opts)

    @mod = nil
    @tag = nil
    @parent = parent
    @id = opts[:id]
    @location = opts[:location]
    @constraint = nil

    if opts[:tag]
        @tag = Tag.new(**opts[:tag])
    end                
    if opts[:constraint]
        @constraint = Constraint.new(self, **opts[:constraint])
    end

end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



22
23
24
# File 'lib/retro_idl/asn/base_type.rb', line 22

def id
  @id
end

Class Method Details

.===(otherClass) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/retro_idl/asn/base_type.rb', line 75

def self.===(otherClass)

    if self == otherClass
        true
    else
        false
    end

end

Instance Method Details

resolve symbols to definitions in module

Parameters:

  • mod (MODULE)

    module this type belongs to

  • stack (Array)

    objects called before this object for depth first search of recursion

Returns:

  • (MODULE)

    object has been linked

  • (nil)

    object has not been linked



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/retro_idl/asn/base_type.rb', line 53

def link(mod, stack)

    if @mod.nil? or @mod != mod

        @mod = nil
        
        if @tag.nil? or @tag.link(mod, [])

            @mod = mod
            stack.push self
            @mod.setBranch stack

        end

    else

        @mod

    end

end