Sha256: f4b41b1472d8f425e07f0a8c0db6a3cbafa54dee5510187ef332a147df11024c

Contents?: true

Size: 485 Bytes

Versions: 3

Compression:

Stored size: 485 Bytes

Contents

module Xdrgen::AST
  class VarSize < Treetop::Runtime::SyntaxNode
    include Concerns::Contained

    def size
      return nil if size_t.text_value.blank?
      size_t.text_value
    end

    def resolved_size
      return size unless named?

      resolved = root.find_definition(size)

      if resolved.blank?
        raise "Could not resolve constant: #{size}"
      end

      resolved.value
    end

    def named?
      size_t.is_a?(Xdrgen::AST::Identifier)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
xdrgen-0.1.1 lib/xdrgen/ast/var_size.rb
xdrgen-0.1.0 lib/xdrgen/ast/var_size.rb
xdrgen-0.0.1 lib/xdrgen/ast/var_size.rb