[pypy-svn] r66863 - in pypy/branch/avm: .ropeproject pypy/translator/avm1 pypy/translator/avm2

magcius at codespeak.net magcius at codespeak.net
Sun Aug 16 23:00:57 CEST 2009


Author: magcius
Date: Sun Aug 16 23:00:55 2009
New Revision: 66863

Added:
   pypy/branch/avm/.ropeproject/
   pypy/branch/avm/.ropeproject/config.py
Modified:
   pypy/branch/avm/pypy/translator/avm1/avm1.py
   pypy/branch/avm/pypy/translator/avm1/function.py
   pypy/branch/avm/pypy/translator/avm1/genavm.py
   pypy/branch/avm/pypy/translator/avm1/metavm.py
   pypy/branch/avm/pypy/translator/avm1/opcodes.py
   pypy/branch/avm/pypy/translator/avm1/swf.py
   pypy/branch/avm/pypy/translator/avm1/tags.py
   pypy/branch/avm/pypy/translator/avm2/__init__.py
   pypy/branch/avm/pypy/translator/avm2/constants.py
Log:
Changed import paths

Added: pypy/branch/avm/.ropeproject/config.py
==============================================================================
--- (empty file)
+++ pypy/branch/avm/.ropeproject/config.py	Sun Aug 16 23:00:55 2009
@@ -0,0 +1,85 @@
+# The default ``config.py``
+
+
+def set_prefs(prefs):
+    """This function is called before opening the project"""
+
+    # Specify which files and folders to ignore in the project.
+    # Changes to ignored resources are not added to the history and
+    # VCSs.  Also they are not returned in `Project.get_files()`.
+    # Note that ``?`` and ``*`` match all characters but slashes.
+    # '*.pyc': matches 'test.pyc' and 'pkg/test.pyc'
+    # 'mod*.pyc': matches 'test/mod1.pyc' but not 'mod/1.pyc'
+    # '.svn': matches 'pkg/.svn' and all of its children
+    # 'build/*.o': matches 'build/lib.o' but not 'build/sub/lib.o'
+    # 'build//*.o': matches 'build/lib.o' and 'build/sub/lib.o'
+    prefs['ignored_resources'] = ['*.pyc', '*~', '.ropeproject',
+                                  '.hg', '.svn', '_svn', '.git']
+
+    # Specifies which files should be considered python files.  It is
+    # useful when you have scripts inside your project.  Only files
+    # ending with ``.py`` are considered to be python files by
+    # default.
+    #prefs['python_files'] = ['*.py']
+
+    # Custom source folders:  By default rope searches the project
+    # for finding source folders (folders that should be searched
+    # for finding modules).  You can add paths to that list.  Note
+    # that rope guesses project source folders correctly most of the
+    # time; use this if you have any problems.
+    # The folders should be relative to project root and use '/' for
+    # separating folders regardless of the platform rope is running on.
+    # 'src/my_source_folder' for instance.
+    #prefs.add('source_folders', 'src')
+
+    # You can extend python path for looking up modules
+    #prefs.add('python_path', '~/python/')
+
+    # Should rope save object information or not.
+    prefs['save_objectdb'] = True
+    prefs['compress_objectdb'] = False
+
+    # If `True`, rope analyzes each module when it is being saved.
+    prefs['automatic_soa'] = True
+    # The depth of calls to follow in static object analysis
+    prefs['soa_followed_calls'] = 0
+
+    # If `False` when running modules or unit tests "dynamic object
+    # analysis" is turned off.  This makes them much faster.
+    prefs['perform_doa'] = True
+
+    # Rope can check the validity of its object DB when running.
+    prefs['validate_objectdb'] = True
+
+    # How many undos to hold?
+    prefs['max_history_items'] = 32
+
+    # Shows whether to save history across sessions.
+    prefs['save_history'] = True
+    prefs['compress_history'] = False
+
+    # Set the number spaces used for indenting.  According to
+    # :PEP:`8`, it is best to use 4 spaces.  Since most of rope's
+    # unit-tests use 4 spaces it is more reliable, too.
+    prefs['indent_size'] = 4
+
+    # Builtin and c-extension modules that are allowed to be imported
+    # and inspected by rope.
+    prefs['extension_modules'] = []
+
+    # Add all standard c-extensions to extension_modules list.
+    prefs['import_dynload_stdmods'] = True
+
+    # If `True` modules with syntax errors are considered to be empty.
+    # The default value is `False`; When `False` syntax errors raise
+    # `rope.base.exceptions.ModuleSyntaxError` exception.
+    prefs['ignore_syntax_errors'] = False
+
+    # If `True`, rope ignores unresolvable imports.  Otherwise, they
+    # appear in the importing namespace.
+    prefs['ignore_bad_imports'] = False
+
+
+def project_opened(project):
+    """This function is called after opening the project"""
+    # Do whatever you like here!

Modified: pypy/branch/avm/pypy/translator/avm1/avm1.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm1/avm1.py	(original)
+++ pypy/branch/avm/pypy/translator/avm1/avm1.py	Sun Aug 16 23:00:55 2009
@@ -2,7 +2,7 @@
 # AVM1 = ActionScript Virtual Machine 1
 # Used for ActionScript 1 and 2
 
-from pypy.translator.avm.util import BitStream
+from pypy.translator.avm1.util import BitStream
 from collections import namedtuple
 import struct
 

Modified: pypy/branch/avm/pypy/translator/avm1/function.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm1/function.py	(original)
+++ pypy/branch/avm/pypy/translator/avm1/function.py	Sun Aug 16 23:00:55 2009
@@ -4,8 +4,8 @@
 from pypy.rpython.ootypesystem import ootype
 from pypy.rpython.lltypesystem.lltype import Void
 from pypy.translator.oosupport.function import Function as OOFunction
-from pypy.translator.avm.node import Node
-from pypy.translator.avm.avm1gen import ClassName
+from pypy.translator.avm1.node import Node
+from pypy.translator.avm1.avm1gen import ClassName
 
 def load_variable_hook(self, v):
     if v.name in self.argset:

Modified: pypy/branch/avm/pypy/translator/avm1/genavm.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm1/genavm.py	(original)
+++ pypy/branch/avm/pypy/translator/avm1/genavm.py	Sun Aug 16 23:00:55 2009
@@ -1,12 +1,12 @@
 
 import py
 from pypy.translator.oosupport.genoo import GenOO
-from pypy.translator.avm.avm1gen import AVM1Gen
-from pypy.translator.avm.constant import AVM1ConstGenerator
-from pypy.translator.avm.database import LowLevelDatabase
-from pypy.translator.avm.function import Function
-from pypy.translator.avm.opcodes import opcodes
-from pypy.translator.avm.types import AVM1TypeSystem
+from pypy.translator.avm1.avm1gen import AVM1Gen
+from pypy.translator.avm1.constant import AVM1ConstGenerator
+from pypy.translator.avm1.database import LowLevelDatabase
+from pypy.translator.avm1.function import Function
+from pypy.translator.avm1.opcodes import opcodes
+from pypy.translator.avm1.types import AVM1TypeSystem
 
 class GenAVM1(GenOO):
     

Modified: pypy/branch/avm/pypy/translator/avm1/metavm.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm1/metavm.py	(original)
+++ pypy/branch/avm/pypy/translator/avm1/metavm.py	Sun Aug 16 23:00:55 2009
@@ -1,7 +1,6 @@
 
 from pypy.rpython.ootypesystem import ootype
 from pypy.translator.oosupport.metavm import MicroInstruction
-from pypy.translator.avm.avm1gen import StackDummy
 
 class _SetField(MicroInstruction):
     def render(self, generator, op):

Modified: pypy/branch/avm/pypy/translator/avm1/opcodes.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm1/opcodes.py	(original)
+++ pypy/branch/avm/pypy/translator/avm1/opcodes.py	Sun Aug 16 23:00:55 2009
@@ -1,6 +1,6 @@
 
 from pypy.translator.oosupport import metavm as om
-from pypy.translator.avm import metavm as am, avm1 as a
+from pypy.translator.avm1 import metavm as am, avm1 as a
 
 DoNothing = [om.PushAllArgs]
 

Modified: pypy/branch/avm/pypy/translator/avm1/swf.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm1/swf.py	(original)
+++ pypy/branch/avm/pypy/translator/avm1/swf.py	Sun Aug 16 23:00:55 2009
@@ -1,8 +1,8 @@
 
 import struct
 
-from pypy.translator.avm.util import BitStream
-from pypy.translator.avm.records import Rect
+from pypy.translator.avm1.util import BitStream
+from pypy.translator.avm1.records import Rect
 
 class SwfData(object):
 

Modified: pypy/branch/avm/pypy/translator/avm1/tags.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm1/tags.py	(original)
+++ pypy/branch/avm/pypy/translator/avm1/tags.py	Sun Aug 16 23:00:55 2009
@@ -1,9 +1,9 @@
 
 import struct
 
-from pypy.translator.avm.records import RecordHeader, ShapeWithStyle, Matrix, CXForm
-from pypy.translator.avm.avm1 import Block
-from pypy.translator.avm.util import BitStream
+from pypy.translator.avm1.records import RecordHeader, ShapeWithStyle, Matrix, CXForm
+from pypy.translator.avm1.avm1 import Block
+from pypy.translator.avm1.util import BitStream
 
 next_character_id = 1
 

Modified: pypy/branch/avm/pypy/translator/avm2/__init__.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm2/__init__.py	(original)
+++ pypy/branch/avm/pypy/translator/avm2/__init__.py	Sun Aug 16 23:00:55 2009
@@ -1 +1 @@
-a
+

Modified: pypy/branch/avm/pypy/translator/avm2/constants.py
==============================================================================
--- pypy/branch/avm/pypy/translator/avm2/constants.py	(original)
+++ pypy/branch/avm/pypy/translator/avm2/constants.py	Sun Aug 16 23:00:55 2009
@@ -1,6 +1,6 @@
 
 import struct
-from pypy.translator.avm.util import serialize_u32 as u32
+from pypy.translator.avm2.util import serialize_u32 as u32
 
 # ======================================
 # Constants
@@ -69,7 +69,7 @@
         return not self == other
         
     def write_to_pool(self, pool):
-        self._name_index = pool.utf8_index(name)
+        self._name_index = pool.utf8_pool.index_for(self.name)
 
     def serialize(self):
         assert self._name_index is not None, "Please call write_to_pool before serializing"
@@ -94,11 +94,11 @@
         return not self == other
 
     def write_to_pool(self, pool):
-        self._namespace_indices = [pool.namespace_index(ns) for ns in self.namespaces]
+        self._namespace_indices = [pool.namespace_pool.index_for(ns) for ns in self.namespaces]
     
     def serialize(self):
         assert self._namespace_indices is not None, "Please call write_to_pool before serializing"
-        return u32(len(self.namespaces)) + ''.join(u32(index) for index in self_namespace_indices)
+        return u32(len(self.namespaces)) + ''.join(u32(index) for index in self._namespace_indices)
         
 
 NO_NAMESPACE  = Namespace(TYPE_NAMESPACE_Namespace, "")
@@ -127,7 +127,7 @@
         return hash((self.kind, self.ns_set))
     
     def write_to_pool(self, pool):
-        self._ns_set_index = pool.nsset_index(self.ns_set)
+        self._ns_set_index = pool.nsset_pool.index_for(self.ns_set)
 
     def serialize(self):
         assert self._ns_set_index is not None, "Please call write_to_pool before serializing"
@@ -155,7 +155,7 @@
 
     def write_to_pool(self, pool):
         super(Multiname, self).write_to_pool(pool)
-        self._name_index = pool.utf8_index(self.name)
+        self._name_index = pool.utf8_pool.index_for(self.name)
 
     def serialize(self):
         assert self._name_index is not None, "Please call write_to_pool before serializing"
@@ -186,8 +186,8 @@
         return hash((self.kind, self.name, self.ns))
     
     def write_to_pool(self, pool):
-        self._name_index = pool.utf8_index(self.name)
-        self._ns_index = pool.namespace_index(self.ns)
+        self._name_index = pool.utf8_pool.index_for(self.name)
+        self._ns_index = pool.namespace_pool.index_for(self.ns)
         
     def serialize(self):
         assert self._name_index is not None, "Please call write_to_pool before serializing"
@@ -223,7 +223,7 @@
         self._name_index = None
 
     def write_to_pool(self, pool):
-        self._name_index = pool.utf8_index(name)
+        self._name_index = pool.utf8_pool.index_for(name)
 
     def serialize(self):
         assert self._name_index is not None, "Please call write_to_pool before serializing"
@@ -232,22 +232,7 @@
 # Constant Pool
 # ======================================
 
-def constant_index_base(default, pool_name):
-    def fn(self, value):
-        if value == default:
-            return 0
-        
-        pool = getattr(self, pool_name)
-        
-        if value in pool:
-            return pool.index(value) + 1
-        else:
-            pool.append(value)
-            return len(pool)
-        
-    return fn
-
-class OptimizedPool(object):
+class ValuePool(object):
     
     def __init__(self, default):
         self.index_map = {}
@@ -258,17 +243,17 @@
         if value == self.default:
             return 0
         
-        if value in index_map:
-            return index_map[value]
+        if value in self.index_map:
+            return self.index_map[value]
         
         self.pool.append(value)
         index = len(self.pool)
         self.index_map[value] = index
         return index
-
+    
     def value_at(self, index):
         if index == 0:
-            return default
+            return self.default
         
         if index < len(self.pool):
             return self.pool[index]
@@ -278,26 +263,25 @@
 class AbcConstantPool(object):
     
     def __init__(self):
-        self.int_pool       = OptimizedPool()
-        self.uint_pool      = OptimizedPool()
-        self.double_pool    = OptimizedPool()
-        self.utf8_pool      = OptimizedPool()
-        self.namespace_pool = OptimizedPool()
-        self.nsset_pool     = OptimizedPool()
-        self.multiname_pool = OptimizedPool()
-        
-    int_index       = constant_index_base(0, "int_pool")
-    uint_index      = constant_index_base(0, "uint_pool")
-    double_index    = constant_index_base(float("nan"), "double_pool")
-    utf8_index      = constant_index_base("", "utf8_pool")
-    namespace_index = constant_index_base(ANY_NAMESPACE, "namespace_pool")
-    nsset_index     = constant_index_base(NO_NAMESPACE_SET, "nsset_pool")
-
+        self.int_pool       = ValuePool(0)
+        self.uint_pool      = ValuePool(0)
+        self.double_pool    = ValuePool(float("nan"))
+        self.utf8_pool      = ValuePool("")
+        self.namespace_pool = ValuePool(ANY_NAMESPACE)
+        self.nsset_pool     = ValuePool(NO_NAMESPACE_SET)
+        self.multiname_pool = ValuePool()
+        
     def has_RTNS(self, index):
-        return self.multiname_pool[index].kind in (TYPE_MULTINAME_RtqName, TYPE_MULTINAME_RtqNameA, TYPE_MULTINAME_RtqNameL, TYPE_MULTINAME_RtqNameLA)
+        return self.multiname_pool[index].kind in (TYPE_MULTINAME_RtqName,
+                                                   TYPE_MULTINAME_RtqNameA,
+                                                   TYPE_MULTINAME_RtqNameL,
+                                                   TYPE_MULTINAME_RtqNameLA)
 
     def has_RTName(self, index):
-        return self.multiname_pool[index].kind in (TYPE_MULTINAME_MultinameL, TYPE_MULTINAME_MultinameLA, TYPE_MULTINAME_RtqNameL, TYPE_MULTINAME_RtqNameLA)
+        return self.multiname_pool[index].kind in (TYPE_MULTINAME_MultinameL,
+                                                   TYPE_MULTINAME_MultinameLA,
+                                                   TYPE_MULTINAME_RtqNameL,
+                                                   TYPE_MULTINAME_RtqNameLA)
 
     def serialize(self):
 



More information about the Pypy-commit mailing list