diff options
| author | krasimir <krasimir@chalmers.se> | 2017-01-26 18:41:07 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2017-01-26 18:41:07 +0000 |
| commit | 0e49c28e5bfcf438818aca731071fdf707a3e2ce (patch) | |
| tree | c2f72e46097685dbf703f7f2dcb946c8db18f729 /src/runtime/haskell-bind/PGF2.hsc | |
| parent | 1cea621216ca515bc14326d9ce5dde12e56334ce (diff) | |
API for computing the Haskell binding
Diffstat (limited to 'src/runtime/haskell-bind/PGF2.hsc')
| -rw-r--r-- | src/runtime/haskell-bind/PGF2.hsc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc index e87bc901b..0c976db37 100644 --- a/src/runtime/haskell-bind/PGF2.hsc +++ b/src/runtime/haskell-bind/PGF2.hsc @@ -45,6 +45,9 @@ module PGF2 (-- * PGF -- ** Type checking checkExpr, inferExpr, checkType, + -- ** Computing + compute, + -- * Concrete syntax ConcName,Concr,languages, -- ** Linearization @@ -279,6 +282,22 @@ checkType (PGF p _) (Type c_ty _) = then return (Left msg) else throwIO (PGFError msg) +compute :: PGF -> Expr -> Expr +compute (PGF p _) (Expr c_expr _) = + unsafePerformIO $ + withGuPool $ \tmpPl -> do + exn <- gu_new_exn tmpPl + exprPl <- gu_new_pool + c_expr <- pgf_compute p c_expr exn tmpPl exprPl + status <- gu_exn_is_raised exn + if not status + then do exprFPl <- newForeignPtr gu_pool_finalizer exprPl + return (Expr c_expr exprFPl) + else do c_msg <- (#peek GuExn, data.data) exn + msg <- peekUtf8CString c_msg + gu_pool_free exprPl + throwIO (PGFError msg) + ----------------------------------------------------------------------------- -- Graphviz |
