mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-24 03:52:50 -06:00
Add note in PGF2 documentation about risk for integer overflow.
Closes #109
This commit is contained in:
@@ -19,7 +19,7 @@ wildCId = "_" :: CId
|
|||||||
type Cat = CId -- ^ Name of syntactic category
|
type Cat = CId -- ^ Name of syntactic category
|
||||||
type Fun = CId -- ^ Name of function
|
type Fun = CId -- ^ Name of function
|
||||||
|
|
||||||
data BindType =
|
data BindType =
|
||||||
Explicit
|
Explicit
|
||||||
| Implicit
|
| Implicit
|
||||||
deriving Show
|
deriving Show
|
||||||
@@ -38,7 +38,7 @@ instance Show Expr where
|
|||||||
show = showExpr []
|
show = showExpr []
|
||||||
|
|
||||||
instance Eq Expr where
|
instance Eq Expr where
|
||||||
(Expr e1 e1_touch) == (Expr e2 e2_touch) =
|
(Expr e1 e1_touch) == (Expr e2 e2_touch) =
|
||||||
unsafePerformIO $ do
|
unsafePerformIO $ do
|
||||||
res <- pgf_expr_eq e1 e2
|
res <- pgf_expr_eq e1 e2
|
||||||
e1_touch >> e2_touch
|
e1_touch >> e2_touch
|
||||||
@@ -113,9 +113,9 @@ unApp (Expr expr touch) =
|
|||||||
appl <- pgf_expr_unapply expr pl
|
appl <- pgf_expr_unapply expr pl
|
||||||
if appl == nullPtr
|
if appl == nullPtr
|
||||||
then return Nothing
|
then return Nothing
|
||||||
else do
|
else do
|
||||||
fun <- peekCString =<< (#peek PgfApplication, fun) appl
|
fun <- peekCString =<< (#peek PgfApplication, fun) appl
|
||||||
arity <- (#peek PgfApplication, n_args) appl :: IO CInt
|
arity <- (#peek PgfApplication, n_args) appl :: IO CInt
|
||||||
c_args <- peekArray (fromIntegral arity) (appl `plusPtr` (#offset PgfApplication, args))
|
c_args <- peekArray (fromIntegral arity) (appl `plusPtr` (#offset PgfApplication, args))
|
||||||
return $ Just (fun, [Expr c_arg touch | c_arg <- c_args])
|
return $ Just (fun, [Expr c_arg touch | c_arg <- c_args])
|
||||||
|
|
||||||
@@ -140,7 +140,9 @@ unStr (Expr expr touch) =
|
|||||||
touch
|
touch
|
||||||
return (Just s)
|
return (Just s)
|
||||||
|
|
||||||
-- | Constructs an expression from an integer literal
|
-- | Constructs an expression from an integer literal.
|
||||||
|
-- Note that the C runtime does not support long integers, and you may run into overflow issues with large values.
|
||||||
|
-- See [here](https://github.com/GrammaticalFramework/gf-core/issues/109) for more details.
|
||||||
mkInt :: Int -> Expr
|
mkInt :: Int -> Expr
|
||||||
mkInt val =
|
mkInt val =
|
||||||
unsafePerformIO $ do
|
unsafePerformIO $ do
|
||||||
@@ -267,7 +269,7 @@ foreign import ccall "wrapper"
|
|||||||
-- in the expression in order reverse to the order
|
-- in the expression in order reverse to the order
|
||||||
-- of binding.
|
-- of binding.
|
||||||
showExpr :: [CId] -> Expr -> String
|
showExpr :: [CId] -> Expr -> String
|
||||||
showExpr scope e =
|
showExpr scope e =
|
||||||
unsafePerformIO $
|
unsafePerformIO $
|
||||||
withGuPool $ \tmpPl ->
|
withGuPool $ \tmpPl ->
|
||||||
do (sb,out) <- newOut tmpPl
|
do (sb,out) <- newOut tmpPl
|
||||||
|
|||||||
Reference in New Issue
Block a user