Ejemplo n.º 1
0
 def setUp(self):
   super(AbstractTestBase, self).setUp()
   options = config.Options.create(python_version=self.python_version)
   self._vm = vm.VirtualMachine(
       errors.ErrorLog(), options, load_pytd.Loader(None, self.python_version))
   self._program = self._vm.program
   self._node = self._vm.root_cfg_node.ConnectNew("test_node")
Ejemplo n.º 2
0
 def test_diamond(self):
   # Disassembled from:
   # | if []:
   # |   y = 1
   # | elif []:
   # |   y = 2
   # | elif []:
   # |   y = None
   # | return y
   code = self.make_code([
       0x67, 0, 0,   #  0 BUILD_LIST, arg=0,
       0x72, 15, 0,  #  3 POP_JUMP_IF_FALSE, dest=15,
       0x64, 1, 0,   #  6 LOAD_CONST, arg=1 (1),
       0x7d, 1, 0,   #  9 STORE_FAST, arg=1 "y",
       0x6e, 30, 0,  # 12 JUMP_FORWARD, dest=45,
       0x67, 0, 0,   # 15 BUILD_LIST, arg=0,
       0x72, 30, 0,  # 18 POP_JUMP_IF_FALSE, dest=30,
       0x64, 2, 0,   # 21 LOAD_CONST, arg=2 (2),
       0x7d, 1, 0,   # 24 STORE_FAST, arg=1 "y",
       0x6e, 15, 0,  # 27 JUMP_FORWARD, dest=45,
       0x67, 0, 0,   # 30 BUILD_LIST, arg=0,
       0x72, 45, 0,  # 33 POP_JUMP_IF_FALSE, dest=45,
       0x64, 0, 0,   # 36 LOAD_CONST, arg=0 (None),
       0x7d, 1, 0,   # 39 STORE_FAST, arg=1 "y",
       0x6e, 0, 0,   # 42 JUMP_FORWARD, dest=45,
       0x7c, 1, 0,   # 45 LOAD_FAST, arg=1,
       0x53,         # 48 RETURN_VALUE
   ])
   code = blocks.process_code(code, {})
   v = vm.VirtualMachine(self.errorlog, self.options, loader=self.loader)
   v.run_bytecode(v.program.NewCFGNode(), code)
Ejemplo n.º 3
0
 def setUp(self):
     super(MatcherTest, self).setUp()
     options = config.Options.create(python_version=self.PYTHON_VERSION)
     self.vm = vm.VirtualMachine(
         errors.ErrorLog(), options,
         load_pytd.Loader(None, self.PYTHON_VERSION))
     self.type_type = self.vm.convert.type_type
Ejemplo n.º 4
0
 def setUp(self):
     super().setUp()
     options = config.Options.create(python_version=self.python_version)
     self.vm = vm.VirtualMachine(
         errors.ErrorLog(), options,
         load_pytd.Loader(None, self.python_version))
     self.type_type = self.vm.convert.type_type
Ejemplo n.º 5
0
 def setUp(self):
     super().setUp()
     options = config.Options.create(python_version=self.python_version)
     self.vm = vm.VirtualMachine(
         errors.ErrorLog(), options,
         load_pytd.Loader(None, self.python_version))
     self.node = self.vm.root_node
     self.attribute_handler = self.vm.attribute_handler
Ejemplo n.º 6
0
 def test_simple(self):
   # Disassembled from:
   # | return None
   code = self.make_code([
       0x64, 1, 0,  # 0 LOAD_CONST, arg=1 (1)
       0x53,  # 3 RETURN_VALUE
   ], name="simple")
   code = blocks.process_code(code, {})
   v = vm.VirtualMachine(self.errorlog, self.options, loader=self.loader)
   v.run_bytecode(v.program.NewCFGNode(), code)
Ejemplo n.º 7
0
 def test_simple(self):
     # Disassembled from:
     # | return None
     code = self.make_code(
         [
             0x64,
             1,  # 0 LOAD_CONST, arg=1 (1)
             0x53,
             0,  # 3 RETURN_VALUE (0)
         ],
         name="simple")
     code = blocks.process_code(code, self.python_version)
     ctx = context.Context(self.errorlog, self.options, loader=self.loader)
     ctx.vm = vm.VirtualMachine(ctx)
     ctx.vm.run_bytecode(ctx.program.NewCFGNode(), code)
Ejemplo n.º 8
0
 def test_simple(self):
     program = cfg.Program()
     # Disassembled from:
     # | return None
     code = self.make_code(
         [
             0x64,
             1,
             0,  # 0 LOAD_CONST, arg=1 (1)
             0x53,  # 3 RETURN_VALUE
         ],
         name="simple")
     code = blocks.process_code(code)
     v = vm.VirtualMachine(self.PYTHON_VERSION, errors.ErrorLog())
     v.run_bytecode(program.NewCFGNode(), code)
Ejemplo n.º 9
0
 def test_diamond(self):
     # Disassembled from:
     # | if []:
     # |   y = 1
     # | elif []:
     # |   y = 2
     # | elif []:
     # |   y = None
     # | return y
     o = test_utils.Py37Opcodes
     code = self.make_code([
         o.BUILD_LIST,
         0,
         o.POP_JUMP_IF_FALSE,
         10,
         o.LOAD_CONST,
         1,
         o.STORE_FAST,
         0,
         o.JUMP_FORWARD,
         18,
         o.BUILD_LIST,
         0,
         o.POP_JUMP_IF_FALSE,
         20,
         o.LOAD_CONST,
         2,
         o.STORE_FAST,
         0,
         o.JUMP_FORWARD,
         8,
         o.BUILD_LIST,
         0,
         o.POP_JUMP_IF_FALSE,
         28,
         o.LOAD_CONST,
         0,
         o.STORE_FAST,
         0,
         o.LOAD_FAST,
         0,
         o.RETURN_VALUE,
         0,
     ])
     code = blocks.process_code(code, self.python_version)
     ctx = context.Context(self.errorlog, self.options, loader=self.loader)
     ctx.vm = vm.VirtualMachine(ctx)
     ctx.vm.run_bytecode(ctx.program.NewCFGNode(), code)
Ejemplo n.º 10
0
 def setUp(self):
     super(AttributeTest, self).setUp()
     options = config.Options.create(python_version=self.python_version)
     self._vm = vm.VirtualMachine(
         errors.ErrorLog(), options,
         load_pytd.Loader(None, self.python_version))
Ejemplo n.º 11
0
 def setUp(self):
     super(GetViewsTest, self).setUp()
     self._vm = vm.VirtualMachine(
         errors.ErrorLog(),
         config.Options.create(python_version=self.python_version),
         load_pytd.Loader(None, self.python_version))
Ejemplo n.º 12
0
 def setUp(self):
     options = config.Options.create()
     self._vm = vm.VirtualMachine(errors.ErrorLog(), options,
                                  load_pytd.Loader(None, options))
Ejemplo n.º 13
0
 def setUp(self):
   self._vm = vm.VirtualMachine(errors.ErrorLog(), config.Options.create(),
                                load_pytd.Loader(None, (2, 7)))
Ejemplo n.º 14
0
 def setUp(self):
     self._vm = vm.VirtualMachine(errors.ErrorLog(), config.Options([""]))
     self._program = cfg.Program()
     self._node = self._vm.root_cfg_node.ConnectNew("test_node")
Ejemplo n.º 15
0
 def setUp(self):
     self.vm = vm.VirtualMachine(errors.ErrorLog(), config.Options([""]))
     self.type_type = abstract.get_atomic_value(self.vm.convert.type_type)
Ejemplo n.º 16
0
 def setUp(self):
     options = config.Options.create()
     self._vm = vm.VirtualMachine(errors.ErrorLog(), options,
                                  load_pytd.Loader(None, options))
     self._program = cfg.Program()
     self._node = self._vm.root_cfg_node.ConnectNew("test_node")
Ejemplo n.º 17
0
 def setUp(self):
   self._vm = vm.VirtualMachine(errors.ErrorLog(), config.Options([""]))
   self._program = cfg.Program()
   self._node = self._program.NewCFGNode("test_node")
Ejemplo n.º 18
0
 def setUp(self):
     options = config.Options.create()
     self.vm = vm.VirtualMachine(
         errors.ErrorLog(), options,
         load_pytd.Loader(None, self.PYTHON_VERSION))
     self.type_type = self.vm.convert.type_type
Ejemplo n.º 19
0
 def setUp(self):
     self._vm = vm.VirtualMachine(errors.ErrorLog(), config.Options([""]))
Ejemplo n.º 20
0
 def test_diamond(self):
     # Disassembled from:
     # | if []:
     # |   y = 1
     # | elif []:
     # |   y = 2
     # | elif []:
     # |   y = None
     # | return y
     o = test_utils.Py2Opcodes
     code = self.make_code([
         o.BUILD_LIST,
         0,
         0,
         o.POP_JUMP_IF_FALSE,
         15,
         0,
         o.LOAD_CONST,
         1,
         0,
         o.STORE_FAST,
         1,
         0,
         o.JUMP_FORWARD,
         30,
         0,
         o.BUILD_LIST,
         0,
         0,
         o.POP_JUMP_IF_FALSE,
         30,
         0,
         o.LOAD_CONST,
         2,
         0,
         o.STORE_FAST,
         1,
         0,
         o.JUMP_FORWARD,
         15,
         0,
         o.BUILD_LIST,
         0,
         0,
         o.POP_JUMP_IF_FALSE,
         45,
         0,
         o.LOAD_CONST,
         0,
         0,
         o.STORE_FAST,
         1,
         0,
         o.JUMP_FORWARD,
         0,
         0,
         o.LOAD_FAST,
         1,
         0,
         o.RETURN_VALUE,
     ])
     code = blocks.process_code(code)
     v = vm.VirtualMachine(self.errorlog, self.options, loader=self.loader)
     v.run_bytecode(v.program.NewCFGNode(), code)
Ejemplo n.º 21
0
 def setUp(self):
   super().setUp()
   options = config.Options.create(python_version=self.python_version)
   self.vm = vm.VirtualMachine(
       errors.ErrorLog(), options, load_pytd.Loader(None, self.python_version))
   self.vm._fold_constants = True