aboutsummaryrefslogtreecommitdiff
path: root/nomsu.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-05-14 14:45:38 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-05-14 14:45:45 -0700
commit7410e42bc00c8438884a475ccf8a9e07b73eaec3 (patch)
treefc8bec6c4c2a885aceb75fc784bdc4d07cd5392f /nomsu.moon
parent95ee15982bb021e94a4976741a0bcdfe5f5d6992 (diff)
Minor optimizations.
Diffstat (limited to 'nomsu.moon')
-rwxr-xr-xnomsu.moon21
1 files changed, 9 insertions, 12 deletions
diff --git a/nomsu.moon b/nomsu.moon
index 9b1ca59..64516e9 100755
--- a/nomsu.moon
+++ b/nomsu.moon
@@ -120,11 +120,10 @@ do
STRING_METATABLE = getmetatable("")
STRING_METATABLE.__add = (other)=> @ .. stringify(other)
STRING_METATABLE.__index = (i)=>
+ ret = string[i]
+ if ret != nil then return ret
if type(i) == 'number' then return string.sub(@, i, i)
elseif type(i) == 'table' then return string.sub(@, i[1], i[2])
- else return string[i]
- -- Can't use this because it breaks some LPEG stuff
- --STRING_METATABLE.__mul = (other)=> string.rep(@, other)
Types = require "nomsu_tree"
@@ -309,6 +308,7 @@ class NomsuCompiler
define_compile_action: (signature, fn)=>
return @define_action(signature, fn, true)
+ _nomsu_chunk_counter = 0
parse: (nomsu_code)=>
if type(nomsu_code) == 'string'
_nomsu_chunk_counter += 1
@@ -333,7 +333,6 @@ class NomsuCompiler
return tree
- _nomsu_chunk_counter = 0
run: (nomsu_code, compile_fn=nil)=>
if #tostring(nomsu_code) == 0 then return nil
tree = @parse(nomsu_code)
@@ -788,13 +787,11 @@ OPTIONS
-- for both APIs
-- TODO: revert back to old error handler
- --ProFi = require 'ProFi'
- --ProFi\start()
- ok, ldt = pcall(require,'ldt')
- if ok
- ldt.guard run
- else xpcall(run, err_hand)
- --ProFi\stop()
- --ProFi\writeReport( 'MyProfilingReport.txt' )
+ --require('ProFi')\profile "scratch/profile.txt", (profi)->
+ do
+ ok, ldt = pcall(require,'ldt')
+ if ok
+ ldt.guard run
+ else xpcall(run, err_hand)
return NomsuCompiler