Class: Elf::Policy::StateBuilder

Inherits:
Object
  • Object
show all
Includes:
BuilderHelper
Defined in:
lib/mithril/policy/dsl.rb

Instance Method Summary collapse

Methods included from BuilderHelper

#section_start

Constructor Details

#initialize(from, to, pol) ⇒ StateBuilder

Returns a new instance of StateBuilder.



252
253
254
255
256
# File 'lib/mithril/policy/dsl.rb', line 252

def initialize(from,to,pol)
  @from = from
  @to = to
  @policy = pol
end

Instance Method Details

#call(symbol, parambytes = 0, returnbytes = 0) ⇒ Object



265
266
267
268
# File 'lib/mithril/policy/dsl.rb', line 265

def call(symbol, parambytes= 0, returnbytes=0)
  raise RuntimeError.new "Call has to have a destination" if @from == @to 
  @policy << Call.new(@from,@to, symbol, parambytes, returnbytes)
end

#call_noreturn(symbol, parambytes = 0) ⇒ Object



269
270
271
# File 'lib/mithril/policy/dsl.rb', line 269

def call_noreturn(symbol,parambytes=0)
  call(symbol, parambytes,-1)
end

#exec(tag) ⇒ Object



277
278
279
280
# File 'lib/mithril/policy/dsl.rb', line 277

def exec(tag)
  mem(tag){
    exec        }
end

#mem(tag, &block) ⇒ Object



272
273
274
275
276
# File 'lib/mithril/policy/dsl.rb', line 272

def mem(tag, &block)
  d = Data.new(@from,@to,tag)
  DataBuilder.new(d).instance_eval(&block)
  @policy << d
end

#read(tag) ⇒ Object



281
282
283
284
285
# File 'lib/mithril/policy/dsl.rb', line 281

def read(tag)
  mem(tag){
    read
  }
end

#readwrite(tag) ⇒ Object



291
292
293
294
295
296
# File 'lib/mithril/policy/dsl.rb', line 291

def readwrite(tag)
  mem(tag){
    read
    write
  }
end

#to(name, &block) ⇒ Object



298
299
300
301
# File 'lib/mithril/policy/dsl.rb', line 298

def to(name,&block)
  raise RuntimeError.new "Cannot nest to{} blocks" if @from != @to#  or name == @from
  StateBuilder.new(@from,name, @policy).instance_eval(&block)
end

#transition(trans) ⇒ Object



302
303
304
# File 'lib/mithril/policy/dsl.rb', line 302

def transition(trans)
  @policy << trans 
end

#write(tag) ⇒ Object



286
287
288
289
290
# File 'lib/mithril/policy/dsl.rb', line 286

def write(tag)
  mem(tag){
    write
  }
end