Permalink
Browse files

Change all Oil classes to be new-style classes.

This is so that callgraph.py can correctly walk them.  Otherwise
isinstance(x, type) isn't true.
  • Loading branch information...
Andy Chu
Andy Chu committed Mar 15, 2018
1 parent 3b5a3f2 commit eac70cd6abdd396a43e91cb0d315310b21659727
Showing with 41 additions and 28 deletions.
  1. +7 −7 asdl/asdl_.py
  2. +2 −2 asdl/encode.py
  3. +3 −3 asdl/format.py
  4. +1 −1 core/args.py
  5. +1 −1 core/braces.py
  6. +1 −1 core/completion.py
  7. +1 −1 core/expr_eval.py
  8. +5 −5 core/process.py
  9. +2 −2 core/test_builtin.py
  10. +2 −2 core/util.py
  11. +1 −1 core/word_eval.py
  12. +5 −0 opy/callgraph.py
  13. +8 −0 scripts/count.sh
  14. +2 −2 tools/osh2oil.py
View
@@ -43,34 +43,34 @@ def is_simple(sum):
return True
class StrType:
class StrType(object):
def __repr__(self):
return '<Str>'
class IntType:
class IntType(object):
def __repr__(self):
return '<Int>'
class BoolType:
class BoolType(object):
def __repr__(self):
return '<Bool>'
class ArrayType:
class ArrayType(object):
def __init__(self, desc):
self.desc = desc
def __repr__(self):
return '<Array %s>' % self.desc
class MaybeType:
class MaybeType(object):
def __init__(self, desc):
self.desc = desc # another descriptor
def __repr__(self):
return '<Maybe %s>' % self.desc
class UserType:
class UserType(object):
def __init__(self, typ):
assert isinstance(typ, type), typ
self.typ = typ
@@ -178,7 +178,7 @@ def ResolveTypes(module, app_types=None):
builtin_types = {'string', 'int', 'bool'}
class AST:
class AST(object):
def Print(self, f, indent):
raise NotImplementedError
View
@@ -17,7 +17,7 @@ def __init__(self, *args, **kwargs):
_DEFAULT_ALIGNMENT = 4
class BinOutput:
class BinOutput(object):
"""Write aligned blocks here. Keeps track of block indexes for refs."""
def __init__(self, f, alignment=_DEFAULT_ALIGNMENT):
@@ -49,7 +49,7 @@ def Write(self, chunk):
return ref
class Params:
class Params(object):
"""Encoding parameters.
Hm most of these settings should be per-field, expressed in the schema. The
View
@@ -33,7 +33,7 @@ def DetectConsoleOutput(f):
return TextOutput(f)
class ColorOutput:
class ColorOutput(object):
"""Abstract base class for plain text, ANSI color, and HTML color."""
def __init__(self, f):
@@ -206,7 +206,7 @@ def PopColor(self):
#
class _Obj:
class _Obj(object):
"""Node for pretty-printing."""
def __init__(self, node_type):
self.node_type = node_type
@@ -225,7 +225,7 @@ def __repr__(self):
return '<_Obj %s %s>' % (self.node_type, self.fields)
class _ColoredString:
class _ColoredString(object):
"""Node for pretty-printing."""
def __init__(self, s, str_type):
assert isinstance(s, str), s
View
@@ -81,7 +81,7 @@ def __repr__(self):
return '<_Attributes %s>' % self.__dict__
class _ArgState:
class _ArgState(object):
"""Modified by both the parsing loop and various actions."""
def __init__(self, argv):
View
@@ -24,7 +24,7 @@
word_e = ast.word_e
class _StackFrame:
class _StackFrame(object):
def __init__(self, cur_parts):
self.cur_parts = cur_parts
self.alt_part = ast.BracedAltPart()
View
@@ -733,7 +733,7 @@ def InitReadline(complete_cb):
readline.set_completer_delims(' ')
class StatusOutput:
class StatusOutput(object):
def __init__(self, status_lines, exec_opts):
self.status_lines = status_lines
self.exec_opts = exec_opts
View
@@ -107,7 +107,7 @@ def _StringToInteger(s, word=None):
return integer
class _ExprEvaluator:
class _ExprEvaluator(object):
"""
For now the arith and bool evaluators share some logic.
"""
View
@@ -26,7 +26,7 @@
log = util.log
class _FdFrame:
class _FdFrame(object):
def __init__(self):
self.saved = []
self.need_close = []
@@ -42,7 +42,7 @@ def __repr__(self):
return '<_FdFrame %s %s>' % (self.saved, self.need_close)
class FdState:
class FdState(object):
"""This is for the current process, as opposed to child processes.
For example, you can do 'myfunc > out.txt' without forking.
@@ -241,7 +241,7 @@ def Pop(self):
unused_status = proc.WaitUntilDone(waiter)
class ChildStateChange:
class ChildStateChange(object):
def Apply(self):
raise NotImplementedError
@@ -301,7 +301,7 @@ def ExecExternalProgram(argv, environ):
# no return
class ExternalThunk:
class ExternalThunk(object):
"""An external executable."""
def __init__(self, argv, environ):
@@ -315,7 +315,7 @@ def Run(self):
ExecExternalProgram(self.argv, self.environ)
class SubProgramThunk:
class SubProgramThunk(object):
"""A subprogram that can be executed in another process."""
def __init__(self, ex, node, disable_errexit=False):
View
@@ -21,7 +21,7 @@
_OTHER_LOOKUP = meta.TEST_OTHER_LOOKUP
class _StringWordEmitter:
class _StringWordEmitter(object):
"""For test/[, we need a word parser that returns StringWord.
The BoolParser calls word.BoolId(w), and deals with Kind.BoolUnary,
@@ -50,7 +50,7 @@ def ReadWord(self, unused_lex_mode):
return ast.StringWord(id_, s)
class _WordEvaluator:
class _WordEvaluator(object):
def EvalWordToString(self, w, do_fnmatch=False):
# do_fnmatch: for the [[ == ]] semantics which we don't have!
View
@@ -183,7 +183,7 @@ def Pop(self):
self.indent = self.indent[:-self.num_spaces]
class _FileResourceLoader:
class _FileResourceLoader(object):
"""Open resources relative to argv[0]."""
def __init__(self, argv0):
@@ -197,7 +197,7 @@ def open(self, rel_path):
import zipimport # NOT the zipfile module.
class _ZipResourceLoader:
class _ZipResourceLoader(object):
"""Open resources INSIDE argv[0] as a zip file."""
def __init__(self, argv0):
View
@@ -124,7 +124,7 @@ def _DecayPartValuesToString(part_vals, join_char):
return ''.join(out)
class _WordEvaluator:
class _WordEvaluator(object):
"""Abstract base class for word evaluators.
Public entry points:
View
@@ -84,7 +84,12 @@ def Disassemble(co):
#log('\t==> i = %d, n = %d', i, n)
import sre_compile
def _GetAttr(module, name):
# Hack for bug in _fixup_range() ! (No longer in Python 3.6 head.)
if module is sre_compile and name == 'l':
return None
try:
val = getattr(module, name)
except AttributeError:
View
@@ -200,4 +200,12 @@ top-level() {
| egrep -v ':import|from|class|def' # note: colon is from grep output
}
py-symbols() {
CALLGRAPH=1 bin/oil.py | sort
}
old-style-classes() {
py-symbols | grep -v '<'
}
"$@"
View
@@ -27,7 +27,7 @@
lhs_expr_e = ast.lhs_expr_e
class Cursor:
class Cursor(object):
"""
Wrapper for printing/transforming a complete source file stored in a single
arena.
@@ -203,7 +203,7 @@ def _GetRhsStyle(w):
PEDANTIC = 1
class OilPrinter:
class OilPrinter(object):
"""
Convert osh code to oil.

0 comments on commit eac70cd

Please sign in to comment.