Commits

Alex Suraci  committed 97aded3

added runMethod for Macros

  • Participants
  • Parent commits 5ccfa84

Comments (0)

Files changed (1)

File src/Atomy/Runtime.hs

         }
 
     return r
-runMethod m _ = error $ "no runMethod for " ++ show m
+runMethod (Macro { mPattern = p, mExpr = e }) m = do
+    Trait c <- gets (psEnvironment . parserState)
+    t <- derive c
+    modify $ \env -> env
+        { methods = (methods env)
+            { mMap = M.insert t (bindings p m) (mMap (methods env))
+            }
+        }
+
+    withTop (Trait t) $ eval e
 
 -- | Run x with t as its toplevel object.
 withTop :: Value -> VM a -> VM a