mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-05 17:22:51 -06:00
added exprSubstitute in the C runtime for substituting meta variables
This commit is contained in:
@@ -39,7 +39,7 @@ module PGF2 (-- * PGF
|
||||
mkFloat,unFloat,
|
||||
mkMeta,unMeta,
|
||||
mkCId,
|
||||
exprHash, exprSize, exprFunctions,
|
||||
exprHash, exprSize, exprFunctions, exprSubstitute,
|
||||
treeProbability,
|
||||
|
||||
-- ** Types
|
||||
@@ -366,6 +366,20 @@ exprFunctions (Expr c_expr touch) =
|
||||
touch
|
||||
return funs
|
||||
|
||||
exprSubstitute :: Expr -> [Expr] -> Expr
|
||||
exprSubstitute (Expr c_expr touch) meta_values =
|
||||
unsafePerformIO $
|
||||
withGuPool $ \tmpPl -> do
|
||||
c_meta_values <- newSequence (#size PgfExpr) pokeExpr meta_values tmpPl
|
||||
exprPl <- gu_new_pool
|
||||
c_expr <- pgf_expr_substitute c_expr c_meta_values exprPl
|
||||
touch
|
||||
exprFPl <- newForeignPtr gu_pool_finalizer exprPl
|
||||
let touch' = sequence_ (touchForeignPtr exprFPl : map touchExpr meta_values)
|
||||
return (Expr c_expr touch')
|
||||
where
|
||||
pokeExpr ptr (Expr c_expr _) = poke ptr c_expr
|
||||
|
||||
-----------------------------------------------------------------------------
|
||||
-- Graphviz
|
||||
|
||||
|
||||
Reference in New Issue
Block a user