packages feed

dhscanner-kbgen 1.1.0 → 1.2.0

raw patch · 2 files changed

+64/−1 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Kbgen: CallableReturnsValue :: Callable -> ReturnedValue -> CallableReturnsValue
+ Kbgen: CallableReturnsValueCtor :: CallableReturnsValue -> Fact
+ Kbgen: CallableReturnsWithoutValue :: Callable -> Location -> CallableReturnsWithoutValue
+ Kbgen: CallableReturnsWithoutValueCtor :: CallableReturnsWithoutValue -> Fact
+ Kbgen: data CallableReturnsValue
+ Kbgen: data CallableReturnsWithoutValue
+ Kbgen: instance Data.Aeson.Types.FromJSON.FromJSON Kbgen.CallableReturnsValue
+ Kbgen: instance Data.Aeson.Types.FromJSON.FromJSON Kbgen.CallableReturnsWithoutValue
+ Kbgen: instance Data.Aeson.Types.ToJSON.ToJSON Kbgen.CallableReturnsValue
+ Kbgen: instance Data.Aeson.Types.ToJSON.ToJSON Kbgen.CallableReturnsWithoutValue
+ Kbgen: instance GHC.Classes.Eq Kbgen.CallableReturnsValue
+ Kbgen: instance GHC.Classes.Eq Kbgen.CallableReturnsWithoutValue
+ Kbgen: instance GHC.Classes.Ord Kbgen.CallableReturnsValue
+ Kbgen: instance GHC.Classes.Ord Kbgen.CallableReturnsWithoutValue
+ Kbgen: instance GHC.Generics.Generic Kbgen.CallableReturnsValue
+ Kbgen: instance GHC.Generics.Generic Kbgen.CallableReturnsWithoutValue
+ Kbgen: instance GHC.Show.Show Kbgen.CallableReturnsValue
+ Kbgen: instance GHC.Show.Show Kbgen.CallableReturnsWithoutValue

Files

dhscanner-kbgen.cabal view
@@ -33,7 +33,7 @@         * explain in plain English your query's purpose
         * et voilà !
 
-version:            1.1.0
+version:            1.2.0
 license:            GPL-3.0-only
 license-file:       LICENSE
 author:             OrenGitHub
src/Kbgen.hs view
@@ -72,6 +72,8 @@     ConstBoolTrue(..),
     ConstNull(..),
     GatedReturn(..),
+    CallableReturnsValue(..),
+    CallableReturnsWithoutValue(..),
     Cond(..),
     ReturnedValue(..),
     ClassAnnotation,
@@ -994,6 +996,51 @@ -- This is how the fact will look inside the Prolog file
 --
 -- @
+-- kb_callable_returns_value( Callable, ReturnedValue ).
+-- @
+--
+-- __When should I use this fact__
+--
+-- Every explicit `return exp;` inside a callable's body fires this fact
+-- once, keyed by the enclosing callable and the returned expression's
+-- location. Downstream predicates like `kb_const_null` or
+-- `kb_call_resolved` add semantic meaning to the value slot.
+--
+data CallableReturnsValue = CallableReturnsValue
+    Callable -- ^
+    ReturnedValue -- ^
+    deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
+
+-- |
+--
+-- __Name__
+--
+-- This is how the fact will look inside the Prolog file
+--
+-- @
+-- kb_callable_returns_without_value( Callable, ReturnStmtLocation ).
+-- @
+--
+-- __When should I use this fact__
+--
+-- User-written bare `return;` (no value expression) fires this fact once,
+-- keyed by the enclosing callable and the location of the return
+-- statement itself. Distinct fact from 'CallableReturnsValue' because
+-- there is no value-expression location to anchor on; the return
+-- statement location is used instead.
+--
+data CallableReturnsWithoutValue = CallableReturnsWithoutValue
+    Callable -- ^
+    Location -- ^
+    deriving ( Show, Eq, Ord, Generic, ToJSON, FromJSON )
+
+-- |
+--
+-- __Name__
+--
+-- This is how the fact will look inside the Prolog file
+--
+-- @
 -- kb_dataflow_edge( From, To ).
 -- @
 --
@@ -1059,6 +1106,8 @@    | ConstBoolTrueCtor ConstBoolTrue
    | ConstNullCtor ConstNull
    | GatedReturnCtor GatedReturn
+   | CallableReturnsValueCtor CallableReturnsValue
+   | CallableReturnsWithoutValueCtor CallableReturnsWithoutValue
    | MethodOfClassCtor MethodOfClass
    | ClassAnnotationCtor ClassAnnotation
    | ParamiOfCallableCtor ParamiOfCallable
@@ -1096,6 +1145,8 @@ prologify (ConstBoolTrueCtor content) = prologify_ConstBoolTrue content
 prologify (ConstNullCtor content) = prologify_ConstNull content
 prologify (GatedReturnCtor content) = prologify_GatedReturn content
+prologify (CallableReturnsValueCtor content) = prologify_CallableReturnsValue content
+prologify (CallableReturnsWithoutValueCtor content) = prologify_CallableReturnsWithoutValue content
 prologify (MethodOfClassCtor content) = prologify_MethodOfClass content
 prologify (ClassAnnotationCtor content) = prologify_ClassAnnotation content
 prologify (ParamiOfCallableCtor content) = prologify_ParamiOfCallable content
@@ -1188,6 +1239,18 @@ 
 prologify_GatedReturn :: GatedReturn -> String
 prologify_GatedReturn (GatedReturn (Cond c) (ReturnedValue v)) = prologify_GatedReturn' c v
+
+prologify_CallableReturnsValue' :: Location -> Location -> String
+prologify_CallableReturnsValue' c v = printf "kb_callable_returns_value( %s, %s )." (locationify c) (locationify v)
+
+prologify_CallableReturnsValue :: CallableReturnsValue -> String
+prologify_CallableReturnsValue (CallableReturnsValue (Callable c) (ReturnedValue v)) = prologify_CallableReturnsValue' c v
+
+prologify_CallableReturnsWithoutValue' :: Location -> Location -> String
+prologify_CallableReturnsWithoutValue' c s = printf "kb_callable_returns_without_value( %s, %s )." (locationify c) (locationify s)
+
+prologify_CallableReturnsWithoutValue :: CallableReturnsWithoutValue -> String
+prologify_CallableReturnsWithoutValue (CallableReturnsWithoutValue (Callable c) s) = prologify_CallableReturnsWithoutValue' c s
 
 prologify_MethodOfClass' :: Location -> Location -> String
 prologify_MethodOfClass' m c = printf "kb_method_of_class( %s, %s )." (locationify m) (locationify c)