unison-runtime-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.Runtime.Stack

Synopsis

Documentation

data K Source #

Instances

Instances details
Show K Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> K -> ShowS #

show :: K -> String #

showList :: [K] -> ShowS #

data GClosure comb Source #

Constructors

GPAp 

Fields

GEnum !Reference !PackedTag 
GData1 !Reference !PackedTag !Val 
GData2 !Reference !PackedTag !Val !Val 
GDataG !Reference !PackedTag !Seg 
GCaptured 

Fields

  • !K

    code cont

  • !Int

    arg size

  • !Seg

    u/b data stacks

GForeign !Foreign 
GUnboxedTypeTag !UnboxedTypeTag

The type tag for the value in the corresponding unboxed stack slot.

We should consider adding separate constructors for common builtin type tags. GHC will optimize nullary constructors into singletons.

GAffine 

Fields

GBlackHole 

Instances

Instances details
Foldable GClosure Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

fold :: Monoid m => GClosure m -> m #

foldMap :: Monoid m => (a -> m) -> GClosure a -> m #

foldMap' :: Monoid m => (a -> m) -> GClosure a -> m #

foldr :: (a -> b -> b) -> b -> GClosure a -> b #

foldr' :: (a -> b -> b) -> b -> GClosure a -> b #

foldl :: (b -> a -> b) -> b -> GClosure a -> b #

foldl' :: (b -> a -> b) -> b -> GClosure a -> b #

foldr1 :: (a -> a -> a) -> GClosure a -> a #

foldl1 :: (a -> a -> a) -> GClosure a -> a #

toList :: GClosure a -> [a] #

null :: GClosure a -> Bool #

length :: GClosure a -> Int #

elem :: Eq a => a -> GClosure a -> Bool #

maximum :: Ord a => GClosure a -> a #

minimum :: Ord a => GClosure a -> a #

sum :: Num a => GClosure a -> a #

product :: Num a => GClosure a -> a #

Traversable GClosure Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

traverse :: Applicative f => (a -> f b) -> GClosure a -> f (GClosure b) #

sequenceA :: Applicative f => GClosure (f a) -> f (GClosure a) #

mapM :: Monad m => (a -> m b) -> GClosure a -> m (GClosure b) #

sequence :: Monad m => GClosure (m a) -> m (GClosure a) #

Functor GClosure Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

fmap :: (a -> b) -> GClosure a -> GClosure b #

(<$) :: a -> GClosure b -> GClosure a #

Show comb => Show (GClosure comb) Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> GClosure comb -> ShowS #

show :: GClosure comb -> String #

showList :: [GClosure comb] -> ShowS #

newtype Closure Source #

Constructors

Closure 

Bundled Patterns

pattern DataC :: Reference -> PackedTag -> SegList -> Closure 
pattern PApV :: CombIx -> RCombInfo Val -> SegList -> Closure 
pattern CapV :: K -> Int -> SegList -> Closure 
pattern PAp :: CombIx -> GCombInfo (RComb Val) -> Seg -> Closure 
pattern Enum :: Reference -> PackedTag -> Closure 
pattern Data1 :: Reference -> PackedTag -> Val -> Closure 
pattern Data2 :: Reference -> PackedTag -> Val -> Val -> Closure 
pattern DataG :: Reference -> PackedTag -> Seg -> Closure 
pattern Captured :: K -> Int -> Seg -> Closure 
pattern Foreign :: Foreign -> Closure 
pattern Affine :: EnumSet Word64 -> AEnv -> AffineRef -> Closure 
pattern BlackHole :: Closure 
pattern UnboxedTypeTag :: UnboxedTypeTag -> Closure 

newtype AffineRef Source #

Constructors

ARef (IORef Closure) 

Instances

Instances details
Show AffineRef Source # 
Instance details

Defined in Unison.Runtime.Stack

Eq AffineRef Source # 
Instance details

Defined in Unison.Runtime.Stack

data HEnv Source #

Constructors

HEnv 

Fields

Instances

Instances details
Monoid HEnv Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

mempty :: HEnv #

mappend :: HEnv -> HEnv -> HEnv #

mconcat :: [HEnv] -> HEnv #

Semigroup HEnv Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

(<>) :: HEnv -> HEnv -> HEnv #

sconcat :: NonEmpty HEnv -> HEnv #

stimes :: Integral b => b -> HEnv -> HEnv #

newtype Callback Source #

Constructors

Hook (XStack -> IO ()) 

Instances

Instances details
Eq Callback Source # 
Instance details

Defined in Unison.Runtime.Stack

Ord Callback Source # 
Instance details

Defined in Unison.Runtime.Stack

data Augment Source #

Constructors

I 
K 
C 

data Dump Source #

Constructors

A 
F Int Int 
S 

data Stack Source #

Constructors

Stack 

Fields

Instances

Instances details
Show Stack Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> Stack -> ShowS #

show :: Stack -> String #

showList :: [Stack] -> ShowS #

type Off = Int Source #

type SZ = Int Source #

type FP = Int Source #

type Seg = (USeg, BSeg) Source #

type SegList = [Val] Source #

data Val Source #

A runtime value, which is either a boxed or unboxed value, but we may not know which.

When it represents a boxed value, $sel:getUnboxedVal:Val is meaningless, but when it represents an unboxed value, $sel:getBoxedVal:Val tells us its type.

Constructors

Val 

Fields

Bundled Patterns

pattern CharVal :: Char -> Val 
pattern NatVal :: Word64 -> Val 
pattern DoubleVal :: Double -> Val 
pattern IntVal :: Int -> Val 
pattern BoolVal :: Bool -> Val 
pattern UnboxedVal :: Int -> UnboxedTypeTag -> Val 
pattern BoxedVal :: Closure -> Val

Matches a Val which is known to be boxed, and returns the closure portion.

Instances

Instances details
Show Val Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

showsPrec :: Int -> Val -> ShowS #

show :: Val -> String #

showList :: [Val] -> ShowS #

Eq Val Source #

The Eq instance for Val can’t be derived because you need to take into account the fact that if a Val is boxed, the unboxed side is garbage and should not be compared.

Instance details

Defined in Unison.Runtime.Stack

Methods

(==) :: Val -> Val -> Bool #

(/=) :: Val -> Val -> Bool #

Ord Val Source # 
Instance details

Defined in Unison.Runtime.Stack

Methods

compare :: Val -> Val -> Ordering #

(<) :: Val -> Val -> Bool #

(<=) :: Val -> Val -> Bool #

(>) :: Val -> Val -> Bool #

(>=) :: Val -> Val -> Bool #

max :: Val -> Val -> Val #

min :: Val -> Val -> Val #

ForeignConvention Val Source # 
Instance details

Defined in Unison.Runtime.Foreign.Function

BuiltinForeign (Ticket Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (TVar Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (IORef Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (MVar Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Array Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (Promise Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

ForeignConvention (Seq Val) Source # 
Instance details

Defined in Unison.Runtime.Foreign.Function

BuiltinForeign (Map Val Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

BuiltinForeign (MutableArray s Val) Source # 
Instance details

Defined in Unison.Runtime.Stack

emptyVal :: Val Source #

A nulled out value you can use when filling empty arrays, etc.

boxedVal :: BVal -> Val Source #

Lift a boxed val into an Val

type USeq = Seq Val Source #

Implementation for Unison sequences.

poke :: DebugCallStack => Stack -> Val -> IO () Source #

pokeD :: Stack -> Double -> IO () Source #

pokeOffD :: Stack -> Int -> Double -> IO () Source #

pokeC :: Stack -> Char -> IO () Source #

pokeOffC :: Stack -> Int -> Char -> IO () Source #

pokeBool :: DebugCallStack => Stack -> Bool -> IO () Source #

pokeTag :: DebugCallStack => Stack -> Int -> IO () Source #

Store an unboxed tag to later match on. Often used to indicate the constructor of a data type that's been unpacked onto the stack, or some tag we're about to branch on.

peekTag :: DebugCallStack => Stack -> IO Int Source #

peekTagOff :: DebugCallStack => Stack -> Off -> IO Int Source #

peekI :: DebugCallStack => Stack -> IO Int Source #

peekOffI :: DebugCallStack => Stack -> Off -> IO Int Source #

pokeN :: Stack -> Word64 -> IO () Source #

pokeOffN :: Stack -> Int -> Word64 -> IO () Source #

pokeI :: Stack -> Int -> IO () Source #

Note: This is for poking an unboxed value that has the UNISON type int, not just any unboxed data.

pokeOffI :: Stack -> Int -> Int -> IO () Source #

pokeBi :: BuiltinForeign b => Stack -> b -> IO () Source #

pokeOffBi :: BuiltinForeign b => Stack -> Int -> b -> IO () Source #

pokeS :: Stack -> USeq -> IO () Source #

pokeOffS :: Stack -> Int -> USeq -> IO () Source #

dumpAP :: Int -> Int -> Int -> Dump -> Int Source #

dumpFP :: Int -> Int -> Dump -> Int Source #

peek :: DebugCallStack => Stack -> IO Val Source #

upeek :: DebugCallStack => Stack -> IO UVal Source #

bpeek :: DebugCallStack => Stack -> IO BVal Source #

peekOff :: DebugCallStack => Stack -> Off -> IO Val Source #

upeekOff :: DebugCallStack => Stack -> Off -> IO UVal Source #

bpeekOff :: DebugCallStack => Stack -> Off -> IO BVal Source #

bpoke :: DebugCallStack => Stack -> BVal -> IO () Source #

Store a boxed value. We don't bother nulling out the unboxed stack, it's extra work and there's nothing to garbage collect.

bpokeOff :: DebugCallStack => Stack -> Off -> BVal -> IO () Source #

pokeOff :: DebugCallStack => Stack -> Off -> Val -> IO () Source #

upokeT :: DebugCallStack => Stack -> UVal -> BVal -> IO () Source #

upokeOffT :: DebugCallStack => Stack -> Off -> UVal -> BVal -> IO () Source #

unsafePokeIasN :: DebugCallStack => Stack -> Int -> IO () Source #

Sometimes we get back an int from a foreign call which we want to use as a Nat. If we know it's positive and smaller than 2^63 then we can safely store the Int directly as a Nat without checks.

grabSeg :: Stack -> SZ -> IO (Seg, Stack) Source #

Eats up arguments

useg :: [Int] -> USeg Source #

Converts a list of integers representing an unboxed segment back into the appropriate segment. Segments are stored backwards in the runtime, so this reverses the list.

bseg :: [Closure] -> BSeg Source #

Converts a list of closures back to a boxed segment. Segments are stored backwards, so this reverses the contents.

segFromList :: SegList -> Seg Source #

Converts from the list representation of a segment to the efficient stack form. Segments are stored backwards, so this reverses the contents.

Unboxed type tags