Example #1
0
 def __init__(self, ctx):
     name = escape.unknown(Unknown._current_id)
     super().__init__(name, ctx)
     self.members = datatypes.MonitorDict()
     self.owner = None
     Unknown._current_id += 1
     self.class_name = self.name
     self._calls = []
     log.info("Creating %s", self.class_name)
Example #2
0
 def testMonitorDict(self):
   d = datatypes.MonitorDict()
   changestamp = d.changestamp
   var = self.prog.NewVariable()
   d["key"] = var
   self.assertGreater(d.changestamp, changestamp)
   changestamp = d.changestamp
   var.AddBinding("data")
   self.assertGreater(d.changestamp, changestamp)
   changestamp = d.changestamp
   var.AddBinding("data")  # No change because this is duplicate data
   self.assertEqual(d.changestamp, changestamp)
   changestamp = d.changestamp
Example #3
0
 def __init__(self, name, bases, members, cls, ctx):
     assert isinstance(name, str)
     assert isinstance(bases, list)
     assert isinstance(members, dict)
     self._bases = bases
     super().__init__(name, ctx)
     self.members = datatypes.MonitorDict(members)
     class_mixin.Class.init_mixin(self, cls)
     self.instances = set()  # filled through register_instance
     # instances created by analyze.py for the purpose of analyzing this class,
     # a subset of 'instances'. Filled through register_canonical_instance.
     self.canonical_instances = set()
     self.slots = self._convert_slots(members.get("__slots__"))
     self.is_dynamic = self.compute_is_dynamic()
     log.info("Created class: %r", self)
     self.type_param_check()
     self.decorators = []
Example #4
0
  def __init__(self, name, ctx):
    """Initialize a SimpleValue.

    Args:
      name: Name of this value. For debugging and error reporting.
      ctx: The abstract context.
    """
    super().__init__(name, ctx)
    self._cls = None  # lazily loaded 'cls' attribute
    self.members = datatypes.MonitorDict()
    # Lazily loaded to handle recursive types.
    # See Instance._load_instance_type_parameters().
    self._instance_type_parameters = datatypes.AliasingMonitorDict()
    # This attribute depends on self.cls, which isn't yet set to its true value.
    self._maybe_missing_members = None
    # The latter caches the result of get_type_key. This is a recursive function
    # that has the potential to generate too many calls for large definitions.
    self._cached_type_key = (
        (self.members.changestamp, self._instance_type_parameters.changestamp),
        None)