aboutsummaryrefslogtreecommitdiff
path: root/lib/object.nom
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2018-10-30 23:42:04 -0700
committerBruce Hill <bruce@bruce-hill.com>2018-10-30 23:42:36 -0700
commitea3197aaffba00318920ed5e1e33ca5f2a5e6c5c (patch)
tree2ec4aff13c7a54a3730994525b591ac60528b5ad /lib/object.nom
parente7e84c9eda38c930f5475301de4a449dcf59e8b6 (diff)
Fully working version of (action [foo]: baz) -> ((foo) means: baz)
refactor and misc other changes.
Diffstat (limited to 'lib/object.nom')
-rw-r--r--lib/object.nom24
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/object.nom b/lib/object.nom
index bbc6e06..4f45188 100644
--- a/lib/object.nom
+++ b/lib/object.nom
@@ -1,15 +1,13 @@
-#!/usr/bin/env nomsu -V4.8.8.6
+#!/usr/bin/env nomsu -V4.8.10
#
This file contains the implementation of an Object-Oriented programming system.
%globals.METAMETHOD_MAP = {..}
- "as text": "__tostring", "clean up": "__gc",
- "+ 1": "__add", "- 1": "__sub", "* 1": "__mul", "/ 1": "__div",
- "-": "__unm", "// 1": "__idiv", "mod 1": "__mod", "^ 1": "__pow",
- "& 1": "__band", "| 1": "__bor", "~ 1": "__bxor", "~": "__bnot",
- "<< 1": "__bshl", ">> 1": "__bshr", "== 1": "__eq", "< 1": "__lt",
- "<= 1": "__le", "set 1 = 2": "__newindex", "size": "__len",
- "iterate": "__ipairs", "iterate all": "__pairs",
+ "as text":"__tostring", "clean up":"__gc", "+ 1":"__add", "- 1":"__sub"
+ "* 1":"__mul", "/ 1":"__div", "-":"__unm", "// 1":"__idiv", "mod 1":"__mod"
+ "^ 1":"__pow", "& 1":"__band", "| 1":"__bor", "~ 1":"__bxor", "~":"__bnot"
+ "<< 1":"__bshl", ">> 1":"__bshr", "== 1":"__eq", "< 1":"__lt", "<= 1":"__le"
+ "set 1 = 2":"__newindex", size:"__len", iterate:"__ipairs", "iterate all":"__pairs"
test:
object (Dog):
@@ -53,13 +51,13 @@ test:
with {%d:Dog {barks:2}}:
assume ((%d::bark) == "Bark! Bark!")
-compile [my action %actions %body] to:
+(my action %actions %body) compiles to:
lua> "\
..local fn_name = \%actions[1].stub:as_lua_id()
local \%args = table.map(\%actions[1]:get_args(), function(a) return tostring(nomsu:compile(a)) end)
table.insert(\%args, 1, \(\%me as lua id))
local lua = LuaCode(tree.source, "class.", fn_name, " = ", \(..)
- compile as (%args -> %body)
+ what (%args -> %body) compiles to
..)
for i=2,#\%actions do
local alias = \%actions[i]
@@ -79,12 +77,13 @@ compile [my action %actions %body] to:
end
return lua"
-compile [object %classname extends %parent %class_body] to:
+(object %classname extends %parent %class_body) compiles to:
unless (%classname.type == "Action"):
compile error at %classname "Expected this to be an action, not a \(%classname.type)"
for % in %classname:
unless (% is text):
compile error at % "Class names should not have arguments."
+
return (..)
Lua "\
..do
@@ -112,6 +111,5 @@ compile [object %classname extends %parent %class_body] to:
end
end"
-parse [object %classname %class_body] as (..)
+(object %classname %class_body) parses as (..)
object %classname extends (nil) %class_body
-