Skip to content

Commit

Permalink
[test/spec] Fix typo in oil test binary.
Browse files Browse the repository at this point in the history
More work on mycpp.

- PartialType -> void*.  I think PartialType is Any?
  • Loading branch information
Andy Chu committed Oct 7, 2019
1 parent e61af0d commit e2abe03
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 12 deletions.
9 changes: 7 additions & 2 deletions asdl/gen_cpp.py
@@ -1,7 +1,12 @@
"""
gen_cpp.py
gen_cpp.py - Generate C++ classes from an ASDL schema.
TODO:
- Integrate some of the lessons here:
- https://github.com/oilshell/blog-code/tree/master/asdl
- And maybe mycpp/target_lang.cc
- pretty printing methods
- so asdl/format.py get translated?
Expand Down Expand Up @@ -38,7 +43,7 @@ def VisitSimpleSum(self, sum, name, depth):


_BUILTINS = {
'string': 'Str*', # declared in runtime.h
'string': 'Str*', # declared in mylib.h
'int': 'int',
'bool': 'bool',
#'id': 'Id', # Application specific hack for now
Expand Down
2 changes: 1 addition & 1 deletion core/asdl_gen.py
Expand Up @@ -48,7 +48,7 @@ def main(argv):
f.write("""\
#include <cstdint>
#include "runtime.h" // for Str, List, etc.
#include "mylib.h" // for Str, List, etc.
namespace %s {
Expand Down
6 changes: 5 additions & 1 deletion mycpp/cppgen_pass.py
Expand Up @@ -8,7 +8,7 @@
from mypy.visitor import ExpressionVisitor, StatementVisitor
from mypy.types import (
Type, AnyType, NoneTyp, TupleType, Instance, Overloaded, CallableType,
UnionType, UninhabitedType)
UnionType, UninhabitedType, PartialType)
from mypy.nodes import (
Expression, Statement, NameExpr, IndexExpr, MemberExpr, TupleExpr,
ExpressionStmt, AssignmentStmt, StrExpr, SliceExpr, FuncDef,
Expand Down Expand Up @@ -78,6 +78,10 @@ def get_c_type(t):
parts = t.type.fullname().split('.')
c_type = '%s::%s%s' % (parts[-2], parts[-1], is_pointer)

elif isinstance(t, PartialType):
# For Any?
c_type = 'void*'

elif isinstance(t, UninhabitedType):
# UninhabitedType has a NoReturn flag
c_type = 'void'
Expand Down
2 changes: 2 additions & 0 deletions mycpp/examples/asdl_generated.py
Expand Up @@ -13,6 +13,8 @@

from typing import Optional, List

from asdl import format as fmt


class arith_expr_t(object):
pass
Expand Down
15 changes: 14 additions & 1 deletion mycpp/run.sh
Expand Up @@ -83,7 +83,13 @@ translate-osh-parse() {
time ./mycpp.py $main
}

# Has some hard-coded stuff
# for examples/{parse,asdl_generated}
# TODO: Get rid of this? Every example should be translated the same.
#
# What does it do?
# - passes multiple files in order to mycpp.py
# - adds the "snippet" prefix

translate-ordered() {
local name=$1
local snippet=$2
Expand Down Expand Up @@ -206,6 +212,13 @@ translate-parse() {
$REPO_ROOT/asdl/format.py examples/parse.py
}

# TODO: Get rid of translate-ordered
translate-asdl-generated() {
translate-ordered asdl_generated '#include "expr.asdl.h"' \
$REPO_ROOT/asdl/runtime.py $REPO_ROOT/asdl/format.py \
examples/asdl_generated.py
}

# build ASDL schema and run it
run-python-parse() {
mkdir -p _gen
Expand Down
7 changes: 1 addition & 6 deletions spec/oil-expr.test.sh
Expand Up @@ -391,19 +391,14 @@ great

#### Tuples
var zero = ()

# TODO: I don't like this trailing comma syntax?
var one = 1,
var one2 = (1,)
var one = tup(42)
var two = (1,2)
echo $len(zero)
echo $len(one)
echo $len(one2)
echo $len(two)
## STDOUT:
0
1
1
2
## END

Expand Down
2 changes: 1 addition & 1 deletion test/spec.sh
Expand Up @@ -55,7 +55,7 @@ if test -z "$OSH_LIST"; then
fi

readonly OIL_CPYTHON="$REPO_ROOT/bin/oil"
readonly OIL_OVM=${OSH_OVM:-$REPO_ROOT/_bin/oil}
readonly OIL_OVM=${OIL_OVM:-$REPO_ROOT/_bin/oil}

OIL_LIST=${OIL_LIST:-} # A space-separated list.

Expand Down

0 comments on commit e2abe03

Please sign in to comment.