Class: TypeProf::Core::LocalEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/typeprof/core/env.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, cref, locals, return_boxes) ⇒ LocalEnv

Returns a new instance of LocalEnv.



280
281
282
283
284
285
286
287
288
# File 'lib/typeprof/core/env.rb', line 280

def initialize(path, cref, locals, return_boxes)
  @path = path
  @cref = cref
  @locals = locals
  @return_boxes = return_boxes
  @break_vtx = nil
  @next_boxes = []
  @filters = {}
end

Instance Attribute Details

#break_vtxObject (readonly)

Returns the value of attribute break_vtx.



290
291
292
# File 'lib/typeprof/core/env.rb', line 290

def break_vtx
  @break_vtx
end

#crefObject (readonly)

Returns the value of attribute cref.



290
291
292
# File 'lib/typeprof/core/env.rb', line 290

def cref
  @cref
end

#localsObject (readonly)

Returns the value of attribute locals.



290
291
292
# File 'lib/typeprof/core/env.rb', line 290

def locals
  @locals
end

#next_boxesObject (readonly)

Returns the value of attribute next_boxes.



290
291
292
# File 'lib/typeprof/core/env.rb', line 290

def next_boxes
  @next_boxes
end

#pathObject (readonly)

Returns the value of attribute path.



290
291
292
# File 'lib/typeprof/core/env.rb', line 290

def path
  @path
end

#return_boxesObject (readonly)

Returns the value of attribute return_boxes.



290
291
292
# File 'lib/typeprof/core/env.rb', line 290

def return_boxes
  @return_boxes
end

Instance Method Details

#add_next_box(box) ⇒ Object



312
313
314
# File 'lib/typeprof/core/env.rb', line 312

def add_next_box(box)
  @next_boxes << box
end

#add_return_box(box) ⇒ Object



308
309
310
# File 'lib/typeprof/core/env.rb', line 308

def add_return_box(box)
  @return_boxes << box
end

#apply_read_filter(genv, node, name, vtx) ⇒ Object



329
330
331
332
333
334
335
336
337
# File 'lib/typeprof/core/env.rb', line 329

def apply_read_filter(genv, node, name, vtx)
  if @filters[name] && !@filters[name].empty?
    case @filters[name].last
    when :non_nil
      return NilFilter.new(genv, node, vtx, false).next_vtx
    end
  end
  vtx
end

#exist_var?(name) ⇒ Boolean

Returns:

  • (Boolean)


304
305
306
# File 'lib/typeprof/core/env.rb', line 304

def exist_var?(name)
  !!@locals[name]
end

#get_break_vtxObject



316
317
318
# File 'lib/typeprof/core/env.rb', line 316

def get_break_vtx
  @break_vtx ||= Vertex.new(:break_vtx)
end

#get_var(name) ⇒ Object



300
301
302
# File 'lib/typeprof/core/env.rb', line 300

def get_var(name)
  @locals[name] || raise("#{ name }")
end

#new_var(name, node) ⇒ Object



292
293
294
# File 'lib/typeprof/core/env.rb', line 292

def new_var(name, node)
  @locals[name] = Vertex.new(node)
end

#pop_read_filter(name) ⇒ Object



325
326
327
# File 'lib/typeprof/core/env.rb', line 325

def pop_read_filter(name)
  (@filters[name] ||= []).pop
end

#push_read_filter(name, type) ⇒ Object



321
322
323
# File 'lib/typeprof/core/env.rb', line 321

def push_read_filter(name, type)
  (@filters[name] ||= []) << type
end

#set_var(name, vtx) ⇒ Object



296
297
298
# File 'lib/typeprof/core/env.rb', line 296

def set_var(name, vtx)
  @locals[name] = vtx
end