Class: Gisele::Analysis::Compiling::Ast2Glts

Inherits:
Processor
  • Object
show all
Defined in:
lib/gisele/analysis/compiling/ast2glts.rb

Instance Attribute Summary

Attributes inherited from Processor

#session

Instance Method Summary collapse

Methods inherited from Processor

call, #initialize

Methods included from Mixin::BddManagement

#bdd, #bdd_interface, #cudd_manager, #one, #with_bdd, #zero

Constructor Details

This class inherits a constructor from Gisele::Analysis::Compiling::Processor

Instance Method Details

#on_case_st(sexpr) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/gisele/analysis/compiling/ast2glts.rb', line 62

def on_case_st(sexpr)
  cond, *clauses = sexpr.sexpr_body

  entry, exit = entry_and_exit(sexpr)

  diamond = add_state(sexpr)
  connect(entry, diamond)

  clauses.each do |clause|
    c_entry, c_exit = apply(clause.last)
    connect(diamond, c_entry, clause[1])
    connect(c_exit, exit)
  end

  [entry, exit]
end

#on_if_st(sexpr) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/gisele/analysis/compiling/ast2glts.rb', line 39

def on_if_st(sexpr)
  cond, then_clause, else_clause, = sexpr.sexpr_body

  entry, exit = entry_and_exit(sexpr)

  diamond = add_state(sexpr)
  connect(entry, diamond)

  c_entry, c_exit = apply(then_clause)
  connect(diamond, c_entry, cond)
  connect(c_exit, exit)

  if else_clause
    c_entry, c_exit = apply(else_clause.last)
    connect(diamond, c_entry, cond.negate)
    connect(c_exit, exit)
  else
    connect(diamond, exit, cond.negate)
  end

  [entry, exit]
end

#on_seq_st(sexpr) ⇒ Object Also known as: on_par_st



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gisele/analysis/compiling/ast2glts.rb', line 26

def on_seq_st(sexpr)
  mine    = entry_and_exit(sexpr)
  current = mine.first
  sexpr.sexpr_body.each do |child|
    c_entry, c_exit = apply(child)
    connect(current, c_entry)
    current = c_exit
  end
  connect(current, mine.last)
  mine
end

#on_task_call_st(sexpr) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/gisele/analysis/compiling/ast2glts.rb', line 96

def on_task_call_st(sexpr)
  entry, exit = entry_and_exit(sexpr)
  middle = add_state(sexpr)
  connect(entry, middle, transition(sexpr, "start"))
  connect(middle, exit, transition(sexpr, "end"))
  [entry, exit]
end

#on_task_def(sexpr) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gisele/analysis/compiling/ast2glts.rb', line 13

def on_task_def(sexpr)
  @glts = Analysis::Glts.new(session)

  entry = add_state(sexpr, :initial => true)
  exit  = add_state(sexpr)

  c_entry, c_exit = apply(sexpr.last)
  connect(entry, c_entry, transition(sexpr, "start"))
  connect(c_exit, exit, transition(sexpr, "end"))

  @glts
end

#on_unit_def(sexpr) ⇒ Object



9
10
11
# File 'lib/gisele/analysis/compiling/ast2glts.rb', line 9

def on_unit_def(sexpr)
  apply(sexpr[1])
end

#on_while_st(sexpr) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/gisele/analysis/compiling/ast2glts.rb', line 79

def on_while_st(sexpr)
  cond, dost, = sexpr.sexpr_body

  entry, exit = entry_and_exit(sexpr)

  diamond = add_state(sexpr)
  connect(entry, diamond)

  c_entry, c_exit = apply(sexpr.last)

  connect(diamond, exit, cond.negate)
  connect(diamond, c_entry, cond)
  connect(c_exit, diamond)

  [entry, exit]
end