Class: Vertigo::PrettyPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/vertigo/pretty_printer.rb

Instance Method Summary collapse

Instance Method Details



7
8
9
10
11
12
# File 'lib/vertigo/pretty_printer.rb', line 7

def print ast
  code=Code.new
  code << "-- generated by Vertigo VHDL tool"
  code << ast.accept(self)
  code
end

#visitAfter(after, args = nil) ⇒ Object



645
646
647
648
649
# File 'lib/vertigo/pretty_printer.rb', line 645

def visitAfter after,args=nil
  lhs=after.lhs.accept(self,args)
  rhs=after.rhs.accept(self,args)
  "#{lhs} after #{rhs}"
end

#visitAggregate(aggregate, args = nil) ⇒ Object



721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
# File 'lib/vertigo/pretty_printer.rb', line 721

def visitAggregate aggregate,args=nil
  elems=(elements=aggregate.elements).map{|e| e.accept(self)}
  # here we prototype a multiline method, for long aggregates
  ret="\n\t(\n\t#{elems.join(',')})"
  if ret.size>5
    klasses=elements.map{|e| e.class}
    #if klasses.include?(Aggregate)
      code=Code.new
      code << '('
      code.indent=col=5
      elements.each{|e|
        code << e.accept(self)+","
      }
      code.indent=col-2
      code.newline
      code << ")"
      ret=code.finalize
    #end
  end
  ret
end

#visitAlias(alias_, args = nil) ⇒ Object



261
262
263
264
265
266
267
# File 'lib/vertigo/pretty_printer.rb', line 261

def visitAlias(alias_,args=nil)
  designator= alias_.designator.accept(self,args)
  type      = alias_.type.accept(self,args)
  name      = alias_.name.accept(self,args)
  signature = alias_.signature.accept(self,args) if alias_.signature
  "alias #{designator} : #{type} is #{name} #{};"
end

#visitAlternative(alternative_, args = nil) ⇒ Object



345
346
347
# File 'lib/vertigo/pretty_printer.rb', line 345

def visitAlternative(alternative_,args=nil)
  alternative_.elements.map{|element_| element_.accept(self,args)}.join(" | ")
end

#visitArchitecture(architecture, args = nil) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/vertigo/pretty_printer.rb', line 165

def visitArchitecture(architecture,args=nil)
  code=Code.new
  name=architecture.name.accept(self,args)
  entity_name=architecture.entity_name.accept(self,args)
  body=architecture.body.accept(self,args) if architecture.body

  code << "architecture #{name} of #{entity_name} is"
  code.indent=2
  architecture.decls.each{|decl_| code << decl_.accept(self,args)}
  code.indent=0
  code << "begin"
  code.newline
  code.indent=2
  code << body
  code.indent=0
  code << "end #{name};"
  code
end

#visitArrayDecl(arraydecl_, args = nil) ⇒ Object



225
226
227
228
229
# File 'lib/vertigo/pretty_printer.rb', line 225

def visitArrayDecl(arraydecl_,args=nil)
  ranges=arraydecl_.dim_decls.map{|dim_decl_| dim_decl_.accept(self,args)}
  type=arraydecl_.type.accept(self)
  "array(#{ranges.join(',')}) of #{type}"
end

#visitArrayDimDecl(arraydimdecl_, args = nil) ⇒ Object



231
232
233
234
235
236
# File 'lib/vertigo/pretty_printer.rb', line 231

def visitArrayDimDecl(arraydimdecl_,args=nil)
  type_mark=arraydimdecl_.type_mark.accept(self)+" " if arraydimdecl_.type_mark
  type_mark_range="#{type_mark}range " if arraydimdecl_.type_mark
  range=arraydimdecl_.range.accept(self,args)
  "#{type_mark_range}#{range}"
end

#visitArrayType(arraytype, args = nil) ⇒ Object



583
584
585
586
587
588
# File 'lib/vertigo/pretty_printer.rb', line 583

def visitArrayType(arraytype,args=nil)
  name=arraytype.name.accept(self,args)
  ranges=[]
  arraytype.discrete_ranges.each{|discrete_range_| ranges << discrete_range_.accept(self,args)}
  "#{name}(#{ranges.join(',')})"
end

#visitAssert(assert, args = nil) ⇒ Object



353
354
355
356
357
358
359
360
361
362
363
# File 'lib/vertigo/pretty_printer.rb', line 353

def visitAssert assert,args=nil
  cond=assert.cond.accept(self)
  repo=assert.report.accept(self) if assert.report
  code=Code.new
  code << "assert #{cond}"
  code.indent=2
  code << repo if repo
  code.indent=0
  code.last << ";"
  code
end

#visitAssoc(assoc, args = nil) ⇒ Object



743
744
745
746
747
# File 'lib/vertigo/pretty_printer.rb', line 743

def visitAssoc assoc,args=nil
  lhs=assoc.lhs.accept(self)
  rhs=assoc.rhs.accept(self)
  "(#{lhs} => #{rhs})"
end

#visitAttributed(attributed_, args = nil) ⇒ Object



657
658
659
660
661
# File 'lib/vertigo/pretty_printer.rb', line 657

def visitAttributed(attributed_,args=nil)
  lhs=attributed_.lhs.accept(self,args)
  rhs=attributed_.rhs.accept(self,args)
  "#{lhs}#{rhs}"
end

#visitAttributeDecl(attributedecl_, args = nil) ⇒ Object



458
459
460
461
462
# File 'lib/vertigo/pretty_printer.rb', line 458

def visitAttributeDecl(attributedecl_,args=nil)
  name=attributedecl_.name.accept(self,args)
  type=attributedecl_.type.accept(self,args)
  "attribute #{name} : #{type};"
end

#visitAttributeSpec(attributespec_, args = nil) ⇒ Object



464
465
466
467
468
469
# File 'lib/vertigo/pretty_printer.rb', line 464

def visitAttributeSpec(attributespec_,args=nil)
  name       =attributespec_.name.accept(self,args)
  entity_spec=attributespec_.entity_spec.accept(self,args)
  expr       =attributespec_.expr.accept(self,args)
  "attribute #{name} of #{entity_spec} is #{expr};"
end

#visitBinary(binary_, args = nil) ⇒ Object



616
617
618
619
620
621
# File 'lib/vertigo/pretty_printer.rb', line 616

def visitBinary(binary_,args=nil)
  lhs=binary_.lhs.accept(self,args)
  op=binary_.op.accept(self,args)
  rhs=binary_.rhs.accept(self,args)
  "#{lhs} #{op} #{rhs}"
end

#visitBody(body, args = nil) ⇒ Object



269
270
271
272
273
# File 'lib/vertigo/pretty_printer.rb', line 269

def visitBody(body,args=nil)
  code=Code.new
  body.elements.each{|element_| code << element_.accept(self,args)}
  code
end

#visitBoolLit(boollit_, args = nil) ⇒ Object



635
636
637
# File 'lib/vertigo/pretty_printer.rb', line 635

def visitBoolLit(boollit_,args=nil)
  boollit_.tok.accept(self,args)
end

#visitCase(case_, args = nil) ⇒ Object



322
323
324
325
326
327
328
329
330
331
332
# File 'lib/vertigo/pretty_printer.rb', line 322

def visitCase case_,args=nil
  expr=case_.expr.accept(self)
  whens=case_.whens.map{|when_| when_.accept(self)}
  code=Code.new
  code << "case #{expr} is"
  code.indent=2
  case_.whens.map{|when_| code << when_.accept(self)}
  code.indent=0
  code << "end case;"
  code
end

#visitCaseWhen(cwhen, args = nil) ⇒ Object



334
335
336
337
338
339
340
341
342
343
# File 'lib/vertigo/pretty_printer.rb', line 334

def visitCaseWhen cwhen,args=nil
  expr=cwhen.expr.accept(self)
  body=cwhen.body.accept(self)
  code=Code.new
  code << "when #{expr} =>"
  code.indent=2
  code << body
  code.indent=0
  code
end

#visitCharLit(lit, args = nil) ⇒ Object



631
632
633
# File 'lib/vertigo/pretty_printer.rb', line 631

def visitCharLit(lit,args=nil)
  lit.tok.accept(self,args)
end

#visitComment(comment_, args = nil) ⇒ Object



24
25
26
# File 'lib/vertigo/pretty_printer.rb', line 24

def visitComment(comment_,args=nil)
  "-- #{comment_.str}"
end

#visitComponentDecl(componentdecl_, args = nil) ⇒ Object



511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/vertigo/pretty_printer.rb', line 511

def visitComponentDecl(componentdecl_,args=nil)
  name=componentdecl_.name.accept(self,args)
  code=Code.new
  code << "component #{name} is"
  code.indent=2
  if componentdecl_.generics.any?
    code.indent=4
    code << "generic("
    code.indent=6
    componentdecl_.generics.map{|generic_| code << generic_.accept(self,args)}
    code.indent=4
    code << ");"
    code.indent=2
  end
  code << "port("
  code.indent=6
  componentdecl_.ports.each{|port_| code << port_.accept(self,args)}
  code.indent=4
  code << ");"
  code.indent=0
  code << "end component;"
  code
end

#visitComponentInstance(componentinstance_, args = nil) ⇒ Object



535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/vertigo/pretty_printer.rb', line 535

def visitComponentInstance(componentinstance_,args=nil)
  label    = componentinstance_.label.accept(self) if componentinstance_.label
  name     = componentinstance_.name.accept(self,args)
  gen_map  = componentinstance_.generic_map.accept(self,args) if componentinstance_.generic_map
  port_map = componentinstance_.port_map.accept(self,args)
  code=Code.new
  code << "#{label}component #{name}"
  code.indent=2
  code << gen_map if gen_map
  code << port_map
  code.indent=0
  code.newline
  code
end

#visitConcat(concat_, args = nil) ⇒ Object



663
664
665
666
667
# File 'lib/vertigo/pretty_printer.rb', line 663

def visitConcat(concat_,args=nil)
  lhs=concat_.lhs.accept(self,args)
  rhs=concat_.rhs.accept(self,args)
  "#{lhs} & #{rhs}"
end

#visitCondExpr(condexpr, args = nil) ⇒ Object



602
603
604
605
606
607
608
# File 'lib/vertigo/pretty_printer.rb', line 602

def visitCondExpr(condexpr,args=nil)
  code=Code.new
  whens=condexpr.whens.map{|when_| when_.accept(self,args)}
  else_=condexpr.else_.accept(self,args)
  code << "#{whens.join} #{else_}"
  code.finalize
end

#visitConstant(cst, args = nil) ⇒ Object



238
239
240
241
242
243
# File 'lib/vertigo/pretty_printer.rb', line 238

def visitConstant cst,args=nil
  name=cst.name.accept(self)
  type=cst.type.accept(self)
  expr=cst.expr.accept(self)
  "constant #{name} : #{type} := #{expr};"
end

#visitDiscreteRange(discreterange, args = nil) ⇒ Object



590
591
592
593
594
595
# File 'lib/vertigo/pretty_printer.rb', line 590

def visitDiscreteRange(discreterange,args=nil)
  lhs=discreterange.lhs.accept(self,args)
  dir=discreterange.dir.accept(self,args)
  rhs=discreterange.rhs.accept(self,args)
  "#{lhs} #{dir} #{rhs}"
end

#visitElse(else_, args = nil) ⇒ Object



312
313
314
315
316
317
318
319
320
# File 'lib/vertigo/pretty_printer.rb', line 312

def visitElse else_,args=nil
  body=else_.body.accept(self)
  code=Code.new
  code << "else"
  code.indent=2
  code << body
  code.indent=0
  code
end

#visitElsif(elsif_, args = nil) ⇒ Object



301
302
303
304
305
306
307
308
309
310
# File 'lib/vertigo/pretty_printer.rb', line 301

def visitElsif elsif_,args=nil
  cond=elsif_.cond.accept(self)
  body=elsif_.body.accept(self)
  code=Code.new
  code << "elsif #{cond} then"
  code.indent=2
  code << body
  code.indent=0
  code
end

#visitEntity(entity, args = nil) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vertigo/pretty_printer.rb', line 40

def visitEntity(entity,args=nil)
  code=Code.new
  name=entity.name.accept(self,args)
  code.newline
  code << "entity #{name} is"
  code.indent=2
  if entity.generics.any?
    code << "generic("
    code.indent=4
    entity.generics.each{|generic_| code << generic_.accept(self,args)}
    code.indent=2
    code << ");"
  end
  if entity.ports.any?
    code << "port("
    code.indent=4
    entity.ports.each{|port_| code << port_.accept(self,args)}
    code.indent=2
    code << ");"
  end
  code.indent=0
  code << "end entity #{name};"
  code.newline
  code
end

#visitEntityInstance(inst, args = nil) ⇒ Object



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/vertigo/pretty_printer.rb', line 425

def visitEntityInstance inst,args=nil
  code=Code.new
  label=inst.label.accept(self) if inst.label
  full_name=inst.full_name.accept(self)
  arch_name=inst.arch_name.accept(self) if inst.arch_name
  arch_name="(#{arch_name})" if inst.arch_name
  gen_map  =inst.generic_map.accept(self) if inst.generic_map
  port_map =inst.port_map.accept(self) if inst.port_map
  code << "#{label}entity #{full_name}#{arch_name}"
  code.indent=2
  code << port_map
  code.indent=0
  code.newline
  code
end

#visitEntitySpec(entityspec_, args = nil) ⇒ Object



471
472
473
474
475
# File 'lib/vertigo/pretty_printer.rb', line 471

def visitEntitySpec(entityspec_,args=nil)
  elements=entityspec_.elements.map{|element_| element_.accept(self,args)}
  entity_class=entityspec_.entity_class.accept(self,args)
  "#{elements.join(',')} : #{entity_class}"
end

#visitEnumDecl(enum, args = nil) ⇒ Object



204
205
206
207
# File 'lib/vertigo/pretty_printer.rb', line 204

def visitEnumDecl enum,args=nil
  elems=enum.elements.map{|e| e.accept(self)}
  "(#{elems.join(',')})"
end

#visitForGenerate(forgenerate_, args = nil) ⇒ Object



409
410
411
412
413
414
415
416
417
418
419
420
421
422
# File 'lib/vertigo/pretty_printer.rb', line 409

def visitForGenerate(forgenerate_,args=nil)
  idx  =forgenerate_.index.accept(self,args)
  range=forgenerate_.range.accept(self,args)
  decls=forgenerate_.decls.each{|decl_| decl_.accept(self,args)} if forgenerate_.decls
  body =forgenerate_.body.accept(self,args)
  code=Code.new
  code << "for #{idx} in #{range} generate"
  code.indent=2
  code << decls if decls
  code << body
  code.indent=0
  code << "end generate;"
  code
end

#visitFormalArg(formalarg_, args = nil) ⇒ Object



148
149
150
151
152
153
154
155
# File 'lib/vertigo/pretty_printer.rb', line 148

def visitFormalArg formalarg_,args=nil
  sig =formalarg_.signal.accept(self,args) if formalarg_.signal
  dir =formalarg_.direction.accept(self,args) if formalarg_.direction
  dir+=" " if dir
  name=formalarg_.name.accept(self,args)
  type=formalarg_.type.accept(self,args)
  "#{sig}#{name} : #{dir}#{type}"
end

#visitFuncCall(funcall, args = nil) ⇒ Object



710
711
712
713
714
# File 'lib/vertigo/pretty_printer.rb', line 710

def visitFuncCall funcall,args=nil
  name=funcall.name.accept(self)
  args=funcall.actual_args.map{|arg| arg.accept(self)}.join(',')
  "#{name}(#{args})"
end

#visitFuncDecl(funcdecl_, args = nil) ⇒ Object



691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
# File 'lib/vertigo/pretty_printer.rb', line 691

def visitFuncDecl(funcdecl_,args=nil)
  name=funcdecl_.name.accept(self,args)
  args=funcdecl_.formal_args.map{|formal_arg_| formal_arg_.accept(self,args)}.join(";")
  type=funcdecl_.return_type.accept(self)
  args="(#{args})" if args
  code=Code.new
  code.newline
  code << "function #{name}#{args} return #{type} is"
  code.indent=2
  funcdecl_.decls.each{|decl| code << decl.accept(self)}
  code.indent=0
  code << "begin"
  code.indent=2
  code << funcdecl_.body.accept(self)
  code.indent=0
  code << "end function #{name};"
  code
end

#visitFuncProtoDecl(funcprotodecl_, args = nil) ⇒ Object



683
684
685
686
687
688
689
# File 'lib/vertigo/pretty_printer.rb', line 683

def visitFuncProtoDecl(funcprotodecl_,args=nil)
  name=funcprotodecl_.name.accept(self,args)
  args=funcprotodecl_.formal_args.map{|formal_arg_| formal_arg_.accept(self,args)}.join(";")
  type=funcprotodecl_.return_type.accept(self)
  args="(#{args})" if args
  "function #{name}#{args} return #{type}"
end

#visitGeneric(generic, args = nil) ⇒ Object



66
67
68
69
70
71
72
# File 'lib/vertigo/pretty_printer.rb', line 66

def visitGeneric(generic,args=nil)
  name=generic.name.accept(self,args)
  type=generic.type.accept(self,args)
  init=generic.init.accept(self,args) if generic.init
  init+=" := #{init}" if init
  "#{name} : #{type}#{init};"
end

#visitGenericMap(generic_map, args = nil) ⇒ Object



477
478
479
480
481
482
483
484
485
# File 'lib/vertigo/pretty_printer.rb', line 477

def visitGenericMap generic_map,args=nil
  code=Code.new
  code << "generic map("
  code.indent=2
  generic_map.elements.each{|e| code << e.accept(self)+","}
  code.indent=0
  code << ");"
  code
end

#visitIdent(ident, args = nil) ⇒ Object



623
624
625
# File 'lib/vertigo/pretty_printer.rb', line 623

def visitIdent(ident,args=nil)
  ident.tok.accept(self,args)
end

#visitIf(if_, args = nil) ⇒ Object



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/vertigo/pretty_printer.rb', line 280

def visitIf if_,args=nil
  label=if_.label.accept(self) if if_.label
  cond=if_.cond.accept(self)
  body=if_.body.accept(self)
  elsifs_=if_.elsifs.map{|elsif_| elsif_.accept(self)} if if_.elsifs.any?
  else_=if_.else_.accept(self) if if_.else_
  code=Code.new
  code << "#{label}if #{cond} then"
  code.indent=2
  code << body
  code.indent=0
  if if_.elsifs.any?
    elsifs_.each{|elsif_| code << elsif_}
  end
  if if_.else_
    code << else_
  end
  code << "end if;"
  code
end

#visitIfGenerate(ifgenerate_, args = nil) ⇒ Object



397
398
399
400
401
402
403
404
405
406
407
# File 'lib/vertigo/pretty_printer.rb', line 397

def visitIfGenerate(ifgenerate_,args=nil)
  cond=ifgenerate_.cond.accept(self,args)
  body=ifgenerate_.body.accept(self,args)
  code=Code.new
  code << "if #{cond} generate"
  code.indent=2
  code << body
  code.indent=0
  code << "end generate;"
  code
end

#visitInOut(inout, args = nil) ⇒ Object



88
89
90
91
92
93
# File 'lib/vertigo/pretty_printer.rb', line 88

def visitInOut(inout,args=nil)
  name=inout.name.accept(self,args)
  type=inout.type.accept(self,args)
  init=inout.init.accept(self,args) if inout.init
  "#{name} : inout #{type}#{init};"
end

#visitInput(input, args = nil) ⇒ Object



74
75
76
77
78
79
# File 'lib/vertigo/pretty_printer.rb', line 74

def visitInput(input,args=nil)
  name=input.name.accept(self,args)
  type=input.type.accept(self,args)
  init=input.init.accept(self,args) if input.init
  "#{name} : in #{type}#{init};"
end

#visitIntLit(intlit, args = nil) ⇒ Object



627
628
629
# File 'lib/vertigo/pretty_printer.rb', line 627

def visitIntLit(intlit,args=nil)
  intlit.tok.accept(self,args)
end

#visitLabel(label, args = nil) ⇒ Object



275
276
277
278
# File 'lib/vertigo/pretty_printer.rb', line 275

def visitLabel label,args=nil
  id=label.ident.accept(self)
  "#{id} : "
end

#visitLibrary(library, args = nil) ⇒ Object



28
29
30
31
# File 'lib/vertigo/pretty_printer.rb', line 28

def visitLibrary(library,args=nil)vhdl=Code.new
  name=library.name.accept(self,args)
  "library #{name};"
end

#visitMap(map, args = nil) ⇒ Object



451
452
453
454
455
456
# File 'lib/vertigo/pretty_printer.rb', line 451

def visitMap map,args=nil
  lhs=map.lhs.accept(self)
  rhs=map.rhs.accept(self) if map.rhs
  rhs=" => #{rhs}" if rhs
  "#{lhs}#{rhs}"
end

#visitNamedType(namedtype, args = nil) ⇒ Object



579
580
581
# File 'lib/vertigo/pretty_printer.rb', line 579

def visitNamedType(namedtype,args=nil)
  namedtype.ident.accept(self,args)
end

#visitNullStmt(null_, args = nil) ⇒ Object



349
350
351
# File 'lib/vertigo/pretty_printer.rb', line 349

def visitNullStmt null_,args=nil
  "null;"
end

#visitOutput(output, args = nil) ⇒ Object



81
82
83
84
85
86
# File 'lib/vertigo/pretty_printer.rb', line 81

def visitOutput(output,args=nil)
  name=output.name.accept(self,args)
  type=output.type.accept(self,args)
  init=output.init.accept(self,args) if output.init
  "#{name} : out #{type}#{init};"
end

#visitPackage(package_, args = nil) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/vertigo/pretty_printer.rb', line 96

def visitPackage package_,args=nil
  name=package_.name.accept(self,args)
  code=Code.new
  code.newline
  code << "package #{name} is"
  code.indent=2
  package_.decls.each{|decl_| code << decl_.accept(self,args)}
  code.indent=0
  code.newline
  code << "end #{name};"
  code.newline
  code
end

#visitPackageBody(packagebody_, args = nil) ⇒ Object



110
111
112
113
114
115
116
117
118
119
# File 'lib/vertigo/pretty_printer.rb', line 110

def visitPackageBody(packagebody_,args=nil)
  name=packagebody_.name.accept(self,args)
  code=Code.new
  code << "package body #{name} is"
  code.indent=2
  packagebody_.decls.each{|decl_| code << decl_.accept(self,args)}
  code.indent=0
  code << "end #{name};"
  code
end

#visitParenth(parenth, args = nil) ⇒ Object



716
717
718
719
# File 'lib/vertigo/pretty_printer.rb', line 716

def visitParenth parenth,args=nil
  expr=parenth.expr.accept(self)
  "(#{expr})"
end

#visitPortMap(port_map, args = nil) ⇒ Object



441
442
443
444
445
446
447
448
449
# File 'lib/vertigo/pretty_printer.rb', line 441

def visitPortMap port_map,args=nil
  code=Code.new
  code << "port map("
  code.indent=2
  port_map.elements.each{|e| code << e.accept(self)+","}
  code.indent=0
  code << ");"
  code
end

#visitProcedureCall(procedurecall_, args = nil) ⇒ Object



157
158
159
160
161
162
# File 'lib/vertigo/pretty_printer.rb', line 157

def visitProcedureCall(procedurecall_,args=nil)
  name=procedurecall_.name.accept(self,args)
  args=name=procedurecall_.actual_args.map{|actual_arg_| actual_arg_.accept(self,args)}.join(',')
  args="(#{args})" if args
  "#{name}#{args}"
end

#visitProcedureDecl(proceduredecl_, args = nil) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/vertigo/pretty_printer.rb', line 121

def visitProcedureDecl(proceduredecl_,args=nil)
  name=proceduredecl_.name.accept(self,args)
  code=Code.new
  code.newline
  code << "procedure #{name}("
  code.indent=2
  proceduredecl_.formal_args.map{|formal_arg_| code << formal_arg_.accept(self,args)+";"}
  code.indent=0
  code.last << ")"
  if proceduredecl_.decls.any? or !proceduredecl_.body.nil?
    code.last << " is"
    decls=proceduredecl_.decls.each{|decl_| decl_.accept(self,args)}
    body =proceduredecl_.body.accept(self,args) if proceduredecl_.body
    code.indent=2
    code << decls
    code.indent=0
    code << "begin"
    code.indent=2
    code << body
    code.indent=0
    code << "end #{name};"
  else
    code.last << ";"
  end
  code
end

#visitProcess(process, args = nil) ⇒ Object



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
# File 'lib/vertigo/pretty_printer.rb', line 487

def visitProcess(process,args=nil)
  code=Code.new
  code.newline
  label=process.label.accept(self) if process.label
  sensitity=process.sensitivity.accept(self,args) if process.sensitivity
  sensitity="(#{sensitity})" if sensitity
  body=process.body.accept(self,args) if process.body
  code << "#{label}process#{sensitity}"
  code.indent=2
  process.decls.each{|decl_| code << decl_.accept(self,args)}
  code.indent=0
  code << "begin"
  code.indent=2
  code << body
  code.indent=0
  code << "end process;"
  code
end

#visitQualified(qualified_, args = nil) ⇒ Object



669
670
671
672
673
# File 'lib/vertigo/pretty_printer.rb', line 669

def visitQualified(qualified_,args=nil)
  lhs=qualified_.lhs.accept(self,args)
  rhs=qualified_.rhs.accept(self,args)
  "#{lhs}'#{rhs}"
end

#visitRangedType(rangedtype_, args = nil) ⇒ Object



573
574
575
576
577
# File 'lib/vertigo/pretty_printer.rb', line 573

def visitRangedType(rangedtype_,args=nil)
  type=rangedtype_.type.accept(self,args)
  range=rangedtype_.range.accept(self,args)
  "#{type} range #{range}"
end

#visitRecordDecl(rec, args = nil) ⇒ Object



209
210
211
212
213
214
215
216
217
# File 'lib/vertigo/pretty_printer.rb', line 209

def visitRecordDecl rec,args=nil
  code=Code.new
  code << "record"
  code.indent=4
  rec.elements.map{|e| code << e.accept(self)}
  code.indent=2
  code << "end record"
  code.finalize
end

#visitRecordItem(ri, args = nil) ⇒ Object



219
220
221
222
223
# File 'lib/vertigo/pretty_printer.rb', line 219

def visitRecordItem ri,args=nil
  name=ri.name.accept(self)
  type=ri.type.accept(self)
  "#{name} : #{type};"
end

#visitReport(report, args = nil) ⇒ Object



365
366
367
368
369
370
# File 'lib/vertigo/pretty_printer.rb', line 365

def visitReport report,args=nil
  expr=report.expr.accept(self)
  sevr=report.severity.accept(self) if report.severity
  severity=" severity #{sevr}" if sevr
  "report #{expr}#{severity};"
end

#visitReturn(return_, args = nil) ⇒ Object



372
373
374
375
376
# File 'lib/vertigo/pretty_printer.rb', line 372

def visitReturn(return_,args=nil)
  expr=return_.expr.accept(self,args) if return_.expr
  expr=" #{expr}" if expr
  "return#{expr};"
end

#visitRoot(root, args = nil) ⇒ Object



14
15
16
17
18
# File 'lib/vertigo/pretty_printer.rb', line 14

def visitRoot(root,args=nil)
  code=Code.new
  root.design_units.each{|design_unit_| code << design_unit_.accept(self,args)}
  code
end

#visitSelectedName(selectedname, args = nil) ⇒ Object



639
640
641
642
643
# File 'lib/vertigo/pretty_printer.rb', line 639

def visitSelectedName(selectedname,args=nil)
  lhs=selectedname.lhs.accept(self,args)
  rhs=selectedname.rhs.accept(self,args)
  "#{lhs}.#{rhs}"
end

#visitSelectedWhen(selectedwhen_, args = nil) ⇒ Object



391
392
393
394
395
# File 'lib/vertigo/pretty_printer.rb', line 391

def visitSelectedWhen(selectedwhen_,args=nil)
  lhs=selectedwhen_.lhs.accept(self,args)
  rhs=selectedwhen_.rhs.accept(self,args)
  "#{lhs} when #{rhs}"
end

#visitSensitivity(sensitivity, args = nil) ⇒ Object



506
507
508
509
# File 'lib/vertigo/pretty_printer.rb', line 506

def visitSensitivity(sensitivity,args=nil)
  list=sensitivity.elements.map{|element_| element_.accept(self,args)}
  list.join(',')
end

#visitSigAssign(sigassign, args = nil) ⇒ Object



550
551
552
553
554
555
# File 'lib/vertigo/pretty_printer.rb', line 550

def visitSigAssign(sigassign,args=nil)
  #pp sigassign
  lhs=sigassign.lhs.accept(self,args)
  rhs=sigassign.rhs.accept(self,args)
  "#{lhs} <= #{rhs};"
end

#visitSignal(signal, args = nil) ⇒ Object



245
246
247
248
249
250
251
# File 'lib/vertigo/pretty_printer.rb', line 245

def visitSignal signal,args=nil
  name=signal.name.accept(self)
  type=signal.type.accept(self)
  init=signal.init.accept(self) if signal.init
  init=" := #{init}" if init
  "signal #{name} : #{type}#{init};"
end

#visitSliced(sliced_, args = nil) ⇒ Object



675
676
677
678
679
680
681
# File 'lib/vertigo/pretty_printer.rb', line 675

def visitSliced(sliced_,args=nil)
  exp=sliced_.expr.accept(self,args)
  lhs=sliced_.lhs.accept(self,args)
  dir=sliced_.dir.accept(self,args)
  rhs=sliced_.rhs.accept(self,args)
  "#{exp}(#{lhs} #{dir} #{rhs})"
end

#visitStdType(stdtype, args = nil) ⇒ Object



569
570
571
# File 'lib/vertigo/pretty_printer.rb', line 569

def visitStdType(stdtype,args=nil)
  stdtype.ident.accept(self,args)
end

#visitSubTypeDecl(sub_type_decl, args = nil) ⇒ Object



194
195
196
197
198
199
200
201
202
# File 'lib/vertigo/pretty_printer.rb', line 194

def visitSubTypeDecl sub_type_decl,args=nil
  name=sub_type_decl.name.accept(self)
  type_spec=sub_type_decl.spec.accept(self)
  code=Code.new
  code.newline
  code << "subtype #{name} is #{type_spec};"
  code.newline
  code
end

#visitTimed(timed, args = nil) ⇒ Object



651
652
653
654
655
# File 'lib/vertigo/pretty_printer.rb', line 651

def visitTimed(timed,args=nil)
  lhs=timed.lhs.accept(self,args)
  rhs=timed.rhs.accept(self,args)
  "#{lhs} #{rhs}"
end

#visitToken(token, args = nil) ⇒ Object



20
21
22
# File 'lib/vertigo/pretty_printer.rb', line 20

def visitToken token,args=nil
  token.val
end

#visitTypeDecl(type_decl, args = nil) ⇒ Object



184
185
186
187
188
189
190
191
192
# File 'lib/vertigo/pretty_printer.rb', line 184

def visitTypeDecl type_decl,args=nil
  name=type_decl.name.accept(self)
  type_spec=type_decl.spec.accept(self)
  code=Code.new
  code.newline
  code << "type #{name} is #{type_spec};"
  code.newline
  code
end

#visitUse(use, args = nil) ⇒ Object



33
34
35
36
37
38
# File 'lib/vertigo/pretty_printer.rb', line 33

def visitUse(use,args=nil)
  library=use.library.accept(self,args)
  package=use.package.accept(self,args)
  element=use.element.accept(self,args)
  "use #{library}.#{package}.#{element};"
end

#visitVarAssign(varassign, args = nil) ⇒ Object



557
558
559
560
561
# File 'lib/vertigo/pretty_printer.rb', line 557

def visitVarAssign(varassign,args=nil)
  lhs=varassign.lhs.accept(self,args)
  rhs=varassign.rhs.accept(self,args)
  "#{lhs} := #{rhs};"
end

#visitVariable(variable, args = nil) ⇒ Object



253
254
255
256
257
258
259
# File 'lib/vertigo/pretty_printer.rb', line 253

def visitVariable variable,args=nil
  name=variable.name.accept(self)
  type=variable.type.accept(self)
  init=variable.init.accept(self) if variable.init
  init=" := #{init}" if init
  "variable #{name} : #{type}#{init};"
end

#visitWait(wait, args = nil) ⇒ Object



563
564
565
566
567
# File 'lib/vertigo/pretty_printer.rb', line 563

def visitWait(wait,args=nil)
  expr=wait.until_.accept(self,args) if wait.until_
  expr=wait.for_.accept(self,args) if wait.for_
  "wait #{expr};"
end

#visitWaveform(waveform, args = nil) ⇒ Object



597
598
599
600
# File 'lib/vertigo/pretty_printer.rb', line 597

def visitWaveform(waveform,args=nil)
  elements=waveform.elements.map{|element_| element_.accept(self,args)}
  elements.join(',')
end

#visitWhen(when_, args = nil) ⇒ Object



610
611
612
613
614
# File 'lib/vertigo/pretty_printer.rb', line 610

def visitWhen(when_,args=nil)
  expr=when_.expr.accept(self,args)
  cond=when_.cond.accept(self,args)
  "#{expr} when #{cond} else "
end

#visitWithSelect(withselect_, args = nil) ⇒ Object



378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/vertigo/pretty_printer.rb', line 378

def visitWithSelect(withselect_,args=nil)
  expr=withselect_.with_expr.accept(self,args)
  assigned=withselect_.assigned.accept(self,args)

  code=Code.new
  code << "with #{expr} select #{assigned} <="
  code.indent=2
  withselect_.selected_whens.each{|selected_when_| code << selected_when_.accept(self,args)+","}
  code.indent=0
  code.last << ";"
  code
end