Skip to content

Commit

Permalink
[mycpp] Remove --shared-ptr flag
Browse files Browse the repository at this point in the history
Need to reconcile mylib.cc and my_runtime.cc.
  • Loading branch information
Andy Chu committed Nov 12, 2020
1 parent 76c9bce commit c89fbf4
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
3 changes: 0 additions & 3 deletions mycpp/cppgen_pass.py
Expand Up @@ -22,9 +22,6 @@
from util import log


SHARED_PTR = False # global variable set by main()


T = None

class UnsupportedException(Exception):
Expand Down
10 changes: 2 additions & 8 deletions mycpp/harness.sh
Expand Up @@ -56,18 +56,11 @@ _translate-example() {
local raw=_gen/${name}_raw${variant}.cc
local out=_gen/${name}${variant}.cc

flags=''
case $variant in
(.shared_ptr)
flags='--shared-ptr'
;;
esac

# NOTE: mycpp has to be run in the virtualenv, as well as with a different
# PYTHONPATH.
( source _tmp/mycpp-venv/bin/activate
# flags may be empty
time PYTHONPATH=$MYPY_REPO ./mycpp_main.py $flags $main > $raw
time PYTHONPATH=$MYPY_REPO ./mycpp_main.py $main > $raw
)
wc -l $raw

Expand Down Expand Up @@ -108,6 +101,7 @@ _compile-example() {
local -a runtime
if test -n "${GC:-}"; then
runtime=(my_runtime.cc gc_heap.cc)
# TODO: Reconcile my_runtime.cc and mylib.cc
else
runtime=(mylib.cc gc_heap.cc)
fi
Expand Down
9 changes: 1 addition & 8 deletions mycpp/mycpp_main.py
Expand Up @@ -32,10 +32,6 @@ def Options():
'-v', '--verbose', dest='verbose', action='store_true', default=False,
help='Show details about translation')

p.add_option(
'--shared-ptr', dest='shared_ptr', action='store_true', default=False,
help='Emit code using std::shared_ptr instead of raw pointers')

p.add_option(
'--to-header', dest='to_header', action='append', default=[],
help='Export this module to a header, e.g. frontend.args')
Expand Down Expand Up @@ -126,10 +122,6 @@ def main(argv):

o = Options()
opts, argv = o.parse_args(argv)

if opts.shared_ptr:
log('*** Compiling with std::shared_ptr<> ***')
cppgen_pass.SHARED_PTR = True # global var hack for now

paths = argv[1:] # e.g. asdl/typed_arith_parse.py

Expand Down Expand Up @@ -236,6 +228,7 @@ def main(argv):

gc = bool(os.getenv('GC'))
header_name = 'gc_heap' if gc else 'mylib'
#header_name = 'mylib'

# TODO: Add --cc-out? But there is a preamble and postamble.
f.write("""\
Expand Down
7 changes: 7 additions & 0 deletions mycpp/run.sh
Expand Up @@ -217,6 +217,13 @@ gen-ctags() {
}

gc-examples() {
# print()
GC=1 example-both switch_
return

# slice(), maybe_str_equals()
GC=1 example-both length

if true; then
# these work
GC=1 example-both fib_iter
Expand Down

0 comments on commit c89fbf4

Please sign in to comment.