implemented computing with abstract syntax trees. It passes all test cases except those that require def rules. The design is consistent with the STG virtual machine

This commit is contained in:
kr.angelov
2014-07-08 19:45:49 +00:00
parent b3397f8071
commit 0138869499
4 changed files with 473 additions and 3 deletions

View File

@@ -2301,8 +2301,30 @@ PGF_compute(PGFObject* self, PyObject *args)
if (!PyArg_ParseTuple(args, "O!", &pgf_ExprType, &py_expr))
return NULL;
Py_INCREF(py_expr);
return py_expr;
ExprObject* py_expr_res = (ExprObject*) pgf_ExprType.tp_alloc(&pgf_ExprType, 0);
if (py_expr_res == NULL)
return NULL;
GuPool* tmp_pool = gu_new_pool();
GuExn* err = gu_new_exn(NULL, gu_kind(type), tmp_pool);
py_expr_res->pool = gu_new_pool();
py_expr_res->expr = pgf_compute(self->pgf, py_expr->expr, err,
tmp_pool, py_expr_res->pool);
py_expr_res->master = (PyObject*) self;
Py_INCREF(py_expr_res->master);
if (!gu_ok(err)) {
GuString msg = (GuString) gu_exn_caught_data(err);
PyErr_SetString(PGFError, msg);
Py_DECREF(py_expr_res);
gu_pool_free(tmp_pool);
return NULL;
}
gu_pool_free(tmp_pool);
return py_expr_res;
}
static ExprObject*