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

Inherits:
Object
  • Object
show all
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)


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

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.



6
7
8
# File 'lib/fort/src/code/program_unit.rb', line 6

def deps
  @deps
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/fort/src/code/program_unit.rb', line 5

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/fort/src/code/program_unit.rb', line 5

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
19
20
21
# File 'lib/fort/src/code/program_unit.rb', line 16

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

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/fort/src/code/program_unit.rb', line 23

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

#hashObject



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

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