Permalink
Browse files

Simplification of name mangling.

  • Loading branch information...
Andy Chu
Andy Chu committed Mar 19, 2018
1 parent 1daf806 commit 750a934a3873ade70eb49deec9320adcc34ad9d5
Showing with 8 additions and 12 deletions.
  1. +4 −1 opy/compiler2/misc.py
  2. +1 −4 opy/compiler2/pycodegen.py
  3. +3 −7 opy/compiler2/symbols.py
View
@@ -3,8 +3,11 @@
MANGLE_LEN = 256 # magic constant from compile.c
def mangle(name, klass):
if not name.startswith('__'):
if klass is None: # nothing to mangle
return name
if not name.startswith('__'): # not a private var
return name
if len(name) + 2 >= MANGLE_LEN:
return name
if name.endswith('__'):
@@ -198,10 +198,7 @@ def _setupGraphDelegation(self):
self.setDocstring = self.graph.setDocstring
def mangle(self, name):
if self.class_name is not None:
return misc.mangle(name, self.class_name)
else:
return name
return misc.mangle(name, self.class_name)
def parseSymbols(self, tree):
s = symbols.SymbolVisitor()
View
@@ -2,15 +2,13 @@
from __future__ import print_function
from . import ast
from . import misc
from .consts import SC_LOCAL, SC_GLOBAL_IMPLICIT, SC_GLOBAL_EXPLICIT, \
SC_FREE, SC_CELL, SC_UNKNOWN
from .misc import mangle
import types
import sys
import types
MANGLE_LEN = 256
class Scope(object):
# XXX how much information do I need about each name?
@@ -46,9 +44,7 @@ def DebugDump(self):
print("\tfrees:", self.frees, file=sys.stderr)
def mangle(self, name):
if self.klass is None:
return name
return mangle(name, self.klass)
return misc.mangle(name, self.klass)
def add_def(self, name):
self.defs[self.mangle(name)] = 1

0 comments on commit 750a934

Please sign in to comment.