Skip to content

Commit

Permalink
Set debugLevel to 0 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Phrogz committed Jul 11, 2008
1 parent 87e3341 commit e253258
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions core.lua
Expand Up @@ -66,7 +66,7 @@ function eval( context, receiver, expressionOrMessageOrLiteral )
return sendMessage( context, receiver, expressionOrMessageOrLiteral )
else
-- Presumably this is a literal
if arg.debugLevel and arg.debugLevel >= 1 and not runtime.isKindOf( receiver, Roots.Context ) then
if arg.debugLevel >= 1 and not runtime.isKindOf( receiver, Roots.Context ) then
print( "Warning: Literal value '"..tostring(expressionOrMessageOrLiteral).."' sent to non-context: "..tostring(receiver))
end
return expressionOrMessageOrLiteral
Expand Down Expand Up @@ -103,7 +103,7 @@ function sendMessage( callingContext, receiver, messageOrLiteral )
if obj == Roots['nil'] and messageName ~= 'nil' then
-- TODO: method_mising
-- FIXME: No need to error, just flow through to return Roots.nil
if arg.debugLevel and arg.debugLevel >= 1 then
if arg.debugLevel >= 1 then
print( "Warning: Cannot find message '"..tostring(messageName).."' on "..tostring(receiver) )
end
elseif obj.executeOnAccess ~= Roots['nil'] then
Expand All @@ -115,7 +115,7 @@ end

function executeFunction( functionObject, receiver, message, callingContext )
if callingContext == Roots['nil'] then
if arg.debugLevel and arg.debugLevel >= 2 then
if arg.debugLevel >= 2 then
local messageString = runtime.luastring[message.identifier]
if messageString ~= 'toString' and messageString ~= 'asCode' then
print( "Warning: No message/expression context when sending '"..messageString.."'...so I'm using the Lawn instead." )
Expand All @@ -139,13 +139,13 @@ function executeFunction( functionObject, receiver, message, callingContext )
local theNextMessageInCallingContext = callingContext.evalStack[ #callingContext.evalStack ]
for i=1,#functionObject.namedArguments do
local theArgName = runtime.luastring[ functionObject.namedArguments[i] ]
if arg.debugLevel and arg.debugLevel >= 2 and rawget( context, theArgName ) then
if arg.debugLevel >= 2 and rawget( context, theArgName ) then
print( "Warning: overriding built in context property '"..theArgName.."'" )
end
if message.arguments[i] ~= Roots['nil'] then
context[ theArgName ] = eval( callingContext, callingContext, message.arguments[i] )
else
if arg.debugLevel and arg.debugLevel >= 3 then
if arg.debugLevel >= 3 then
print( "Warning: No argument passed for parameter '"..theArgName.."'; setting to Roots.nil" )
end
context[ theArgName ] = Roots['nil']
Expand Down
4 changes: 2 additions & 2 deletions core/expression.lua
Expand Up @@ -15,14 +15,14 @@ Roots.Expression.eval = createLuaFunc( 'evalContext', 'receiver', function( cont
-- Expressions explicitly created (Expression new) have a creationContext
if context.evalContext == Roots['nil'] then
context.evalContext = context.self.creationContext
if arg.debugLevel and arg.debugLevel >= 2 then
if arg.debugLevel >= 2 then
print( "No explicit context for Expression#eval; using "..tostring(context.evalContext) )
end

-- As a fallback, evaluate the expression in the context eval was called in
if context.evalContext == Roots['nil'] then
context.evalContext = context.callState.callingContext
if arg.debugLevel and arg.debugLevel >= 2 then
if arg.debugLevel >= 2 then
print( "...and no creationContext, either; using "..tostring(evalContext) )
end
end
Expand Down
7 changes: 6 additions & 1 deletion mab
Expand Up @@ -17,6 +17,10 @@ if not arg.sourcefile then
arg.interactive = true
end

if not arg.debugLevel then
arg.debugLevel = 0
end

USAGE = [[
Usage: mab [-h] [-e] [-d debugLevel] [-p] [-i] [sourcefile.mab]
-h,--help show this usage message
Expand All @@ -29,6 +33,7 @@ Usage: mab [-h] [-e] [-d debugLevel] [-p] [-i] [sourcefile.mab]
4 = ...plus trivial notes
-p,--profile show profile statistics after running the code
-i,--interactive enter interactive mode (read/evaluate/print loop)
automatically enabled if no source file is supplied
]]

EXAMPLES = [[
Expand Down Expand Up @@ -81,7 +86,7 @@ if arg.sourcefile then
Lawn.program = parser.parse( code )
LastParsedObjectIndex = #runtime.ObjectById

-- if arg.debugLevel and arg.debugLevel >= 3 then
-- if arg.debugLevel >= 3 then
-- print( "Parsed program tree:" )
-- core.printObjectAsXML( Lawn.program )
-- end
Expand Down
2 changes: 1 addition & 1 deletion parser.lua
Expand Up @@ -111,7 +111,7 @@ end )
function runString( code )
local Lawn = core.Roots.Lawn
Lawn.program = parser.parse( code )
if arg.debugLevel and arg.debugLevel >= 3 then
if arg.debugLevel >= 3 then
print( "Parsed program tree:" )
core.printObjectAsXML( Lawn.program )
end
Expand Down
2 changes: 1 addition & 1 deletion runtime.lua
Expand Up @@ -25,7 +25,7 @@ function childFrom( parentObject, name )
end
local object = blank( name )
addInheritance( object, parentObject )
if arg.debugLevel and arg.debugLevel >= 4 and parentObject.__name then
if arg.debugLevel >= 4 and parentObject.__name then
print( "Created "..luastring[parentObject.__name].." #"..ObjectId[object] )
end
return object
Expand Down

0 comments on commit e253258

Please sign in to comment.