Class: Rlang::Parser::Export

Inherits:
Object
  • Object
show all
Defined in:
lib/rlang/parser/export.rb

Constant Summary collapse

@@exports =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Export

Object can be either a method object or a global object



9
10
11
12
# File 'lib/rlang/parser/export.rb', line 9

def initialize(object)
  @object = object
  @@exports << self
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



6
7
8
# File 'lib/rlang/parser/export.rb', line 6

def object
  @object
end

Class Method Details

.reset!Object



14
15
16
# File 'lib/rlang/parser/export.rb', line 14

def self.reset!
  @@exports = []
end

.transpile(depth) ⇒ Object

Export Rlang funcs, etc… grouping them by object type for Wasm code readability



20
21
22
23
24
25
# File 'lib/rlang/parser/export.rb', line 20

def self.transpile(depth)
  indent = ' ' * depth * 2
  indent + @@exports.sort_by {|e| e.object.class.to_s}.collect do |export|
    export.object.export_wasm_code
  end.join("\n#{indent}")
end