|
using System;
using System.Collections.Generic;
using System.Text;
namespace Language.Lua
{
public partial class FunctionCall : Access
{
public override LuaValue Evaluate(LuaValue baseValue, LuaTable enviroment)
{
LuaFunction function = baseValue as LuaFunction;
if (function != null)
{
if (function.Function.Method.DeclaringType.FullName == "Language.Lua.Library.BaseLib" &&
(function.Function.Method.Name == "loadstring" || function.Function.Method.Name == "dofile"))
{
if (this.Args.String != null)
{
return function.Function.Invoke(new LuaValue[] { this.Args.String.Evaluate(enviroment), enviroment });
}
else
{
return function.Function.Invoke(new LuaValue[] { this.Args.ArgList[0].Evaluate(enviroment), enviroment });
}
}
if (this.Args.Table != null)
{
return function.Function.Invoke(new LuaValue[] { this.Args.Table.Evaluate(enviroment) });
}
else if (this.Args.String != null)
{
return function.Function.Invoke(new LuaValue[] { this.Args.String.Evaluate(enviroment) });
}
else
{
List<LuaValue> args = this.Args.ArgList.ConvertAll(arg => arg.Evaluate(enviroment));
return function.Function.Invoke(LuaMultiValue.UnWrapLuaValues(args.ToArray()));
}
}
else
{
throw new Exception("Invoke function call on non function value.");
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.