Skip to content

Commit

Permalink
[mycpp] Don't create new vars in case blocks, unless var is UP_*
Browse files Browse the repository at this point in the history
We are making the "UP_val downcasting pattern" real in mycpp.

This fixes a failing test case in

    test/spec-cpp.sh run-file ysh-methods

Related to casting "out" of a switch.

Document many more things in mycpp/README.md.  Publish it in
doc/oils-repo/mycpp/README.html.

Also move our README.md from doc/README.html to
doc/oils-repo/README.html.
  • Loading branch information
Andy C committed Mar 12, 2024
1 parent 1225881 commit bde2d3f
Show file tree
Hide file tree
Showing 9 changed files with 303 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,6 @@ There are README files in many subdirectories, like
* [oilshell.zulipchat.com][] is for any kind of discussion
* Subscribe for updates:
* [/r/oilshell on Reddit](https://www.reddit.com/r/oilshell/)
* [@oilshellblog on Twitter](https://twitter.com/oilshellblog)
* [@oilsforunix on Twitter](https://twitter.com/oilsforunix)


26 changes: 20 additions & 6 deletions build/doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ REPO_ROOT=$(cd $THIS_DIR/.. && pwd)
readonly REPO_ROOT


readonly HTML_BASE_DIR=_release/VERSION


log() {
echo "$@" 1>&2
}
Expand Down Expand Up @@ -167,7 +170,7 @@ split-and-render() {
local rel_path=${src%'.md'} # doc/known-differences
local tmp_prefix=_tmp/$rel_path # temp dir for splitting

local out=${2:-_release/VERSION/$rel_path.html}
local out=${2:-$HTML_BASE_DIR/$rel_path.html}
local web_url=${3:-'../web'}

mkdir -v -p $(dirname $out) $tmp_prefix
Expand Down Expand Up @@ -227,8 +230,6 @@ render-from-kate() {
# Do NOT split because we don't want front matter in the markdown source.
render-only() {
local src=${1:-README.md}
local css_files=${2:-'../web/manual.css ../web/toc.css'}
local title=${3:-'Oils Source Code'}

local name
case $src in
Expand All @@ -243,8 +244,11 @@ render-only() {
;;
esac

local out=${2:-$HTML_BASE_DIR/doc/$name.html}
local css_files=${3:-'../web/manual.css ../web/toc.css'}
local title=${4:-'Oils Source Code'}

local prefix=_tmp/doc/$name
local out=_release/VERSION/doc/$name.html

local meta=${prefix}_meta.json
cat >$meta <<EOF
Expand All @@ -263,8 +267,18 @@ EOF
}

special() {
render-only 'README.md' '../web/base.css ../web/manual.css ../web/toc.css' 'Oils Source Code'
render-only 'INSTALL.txt' '../web/base.css ../web/install.css' 'Installing Oils'
# TODO: do all READMEs
split-and-render mycpp/README.md \
$HTML_BASE_DIR/doc/oils-repo/mycpp/README.html \
../../../web

local web_dir='../../web'
render-only 'README.md' $HTML_BASE_DIR/doc/oils-repo/README.html \
"$web_dir/base.css $web_dir/manual.css $web_dir/toc.css" 'Oils Source Code'

local web_dir='../web'
render-only 'INSTALL.txt' '' \
"$web_dir/base.css $web_dir/install.css" 'Installing Oils'

# These pages aren't in doc/
split-and-render doc/release-index.md _tmp/release-index.html
Expand Down
7 changes: 2 additions & 5 deletions core/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,29 +744,26 @@ def _DumpVarFrame(frame):

# TODO:
# - Use packle for crash dumps! Then we can represent object cycles
# - Right now the JSON serializer will probably crash
# - although BashArray and BashAssoc may need 'type' tags
# - they don't round trip correctly
# - maybe add value.Tombstone here or something?
# - value.{Func,Eggex,...} may have value.Tombstone and
# vm.ValueIdString()?

val = None # type: value_t
with tagswitch(cell.val) as case:
if case(value_e.Undef):
cell_json['type'] = value.Str('Undef')

elif case(value_e.Str):
val = cast(value.Str, cell.val)
cell_json['type'] = value.Str('Str')
cell_json['value'] = value.Str(val.s)
cell_json['value'] = cell.val

elif case(value_e.BashArray):
val = cast(value.BashArray, cell.val)
cell_json['type'] = value.Str('BashArray')
cell_json['value'] = cell.val

elif case(value_e.BashAssoc):
val = cast(value.BashAssoc, cell.val)
cell_json['type'] = value.Str('BashAssoc')
cell_json['value'] = cell.val

Expand Down
2 changes: 1 addition & 1 deletion doc/architecture-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ These internal details are subject to change.
## Links

- [Contributing][] (wiki) helps you change the code for the first time.
- [README](README.html) describes how the code is organized.
- [README](oils-repo/README.html) describes how the code is organized.
- [Interpreter State](interpreter-state.html) describes the interpreter's user-facing data
structures.
- [Parser Architecture](parser-architecture.html)
Expand Down
6 changes: 4 additions & 2 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ Internal details:

## For Contributors

- [README.md](README.html). If you want to modify Oils, start here. We
welcome contributions!
- [README.md](oils-repo/README.html). If you want to modify Oils, start here.
We welcome contributions!
- [Doc Toolchain](doc-toolchain.html) and [Doc Plugins](doc-plugins.html).
- [Github Wiki for oilshell/oil](https://github.com/oilshell/oil/wiki)
- [Old Docs](old/index.html). Drafts that may be deleted.
Expand All @@ -144,6 +144,8 @@ Internal Architecture:
- [Notes on Oils Architecture](architecture-notes.html)
- [Parser Architecture](parser-architecture.html)
- [Pretty Printing](pretty-printing.html) - March 2024 design notes.
- [mycpp/README](oils-repo/mycpp/README.html) - How we translate typed Python to
C++.

## More

Expand Down
3 changes: 2 additions & 1 deletion doc/pretty-printing.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ tree with "NIL8":
**"lossless invariant"**, which is affected by *re-parsing*.
- I recently updated it, and tested the invariant with
[test/lossless.sh]($oils-src).
- The repo [README]($oils-doc:README.html) has an overview of the code.
- The repo [README]($oils-doc:oils-repo/README.html) has an overview of the
code.

### Fun Computer Science Problems in Oils

Expand Down
Loading

0 comments on commit bde2d3f

Please sign in to comment.