Class: Sexpir::Circuit

Inherits:
Ast
  • Object
show all
Defined in:
lib/sexpir/ast.rb,
lib/sexpir/ast_sexp.rb

Instance Attribute Summary collapse

Attributes inherited from Ast

#node

Instance Method Summary collapse

Methods inherited from Ast

#accept

Constructor Details

#initializeCircuit



12
13
14
15
16
# File 'lib/sexpir/ast.rb', line 12

def initialize
  @signals=[]
  @inputs,@outputs=[],[]
  @body=Body.new
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



11
12
13
# File 'lib/sexpir/ast.rb', line 11

def body
  @body
end

#inputsObject

Returns the value of attribute inputs.



11
12
13
# File 'lib/sexpir/ast.rb', line 11

def inputs
  @inputs
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/sexpir/ast.rb', line 11

def name
  @name
end

#outputsObject

Returns the value of attribute outputs.



11
12
13
# File 'lib/sexpir/ast.rb', line 11

def outputs
  @outputs
end

#signalsObject

Returns the value of attribute signals.



11
12
13
# File 'lib/sexpir/ast.rb', line 11

def signals
  @signals
end

Instance Method Details

#sexpObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/sexpir/ast_sexp.rb', line 17

def sexp
  code=Code.new
  code << "(circuit #{name}"
  code.indent=2
  signals.each{|sig| code << sig.sexp}
  inputs.each{|input | code << input.sexp}
  outputs.each{|output| code << output.sexp}
  code.newline
  code << body.sexp
  code.indent=0
  code << ")"
  code.finalize
end