Commit ff1f90b9 authored by bbr's avatar bbr
Browse files

concurrency has to switch threads sometimes...

parent 06e07e81
......@@ -595,7 +595,7 @@ concAnd s@(C_BoolSusp _ wake) x st =
maySwitch :: StrEqResult -> StrEqResult -> Result StrEqResult
maySwitch C_True x _ = x
maySwitch y@(C_BoolOr _ _) (C_BoolOr r xs) st =
C_BoolOr r (map (\ x -> concAnd x y st) xs)
C_BoolOr r (map (\ x -> concAnd y x st) xs)
maySwitch x@(C_BoolFail _) _ _ = x
maySwitch x@C_False _ _ = x
maySwitch (C_BoolFreeVar v) x st = narrowSuccess v x
......@@ -885,171 +885,3 @@ instance (Generate a,Show a,Read a,Eq a) => Curry (Prim a) where
instance Eq (a->b) where
(==) = error "comparing FUNCTION"
{-
-----------------------------------------------------------------------
-- Strings and other Lists
-----------------------------------------------------------------------
strEq C_Success C_Success = C_Success
strEq x _ = strEqFail (typeName x)
eq C_Success C_Success = C_True
eq _ _ = C_False
typeName _ = (:<)(C_Char('S'))((:<)(C_Char('u'))((:<)(C_Char('c'))((:<)(C_Char('c'))((:<)(C_Char('e'))((:<)(C_Char('s'))((:<)(C_Char('s'))(List)))))))
--toC_Term mode store C_Success = C_Data(C_Int((1::Integer)))((:<)(C_Char('S'))((:<)(C_Char('u'))((:<)(C_Char('c'))((:<)(C_Char('c'))((:<)(C_Char('e'))((:<)(C_Char('s'))((:<)(C_Char('s'))(List))))))))(List)
--toC_Term _ _ (C_SuccessFreeVar r) = C_Free(C_Int(Prelude.toInteger(r)))
--fromC_Term (C_Data (C_Int (1::Integer)) _ List) = C_Success
--fromC_Term (C_Data (C_IntFreeVar _) ((:<) (C_Char 'S') ((:<) (C_Char 'u') ((:<) (C_Char 'c') ((:<) (C_Char 'c') ((:<) (C_Char 'e') ((:<) (C_Char 's') ((:<) (C_Char 's') List))))))) List) = C_Success
--fromC_Term (C_Free (C_Int r)) = C_SuccessFreeVar(Prelude.fromInteger(r))
strEq C_True C_True = C_Success
strEq C_False C_False = C_Success
strEq x _ = strEqFail (typeName x)
eq C_True C_True = C_True
eq C_False C_False = C_True
eq _ _ = C_False
typeName _ = (:<)(C_Char('B'))((:<)(C_Char('o'))((:<)(C_Char('o'))((:<)(C_Char('l'))(List))))
--toC_Term mode store C_True = C_Data(C_Int((2::Integer)))((:<)(C_Char('T'))((:<)(C_Char('r'))((:<)(C_Char('u'))((:<)(C_Char('e'))(List)))))(List)
--toC_Term mode store C_False = C_Data(C_Int((1::Integer)))((:<)(C_Char('F'))((:<)(C_Char('a'))((:<)(C_Char('l'))((:<)(C_Char('s'))((:<)(C_Char('e'))(List))))))(List)
--toC_Term _ _ (C_BoolFreeVar r) = C_Free(C_Int(Prelude.toInteger(r)))
--fromC_Term (C_Data (C_Int (2::Integer)) _ List) = C_True
--fromC_Term (C_Data (C_Int (1::Integer)) _ List) = C_False
--fromC_Term (C_Data (C_IntFreeVar _) ((:<) (C_Char 'T') ((:<) (C_Char 'r') ((:<) (C_Char 'u') ((:<) (C_Char 'e') List)))) List) = C_True
--fromC_Term (C_Data (C_IntFreeVar _) ((:<) (C_Char 'F') ((:<) (C_Char 'a') ((:<) (C_Char 'l') ((:<) (C_Char 's') ((:<) (C_Char 'e') List))))) List) = C_False
--fromC_Term (C_Free (C_Int r)) = C_BoolFreeVar(Prelude.fromInteger(r))
--instance Enum (IORef a) where
--instance Real (IORef a) where
--instance Num (IORef a) where
--instance Ord (IORef a) where
--instance Integral (IORef a) where
-- toInteger _ = undefined
-------------------------------------------------------------------------
-- expanding type definitions
-------------------------------------------------------------------------
-- the following is needed to give functions a curry class
-- by data type (Prim (a->b)) (see below.)
-- The alternative would be an own Wrapper class for functions.
-- (Maybe done some day if there would be some serious advantage.)
-----------------------------------------------------------------------
-- some special instances for functions in order to derive class Curry
-- for Prim (a->b)
-----------------------------------------------------------------------
-----------------------------------------------------------------
-- wrapper for primitive datatypes
-----------------------------------------------------------------
int2string :: Integer -> String
int2string i = if i < 256 then [ch i] else int2string (div i 256) ++ [ch (mod i 256)]
where
ch i = chr (fromInteger i)
string2int :: String -> Integer
string2int = foldl (\ i c -> 256*i+toInteger(ord c)) 0
-----------------------------------------------------------------------
-- Lists
-----------------------------------------------------------------------
freeVarify cs = case break isSpace cs of
(consName,_:nStr)
| isSuffixOf "FreeVar" consName && isDigit (head nStr) ->
'_':nStr
_ -> cs
-----------------------------------------------------------------------
-- Char is not implemented with Prim because of String representation
-----------------------------------------------------------------------
---------------------------------------------------
-- only as long as AutoGenerated2 is not complete
---------------------------------------------------
instance Curry C_Int where
nf f store x = f(store)(x)
gnf f store x = f(store)(x)
consKind (C_IntFreeVar _) = Free
consKind (C_IntOr _ _) = Branching
consKind (C_IntFail _) = Failed
consKind (C_IntSusp _ _) = Suspended
consKind _ = Val
exceptions (C_IntFail x) = x
freeVarRef (C_IntFreeVar r) = r
orRef (C_IntOr x _) = x
branches (C_IntOr _ x) = x
suspRef (C_IntSusp x _) = x
suspCont (C_IntSusp _ x) = x
failed = C_IntFail
freeVar = C_IntFreeVar
branching = C_IntOr
suspend = C_IntSusp
strEq x@(C_Int c1) (C_Int c2)
| c1 Prelude.== c2 = C_Success
| otherwise = strEqFail (typeName x)
eq (C_Int x1) (C_Int y1) = toCurry (x1 Prelude.== y1)
eq _ _ = C_False
--toC_Term _ _ ci@(C_Int i) = C_Data ci (toCurry (show i)) List
--toC_Term _ _ (C_IntFreeVar r) = C_Free(C_Int(Prelude.toInteger(r)))
--fromC_Term (C_Data i@(C_Int _) _ _) = i
--fromC_Term (C_Data (C_IntFreeVar _) name List) = C_Int (read (fromCurry name))
--fromC_Term (C_Free (C_Int r)) = C_IntFreeVar(Prelude.fromInteger(r))
typeName _ = (:<)(C_Char('I'))((:<)(C_Char('n'))((:<)(C_Char('t'))(List)))
-}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment