diff options
| author | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-04 17:23:02 -0700 |
|---|---|---|
| committer | Bruce Hill <bitbucket@bruce-hill.com> | 2018-06-04 17:23:13 -0700 |
| commit | e7bdc35aa82339f0734ec7014d2da0459ff0462d (patch) | |
| tree | fbd04f75c4a75210e80b86c480e5dc15508968e9 /lib/object.nom | |
| parent | 7cd4f276b7b80e269569d775238606004edf1330 (diff) | |
Cleanups to try/catch logic and object logic.
Diffstat (limited to 'lib/object.nom')
| -rw-r--r-- | lib/object.nom | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/lib/object.nom b/lib/object.nom index 9229d21..eb9beb8 100644 --- a/lib/object.nom +++ b/lib/object.nom @@ -11,22 +11,26 @@ action [new %classname %inst] immediately parse [new %classname] as: new %classname {} -parse [as %instance %body] as - lua> "local self;" - do - using - lua> ".." - self = \%instance - local cls = self.class - local old_self = self.class:set_self(self) - ACTIONS = cls.ACTIONS - COMPILE_ACTIONS = cls.COMPILE_ACTIONS - ARG_ORDERS = cls.ARG_ORDERS - ..do - %body - ..then always - lua> ".." +compile [as %instance %body] to + Lua ".." + do + local self = \(%instance as lua expr) + local old_self = self.class:set_self(self) + old_actions, ACTIONS = ACTIONS, self.class.ACTIONS + old_compile_actions, COMPILE_ACTIONS = COMPILE_ACTIONS, self.class.COMPILE_ACTIONS + old_arg_orders, ARG_ORDERS = ARG_ORDERS, self.class.ARG_ORDERS + local fell_through = false + local ok, ret = pcall(function() + \(%body as lua statements) + fell_through = true + end) self.class:set_self(old_self) + ACTIONS = old_actions + COMPILE_ACTIONS = old_compile_actions + ARG_ORDERS = old_arg_orders + if not ok then error(ret) end + if not fell_through then return ret end + end parse [object %classname %class_body] as using |
