Skip to content

Commit

Permalink
[refactor] Rename cpp/* -> cpp/*_leaky
Browse files Browse the repository at this point in the history
To prepare for making everything garbage-collected!
  • Loading branch information
Andy C committed Jul 7, 2022
1 parent 78e4620 commit 3a62723
Show file tree
Hide file tree
Showing 50 changed files with 139 additions and 110 deletions.
4 changes: 2 additions & 2 deletions build/translate.sh
Expand Up @@ -41,7 +41,7 @@ cpp-skeleton() {
cat <<EOF
// $name.cc: translated from Python by mycpp
#include "cpp/preamble.h" // hard-coded stuff
#include "cpp/preamble_leaky.h" // hard-coded stuff
#undef errno // for e->errno to work; see mycpp/myerror.h
Expand All @@ -54,7 +54,7 @@ int main(int argc, char **argv) {
complain_loudly_on_segfault();
gc_heap::gHeap.Init(400 << 20); // 400 MiB matches dumb_alloc.cc
gc_heap::gHeap.Init(400 << 20); // 400 MiB matches dumb_alloc_leaky.cc
// NOTE(Jesse): Turn off buffered IO
setvbuf(stdout, 0, _IONBF, 0);
Expand Down
34 changes: 17 additions & 17 deletions cpp/NINJA_subgraph.py
Expand Up @@ -37,7 +37,7 @@
preprocessed/
cxx-dbg/
posix.cc
posix_leaky.cc
cxx-dbg.txt # line counts
Expand Down Expand Up @@ -79,21 +79,21 @@ def log(msg, *args):


DEPS_CC = [
'cpp/core_pyos.cc',
'cpp/core_pyutil.cc',
'cpp/frontend_flag_spec.cc',
'cpp/frontend_match.cc',
'cpp/frontend_tdop.cc',
'cpp/osh_arith_parse.cc',
'cpp/osh_bool_stat.cc',
'cpp/pgen2_parse.cc',
'cpp/pylib_path_stat.cc',
'cpp/pylib_os_path.cc',
'cpp/dumb_alloc.cc',
'cpp/fcntl_.cc',
'cpp/posix.cc',
'cpp/signal_.cc',
'cpp/libc.cc',
'cpp/core_pyos_leaky.cc',
'cpp/core_pyutil_leaky.cc',
'cpp/frontend_flag_spec_leaky.cc',
'cpp/frontend_match_leaky.cc',
'cpp/frontend_tdop_leaky.cc',
'cpp/osh_arith_parse_leaky.cc',
'cpp/osh_bool_stat_leaky.cc',
'cpp/pgen2_parse_leaky.cc',
'cpp/pylib_path_stat_leaky.cc',
'cpp/pylib_os_path_leaky.cc',
'cpp/dumb_alloc_leaky.cc',
'cpp/fcntl__leaky.cc',
'cpp/posix_leaky.cc',
'cpp/signal__leaky.cc',
'cpp/libc_leaky.cc',

# generated
# TODO: We're missing dependencies for these
Expand Down Expand Up @@ -124,7 +124,7 @@ def log(msg, *args):

# -D DUMB_ALLOC: not sure why but only the _bin/cxx-opt/osh_eval binary needs it?
# -D NO_GC_HACK: Avoid memset(). TODO: remove this hack!
# -D OSH_EVAL: hack for osh_eval_stubs.h
# -D OSH_EVAL: hack for osh_eval_stubs_leaky.h
# -D LEAKY_BINDINGS: for QSN, which is used by the ASDL runtime

# single quoted in Ninja/shell syntax
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cpp/core_pyerror.h → cpp/core_pyerror_leaky.h
@@ -1,4 +1,4 @@
// core_pyerror.h
// core_pyerror_leaky.h

#ifndef CORE_PYERROR_H
#define CORE_PYERROR_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/core_pyos.cc → cpp/core_pyos_leaky.cc
@@ -1,6 +1,6 @@
// core_pyos.cc

#include "core_pyos.h" // undefined errno
#include "core_pyos_leaky.h" // undefined errno

#include <pwd.h>
#include <signal.h>
Expand Down
4 changes: 2 additions & 2 deletions cpp/core_pyos.h → cpp/core_pyos_leaky.h
@@ -1,4 +1,4 @@
// core_pyos.h: Replacement for core/pyos.py
// core_pyos_leaky.h: Replacement for core/pyos.py

#ifndef CORE_PYOS_H
#define CORE_PYOS_H
Expand All @@ -17,7 +17,7 @@

#include "_build/cpp/syntax_asdl.h"
#include "mycpp/mylib_leaky.h"
#include "time_.h"
#include "time__leaky.h"
// has a member named errno. That member can't be changed
// because it has to match the python error structure, which
// has an errno member.
Expand Down
2 changes: 1 addition & 1 deletion cpp/core_pyutil.cc → cpp/core_pyutil_leaky.cc
Expand Up @@ -4,7 +4,7 @@
#include "mycpp/myerror.h" // for _OSError; must come first
// clang-format on

#include "core_pyutil.h"
#include "core_pyutil_leaky.h"

namespace pyutil {

Expand Down
2 changes: 1 addition & 1 deletion cpp/core_pyutil.h → cpp/core_pyutil_leaky.h
@@ -1,4 +1,4 @@
// core_pyutil.h
// core_pyutil_leaky.h

#ifndef CORE_PYUTIL_H
#define CORE_PYUTIL_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/dumb_alloc.cc → cpp/dumb_alloc_leaky.cc
@@ -1,6 +1,6 @@
// dumb_alloc.cc: Test this C++ mechanism as a lower bound on performance.

#include "dumb_alloc.h"
#include "dumb_alloc_leaky.h"

#include <stdio.h>

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cpp/fcntl_.cc → cpp/fcntl__leaky.cc
Expand Up @@ -4,7 +4,7 @@
#include "mycpp/myerror.h" // for IOError
// clang-format on

#include "fcntl_.h"
#include "fcntl__leaky.h"

#include <errno.h>
#include <fcntl.h> // the system header
Expand Down
File renamed without changes.
@@ -1,6 +1,6 @@
// frontend_flag_spec.cc

#include "frontend_flag_spec.h"
#include "frontend_flag_spec_leaky.h"

#include "_build/cpp/arg_types.h"

Expand Down
@@ -1,4 +1,4 @@
// frontend_flag_spec.h
// frontend_flag_spec_leaky.h

#ifndef FRONTEND_FLAG_SPEC_H
#define FRONTEND_FLAG_SPEC_H
Expand Down
4 changes: 2 additions & 2 deletions cpp/frontend_match.cc → cpp/frontend_match_leaky.cc
@@ -1,6 +1,6 @@
// frontend_match.cc: manual port of frontend/match

#include "frontend_match.h"
#include "frontend_match_leaky.h"

// This order is required to get it to compile, despite clang-format
// clang-format off
Expand All @@ -10,7 +10,7 @@
// clang-format on

#ifdef DUMB_ALLOC
#include "dumb_alloc.h"
#include "dumb_alloc_leaky.h"
#define malloc dumb_malloc
#define free dumb_free
#endif
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cpp/frontend_tdop.cc → cpp/frontend_tdop_leaky.cc
@@ -1,4 +1,4 @@
#include "osh_arith_parse.h"
#include "osh_arith_parse_leaky.h"

// This code structure is odd because frontend/tdop.py would allow multiple
// TDOP parser. Since we only have one, we just hard-code it in C++.
Expand Down
File renamed without changes.
22 changes: 11 additions & 11 deletions cpp/leaky_binding_test.cc
Expand Up @@ -7,16 +7,16 @@

#include "_build/cpp/runtime_asdl.h" // cell, etc
#include "_devbuild/gen/id.h"
#include "core_error.h"
#include "core_pyerror.h"
#include "core_pyos.h" // Chdir
#include "core_pyutil.h"
#include "frontend_match.h"
#include "libc.h"
#include "osh_bool_stat.h"
#include "posix.h"
#include "pylib_os_path.h"
#include "time_.h"
#include "core_error_leaky.h"
#include "core_pyerror_leaky.h"
#include "core_pyos_leaky.h" // Chdir
#include "core_pyutil_leaky.h"
#include "frontend_match_leaky.h"
#include "libc_leaky.h"
#include "osh_bool_stat_leaky.h"
#include "posix_leaky.h"
#include "pylib_os_path_leaky.h"
#include "time__leaky.h"
#include "vendor/greatest.h"

namespace Id = id_kind_asdl::Id;
Expand Down Expand Up @@ -199,7 +199,7 @@ TEST posix_test() {
PASS();
}

// HACK! asdl/runtime.py isn't translated, but core_error.h uses it...
// HACK! asdl/runtime.py isn't translated, but core_error_leaky.h uses it...
namespace runtime {
int NO_SPID = -1;
};
Expand Down
2 changes: 1 addition & 1 deletion cpp/leaky_flag_spec_test.cc
@@ -1,4 +1,4 @@
#include "cpp/frontend_flag_spec.h"
#include "cpp/frontend_flag_spec_leaky.h"
#include "vendor/greatest.h"

using runtime_asdl::flag_type_e;
Expand Down
2 changes: 1 addition & 1 deletion cpp/libc.cc → cpp/libc_leaky.cc
@@ -1,6 +1,6 @@
// libc.cc: Replacement for native/libcmodule.c

#include "libc.h"
#include "libc_leaky.h"

#include <glob.h>
#include <locale.h>
Expand Down
2 changes: 1 addition & 1 deletion cpp/libc.h → cpp/libc_leaky.h
@@ -1,4 +1,4 @@
// libc.h: Replacement for native/libc.c
// libc_leaky.h: Replacement for native/libc.c

#ifndef LIBC_H
#define LIBC_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/osh_arith_parse.cc → cpp/osh_arith_parse_leaky.cc
@@ -1,6 +1,6 @@
// osh_arith_parse.cc: Manual rewrites of some parts of osh/arith_parse

#include "osh_arith_parse.h"
#include "osh_arith_parse_leaky.h"

namespace arith_parse {

Expand Down
2 changes: 1 addition & 1 deletion cpp/osh_arith_parse.h → cpp/osh_arith_parse_leaky.h
Expand Up @@ -3,7 +3,7 @@
#ifndef OSH_ARITH_PARSE_H
#define OSH_ARITH_PARSE_H

#include "frontend_tdop.h"
#include "frontend_tdop_leaky.h"

namespace arith_parse {

Expand Down
6 changes: 3 additions & 3 deletions cpp/osh_bool_stat.cc → cpp/osh_bool_stat_leaky.cc
@@ -1,13 +1,13 @@
// osh_bool_stat.cc

#include "osh_bool_stat.h"
#include "osh_bool_stat_leaky.h"

#include <fcntl.h> // AT_* Constants
#include <sys/stat.h>
#include <unistd.h>

#include "core_error.h"
#include "core_pyerror.h"
#include "core_error_leaky.h"
#include "core_pyerror_leaky.h"

namespace bool_stat {

Expand Down
2 changes: 1 addition & 1 deletion cpp/osh_bool_stat.h → cpp/osh_bool_stat_leaky.h
@@ -1,4 +1,4 @@
// osh_bool_stat.h
// osh_bool_stat_leaky.h

#ifndef OSH_BOOL_STAT_H
#define OSH_BOOL_STAT_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/osh_eval_stubs.h → cpp/osh_eval_stubs_leaky.h
@@ -1,4 +1,4 @@
// osh_eval_stubs.h
// osh_eval_stubs_leaky.h

#ifndef OSH_EVAL_STUBS_H
#define OSH_EVAL_STUBS_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/osh_sh_expr_eval.h → cpp/osh_sh_expr_eval_leaky.h
@@ -1,4 +1,4 @@
// osh_sh_expr_eval.h
// osh_sh_expr_eval_leaky.h

#ifndef OSH_SH_EXPR_EVAL_H
#define OSH_SH_EXPR_EVAL_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/pgen2_parse.cc → cpp/pgen2_parse_leaky.cc
@@ -1,6 +1,6 @@
// pgen2_parse.cc

#include "pgen2_parse.h"
#include "pgen2_parse_leaky.h"

namespace parse {

Expand Down
2 changes: 1 addition & 1 deletion cpp/pgen2_parse.h → cpp/pgen2_parse_leaky.h
@@ -1,4 +1,4 @@
// pgen2_parse.h
// pgen2_parse_leaky.h

#ifndef PGEN2_PARSE_H
#define PGEN2_PARSE_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/posix.cc → cpp/posix_leaky.cc
Expand Up @@ -4,7 +4,7 @@
#include "mycpp/myerror.h" // for OSError; must come first
// clang-format on

#include "posix.h"
#include "posix_leaky.h"

#include <errno.h>
#include <fcntl.h> // open
Expand Down
2 changes: 1 addition & 1 deletion cpp/posix.h → cpp/posix_leaky.h
@@ -1,4 +1,4 @@
// posix.h: Replacement for native/posixmodule.c
// posix_leaky.h: Replacement for native/posixmodule.c

#ifndef POSIX_H
#define POSIX_H
Expand Down
42 changes: 21 additions & 21 deletions cpp/preamble.h → cpp/preamble_leaky.h
@@ -1,4 +1,4 @@
// preamble.h: declarations to run osh_eval.cc
// preamble_leaky.h: declarations to run osh_eval.cc

// clang-format off
#include "mycpp/myerror.h" // do this before 'errno' macro is defined
Expand All @@ -7,7 +7,7 @@
#include <errno.h>
#include <sys/wait.h> // WIFSIGNALED, etc. called DIRECTLY

#include "dumb_alloc.h" // change the allocator
#include "dumb_alloc_leaky.h" // change the allocator
// TODO: Need #if GC
#include "_build/cpp/id_kind_asdl.h" // syntax.asdl depends on this
#include "mycpp/mylib_leaky.h" // runtime library e.g. with Python data structures
Expand All @@ -25,30 +25,30 @@ using id_kind_asdl::Kind_t;
#include "_devbuild/gen/grammar_nt.h"

// oil/cpp
#include "core_error.h"
#include "core_error_leaky.h"
//#include "core_process.h"
#include "core_pyerror.h"
#include "core_pyos.h"
#include "core_pyutil.h"
#include "fcntl_.h"
#include "frontend_flag_spec.h"
#include "frontend_match.h"
#include "frontend_tdop.h"
#include "libc.h"
#include "osh_arith_parse.h"
#include "osh_bool_stat.h"
#include "osh_sh_expr_eval.h"
#include "pgen2_parse.h"
#include "posix.h"
#include "pylib_os_path.h"
#include "pylib_path_stat.h"
#include "core_pyerror_leaky.h"
#include "core_pyos_leaky.h"
#include "core_pyutil_leaky.h"
#include "fcntl__leaky.h"
#include "frontend_flag_spec_leaky.h"
#include "frontend_match_leaky.h"
#include "frontend_tdop_leaky.h"
#include "libc_leaky.h"
#include "osh_arith_parse_leaky.h"
#include "osh_bool_stat_leaky.h"
#include "osh_sh_expr_eval_leaky.h"
#include "pgen2_parse_leaky.h"
#include "posix_leaky.h"
#include "pylib_os_path_leaky.h"
#include "pylib_path_stat_leaky.h"
#include "qsn_qsn.h"
#include "segfault_handler.h"
#include "signal_.h"
#include "time_.h"
#include "signal__leaky.h"
#include "time__leaky.h"

#ifdef OSH_EVAL
#include "osh_eval_stubs.h"
#include "osh_eval_stubs_leaky.h"
#endif

inline bool are_equal(id_kind_asdl::Kind left, id_kind_asdl::Kind right) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/pylib_os_path.cc → cpp/pylib_os_path_leaky.cc
@@ -1,6 +1,6 @@
// pylib_os_path.cc

#include "pylib_os_path.h"
#include "pylib_os_path_leaky.h"

namespace os_path {

Expand Down
2 changes: 1 addition & 1 deletion cpp/pylib_os_path.h → cpp/pylib_os_path_leaky.h
@@ -1,4 +1,4 @@
// pylib_os_path.h
// pylib_os_path_leaky.h

#ifndef PYLIB_OS_PATH_H
#define PYLIB_OS_PATH_H
Expand Down
2 changes: 1 addition & 1 deletion cpp/pylib_path_stat.cc → cpp/pylib_path_stat_leaky.cc
@@ -1,6 +1,6 @@
// pylib_path_stat.cc

#include "pylib_path_stat.h"
#include "pylib_path_stat_leaky.h"

#include <sys/stat.h>

Expand Down

0 comments on commit 3a62723

Please sign in to comment.