Commit 2a66d281 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Sweet, we have some basic regex support

parent 4cf93f94
......@@ -765,12 +765,16 @@ endif
.PHONY: perf$1_%
perf$1_%: %.py pyston$1
perf record -g -- ./pyston$1 -q -p $$(ARGS) $$<
perf report -v -n -g flat,1000 | bash $$(TOOLS_DIR)/cumulate.sh | less -S
@$(MAKE) perf_report
$$(call make_search,perf$1_%)
)
endef
.PHONY: perf_report
perf_report:
perf report -v -n -g flat,1000 | bash $(TOOLS_DIR)/cumulate.sh | less -S
.PHONY: run run_% dbg_% debug_% perf_%
run: run_dbg
run_%: run_dbg_%
......
......@@ -237,6 +237,11 @@ Box* tupleNe(BoxedTuple* self, Box* rhs) {
return _tupleCmp(self, static_cast<BoxedTuple*>(rhs), AST_TYPE::NotEq);
}
Box* tupleNonzero(BoxedTuple* self) {
RELEASE_ASSERT(self->cls == tuple_cls, "");
return boxBool(self->elts.size() != 0);
}
Box* tupleContains(BoxedTuple* self, Box* elt) {
int size = self->elts.size();
for (int i = 0; i < size; i++) {
......@@ -373,6 +378,8 @@ void setupTuple() {
tuple_cls->giveAttr("__eq__", new BoxedFunction(boxRTFunction((void*)tupleEq, UNKNOWN, 2)));
tuple_cls->giveAttr("__ne__", new BoxedFunction(boxRTFunction((void*)tupleNe, UNKNOWN, 2)));
tuple_cls->giveAttr("__nonzero__", new BoxedFunction(boxRTFunction((void*)tupleNonzero, BOXED_BOOL, 1)));
tuple_cls->giveAttr("__hash__", new BoxedFunction(boxRTFunction((void*)tupleHash, BOXED_INT, 1)));
tuple_cls->giveAttr("__len__", new BoxedFunction(boxRTFunction((void*)tupleLen, BOXED_INT, 1)));
tuple_cls->giveAttr("__repr__", new BoxedFunction(boxRTFunction((void*)tupleRepr, STR, 1)));
......
# skip-if: True
# This test works but 1) is very slow [the importing is, not the regex itself], and 2) throws warnings
import sre_compile
r = sre_compile.compile("a(b+)c", 0)
print r.match("")
print r.match("ac")
print r.match("abc").groups()
print r.match("abbc").groups()
......@@ -168,3 +168,8 @@ try:
t[3]
except IndexError as e:
print e
print bool(())
print bool((1,))
print bool((0,))
print bool((0, 0))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment