git @ Cat's Eye Technologies Deturgenchry / bc93e46
Rename ContV to something less easily confused with ContVal... catseye 11 years ago
1 changed file(s) with 14 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
198198
199199 -- ========== RUNTIME ========== --
200200
201 --
202 -- A ContObj is what continuations pass along to each other.
203 -- It can be a context (environment), a single object, or a list of objects.
204 --
201205 data ContObj = Ctx (Map Name Object)
202206 | Obj Object
203207 | Objs [Object]
204208
205209 type Continuation = ContObj -> ContObj
206210
207 data ContV = ContV Continuation
208 instance Show ContV where
209 show (ContV _) = ""
210 instance Eq ContV where
211 ContV _ == ContV _ = False
211 data ContJ = ContJ Continuation
212 instance Show ContJ where
213 show (ContJ _) = ""
214 instance Eq ContJ where
215 ContJ _ == ContJ _ = False
212216
213217 data Object = IntVal Integer
214218 | ObjVal String (Map Name Object)
215 | ContVal (Map Name Object) ContV
219 | ContVal (Map Name Object) ContJ
216220 | Null
217221 deriving (Show, Eq)
218222
239243 Nothing -> error "No Main class with main() method found"
240244 Just mainMethod ->
241245 let
242 final = ContV id
246 final = ContJ id
243247 r = callMethod p (ContVal EmptyMap final) mainMethod []
244248 in
245249 case r of
260264 case (length actuals) - (length formals) of
261265 0 ->
262266 let
263 self = (ContVal EmptyMap (ContV id)) -- NO NOT REALLY
267 self = (ContVal EmptyMap (ContJ id)) -- NO NOT REALLY
264268 ctx = buildContext formals actuals
265269 ctx' = set "self" self ctx
266270 ctx'' = set "other" other ctx'
292296
293297 evalStatement p ctx (Transfer dest e) _ =
294298 evalExpr p ctx e (\(Obj value) ->
295 evalExpr p ctx dest (\(Obj (ContVal m (ContV k))) ->
299 evalExpr p ctx dest (\(Obj (ContVal m (ContJ k))) ->
296300 k $ Obj value))
297301
298302 evalStatement p ctx (Assign name e) cc =
318322 let
319323 Just klass = getClass className p
320324 Just method = getMethod methodName klass
321 newOther = ContVal ctx $ ContV cc
325 newOther = ContVal ctx $ ContJ cc
322326 in
323327 callMethod p newOther method actuals))
324328