aboutsummaryrefslogtreecommitdiff
path: root/lib/object.nom
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-17 23:37:20 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-17 23:37:26 -0700
commit88df5c72a317cc011f221627a2c3082078237cc1 (patch)
treea0e983d6aa356dbcd7ec2f71378c3b796e960ac3 /lib/object.nom
parentaf441330ff7cfdc466281ce135ca7231ec54c499 (diff)
Updating lib to v2
Diffstat (limited to 'lib/object.nom')
-rw-r--r--lib/object.nom42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/object.nom b/lib/object.nom
index 45f7551..d41557b 100644
--- a/lib/object.nom
+++ b/lib/object.nom
@@ -1,37 +1,35 @@
-#!/usr/bin/env nomsu -V1
+#!/usr/bin/env nomsu -V2.2.4.3
#
This file contains the implementation of an Object-Oriented programming system.
use "core"
-compile [@, me] to: Lua value "self"
-
-compile [method %actions %body] to
- %lua <- (compile as: action %actions %body)
+compile [@, me] to (Lua value "self")
+compile [method %actions %body] to:
+ %lua <- (compile as (action %actions %body))
add free vars ((% as lua id) for % in %actions) to %lua
declare locals in %lua
- for % in %actions
+ for % in %actions:
to %lua write "\nclass.\(% as lua id) = \(% as lua id)"
- return
+
+ return (..)
Lua ".."
- do -- Method: \(%actions.1.stub)
+ do -- Method: \(%actions.(1).stub)
\%lua
end
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-parse [as %instance %body] as
- result of
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+parse [as %instance %body] as (..)
+ result of:
%old_self <- (me)
(me) <- %instance
- try
- %body
- ..and if it barfs %msg
+ try %body and if it barfs %msg:
(me) <- %old_self
barf %msg
- ..or if it succeeds
- (me) <- %old_self
+ ..or if it succeeds: (me) <- %old_self
-compile [object %classname extends %parent %class_body] to
+compile [object %classname extends %parent %class_body] to (..)
Lua ".."
do
local class = {name=\(%classname as lua expr)}
@@ -51,11 +49,13 @@ compile [object %classname extends %parent %class_body] to
_ENV["A"..string.as_lua_id("class "..class.name)] = function() return class end
class.__index = class
class.class = class
-
+
\(%class_body as lua statements)
-
+
class.__tostring = class["A"..string.as_lua_id("as text")]
end
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-parse [object %classname %class_body] as: object %classname extends (nil) %class_body
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+parse [object %classname %class_body] as (..)
+ object %classname extends (nil) %class_body