Class: Fort::Src::Code::ProgramUnit

Inherits:
Object
  • Object
show all
Extended by:
RubyPatch::AutoLoad
Defined in:
lib/fort/src/code/program_unit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, deps = []) ⇒ ProgramUnit

Returns a new instance of ProgramUnit.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
# File 'lib/fort/src/code/program_unit.rb', line 11

def initialize(name, type, deps = [])
  raise ArgumentError unless [:program, :module].include?(type)

  @name = name
  @type = type
  @deps = deps
end

Instance Attribute Details

#depsObject

Returns the value of attribute deps.



9
10
11
# File 'lib/fort/src/code/program_unit.rb', line 9

def deps
  @deps
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/fort/src/code/program_unit.rb', line 8

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/fort/src/code/program_unit.rb', line 8

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
22
23
24
# File 'lib/fort/src/code/program_unit.rb', line 19

def ==(other)
  self.class == other.class\
  && @name == other.name\
  && @type == other.type\
  && @deps == other.deps
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/fort/src/code/program_unit.rb', line 26

def eql?(other)
  self.class == other.class && self.hash == other.hash
end

#hashObject



30
31
32
# File 'lib/fort/src/code/program_unit.rb', line 30

def hash
  [@name, @intrinsic_mode].hash
end