From 23edeec5a95bb7378d8f075e5bee5e67235adadd Mon Sep 17 00:00:00 2001 From: krangelov Date: Fri, 14 Aug 2020 20:54:15 +0200 Subject: added an API for cloning expressions/types/literals --- src/runtime/haskell-bind/PGF2.hsc | 12 ++---------- src/runtime/haskell-bind/PGF2/FFI.hsc | 3 +++ 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src/runtime/haskell-bind') diff --git a/src/runtime/haskell-bind/PGF2.hsc b/src/runtime/haskell-bind/PGF2.hsc index 827e19bf4..5681f0f86 100644 --- a/src/runtime/haskell-bind/PGF2.hsc +++ b/src/runtime/haskell-bind/PGF2.hsc @@ -433,6 +433,7 @@ graphvizParseTree c opts e = c_opts <- newGraphvizOptions tmpPl opts pgf_graphviz_parse_tree (concr c) (expr e) c_opts out exn touchExpr e + touchConcr c s <- gu_string_buf_freeze sb tmpPl peekUtf8CString s @@ -858,16 +859,7 @@ mkCallbacksMap concr callbacks pool = do Just (e,prob,offset') -> do poke poffset (fromIntegral offset') -- here we copy the expression to out_pool - c_e <- withGuPool $ \tmpPl -> do - exn <- gu_new_exn tmpPl - - (sb,out) <- newOut tmpPl - let printCtxt = nullPtr - pgf_print_expr (expr e) printCtxt 1 out exn - c_str <- gu_string_buf_freeze sb tmpPl - - guin <- gu_string_in c_str tmpPl - pgf_read_expr guin out_pool tmpPl exn + c_e <- pgf_clone_expr (expr e) out_pool ep <- gu_malloc out_pool (#size PgfExprProb) (#poke PgfExprProb, expr) ep c_e diff --git a/src/runtime/haskell-bind/PGF2/FFI.hsc b/src/runtime/haskell-bind/PGF2/FFI.hsc index 082b58d36..f0a811c6d 100644 --- a/src/runtime/haskell-bind/PGF2/FFI.hsc +++ b/src/runtime/haskell-bind/PGF2/FFI.hsc @@ -551,3 +551,6 @@ foreign import ccall "pgf/data.h pgf_lzr_index" foreign import ccall "pgf/data.h pgf_production_is_lexical" pgf_production_is_lexical :: Ptr PgfProductionApply -> Ptr GuBuf -> Ptr GuPool -> IO (#type bool) + +foreign import ccall "pgf/expr.h pgf_clone_expr" + pgf_clone_expr :: PgfExpr -> Ptr GuPool -> IO PgfExpr -- cgit v1.2.3 From 90fc1d750ed21e78e10a37c0699b27665bda0c47 Mon Sep 17 00:00:00 2001 From: krangelov Date: Fri, 14 Aug 2020 21:03:48 +0200 Subject: remove the deprecated pgf_print_expr_tuple --- src/runtime/c/pgf/expr.c | 13 ------------- src/runtime/c/pgf/expr.h | 4 ---- src/runtime/haskell-bind/PGF2/FFI.hsc | 3 --- 3 files changed, 20 deletions(-) (limited to 'src/runtime/haskell-bind') diff --git a/src/runtime/c/pgf/expr.c b/src/runtime/c/pgf/expr.c index 2034a2d61..7bd1601d8 100644 --- a/src/runtime/c/pgf/expr.c +++ b/src/runtime/c/pgf/expr.c @@ -1635,19 +1635,6 @@ pgf_print_context(PgfHypos *hypos, PgfPrintContext* ctxt, } } -PGF_API void -pgf_print_expr_tuple(size_t n_exprs, PgfExpr exprs[], PgfPrintContext* ctxt, - GuOut* out, GuExn* err) -{ - gu_putc('<', out, err); - for (size_t i = 0; i < n_exprs; i++) { - if (i > 0) - gu_putc(',', out, err); - pgf_print_expr(exprs[i], ctxt, 0, out, err); - } - gu_putc('>', out, err); -} - PGF_API bool pgf_type_eq(PgfType* t1, PgfType* t2) { diff --git a/src/runtime/c/pgf/expr.h b/src/runtime/c/pgf/expr.h index 59af969ec..9a5d483a5 100644 --- a/src/runtime/c/pgf/expr.h +++ b/src/runtime/c/pgf/expr.h @@ -229,10 +229,6 @@ PGF_API_DECL void pgf_print_context(PgfHypos *hypos, PgfPrintContext* ctxt, GuOut *out, GuExn *err); -PGF_API_DECL void -pgf_print_expr_tuple(size_t n_exprs, PgfExpr exprs[], PgfPrintContext* ctxt, - GuOut* out, GuExn* err); - PGF_API PgfLiteral pgf_clone_literal(PgfLiteral lit, GuPool* pool); diff --git a/src/runtime/haskell-bind/PGF2/FFI.hsc b/src/runtime/haskell-bind/PGF2/FFI.hsc index f0a811c6d..c72c48e3b 100644 --- a/src/runtime/haskell-bind/PGF2/FFI.hsc +++ b/src/runtime/haskell-bind/PGF2/FFI.hsc @@ -513,9 +513,6 @@ foreign import ccall "pgf/expr.h pgf_compute" foreign import ccall "pgf/expr.h pgf_print_expr" pgf_print_expr :: PgfExpr -> Ptr PgfPrintContext -> CInt -> Ptr GuOut -> Ptr GuExn -> IO () -foreign import ccall "pgf/expr.h pgf_print_expr_tuple" - pgf_print_expr_tuple :: CSizeT -> Ptr PgfExpr -> Ptr PgfPrintContext -> Ptr GuOut -> Ptr GuExn -> IO () - foreign import ccall "pgf/expr.h pgf_print_type" pgf_print_type :: PgfType -> Ptr PgfPrintContext -> CInt -> Ptr GuOut -> Ptr GuExn -> IO () -- cgit v1.2.3