コード例 #1
0
ファイル: GetIndexBinder.cs プロジェクト: jeffpanici75/Tsuki
 public GetIndexBinder(
     StaticMetaTables metaTables,
     CallInfo callInfo)
     : base(callInfo)
 {
     _metaTables = metaTables;
 }
コード例 #2
0
ファイル: MetaTable.cs プロジェクト: jeffpanici75/Tsuki
        public static Table GetMetaTable(StaticMetaTables metaTables, object o)
        {
            if (o == null)
                return null;

            var table = o as Table;

            if (table != null)
                return table.MetaTable;

            if (metaTables == null)
                return null;

            if (o is string)
                return metaTables.String;

            if (o is int
                || o is double
                || o is long
                || o is Int16
                || o is decimal)
                return metaTables.Numeric;

            if (TypeHelper.IsCallable(o))
                return metaTables.Function;

            if (o is Thread)
                return metaTables.Thread;

            if (o is Boolean)
                return metaTables.Boolean;

            return null;
        }
コード例 #3
0
ファイル: Chunk.cs プロジェクト: jeffpanici75/Tsuki
        public static LuaResult Compile(
            StaticMetaTables staticTables,
            string source,
            dynamic globals = null,
            string name = null)
        {
            var result = new LuaResult();
            var stopwatch = new Stopwatch();
            stopwatch.Start();
            try
            {
                var stream = new ANTLRStringStream(source);
                var lexer = new ChunkLexer(stream);
                var tokenStream = new CommonTokenStream(lexer);
                var parser = new ChunkParser(tokenStream);

                var r = parser.chunk();
                result.Errors.AddRange(parser.Errors);

                Expression e;
                var scope = Scope.NewTopLevelScop();
                var chunk = new Chunk();
                result.Errors.AddRange(chunk.Generate(staticTables, scope, r.Tree, out e));

                var fnExp = Expression.Lambda<Func<Table, object>>(e, scope.Env.GlobalParameter);
                result.Chunk = new CompiledChunk(fnExp.Compile(), globals ?? new Table(), name);
            }
            finally
            {
                stopwatch.Stop();
                result.ElapsedTime = stopwatch.Elapsed;
                result.Success = !result.Errors.ContainsError();
            }
            return result;
        }
コード例 #4
0
 public HiddenStatefulBasicFunctions(
     LuaRuntime runtime, 
     StaticMetaTables metaTables)
 {
     _runtime = runtime;
     _metaTables = metaTables;
 }
コード例 #5
0
 public CompareOperationBinder(
     StaticMetaTables metaTables,
     ExpressionType operation)
     : base(operation)
 {
     _metaTables = metaTables;
 }
コード例 #6
0
 public static InvokeMemberBinder New(
     StaticMetaTables metaTables, 
     string name, 
     CallInfo info)
 {
     return new InvokeMemberBinder(metaTables, name, info);
 }
コード例 #7
0
ファイル: LuaRuntime.cs プロジェクト: jeffpanici75/Tsuki
        public LuaRuntime(Table environment = null)
        {
            if (environment != null)
                _environment = environment;

            StaticMetaTables = new StaticMetaTables();
        }
コード例 #8
0
 public InvokeMemberBinder(
     StaticMetaTables metaTables, 
     string name, 
     CallInfo callInfo)
     : base(name, false, callInfo)
 {
     _metaTables = metaTables;
 }
コード例 #9
0
 public LessThanOrEqualBinder(StaticMetaTables metaTables)
     : base(ExpressionType.LessThanOrEqual)
 {
     _metaTables = metaTables;
     _info = typeof (Compare).GetMethod("ApplyLessThanOrEqual");
 }
コード例 #10
0
 public static void ImportStatefulBasicFunctions(
     this Table t,
     LuaRuntime runtime,
     StaticMetaTables st)
 {
     LuaExportAttribute.AssignExportedFunctions(
         typeof (HiddenStatefulBasicFunctions),
         t,
         new HiddenStatefulBasicFunctions(runtime, st));
 }
コード例 #11
0
ファイル: LessThanBinder.cs プロジェクト: jeffpanici75/Tsuki
 public static LessThanBinder New(StaticMetaTables st)
 {
     return new LessThanBinder(st);
 }
コード例 #12
0
 public static NumericOperationBinder New(StaticMetaTables metaTables, ExpressionType op)
 {
     return new NumericOperationBinder(metaTables, op);
 }
コード例 #13
0
 public NumericOperationBinder(StaticMetaTables metaTables, ExpressionType operation)
     : base(operation)
 {
     _metaTables = metaTables;
 }
コード例 #14
0
 public static EqualityOperationBinder New(StaticMetaTables metaTables)
 {
     return new EqualityOperationBinder(metaTables);
 }
コード例 #15
0
ファイル: LengthBinder.cs プロジェクト: jeffpanici75/Tsuki
 public static LengthBinder New(StaticMetaTables metaTables)
 {
     return new LengthBinder(metaTables);
 }
コード例 #16
0
 public static LessThanOrEqualBinder New(StaticMetaTables metaTables)
 {
     return new LessThanOrEqualBinder(metaTables);
 }
コード例 #17
0
 public static CompareOperationBinder New(StaticMetaTables st, ExpressionType op)
 {
     return new CompareOperationBinder(st, op);
 }
コード例 #18
0
ファイル: GetIndexBinder.cs プロジェクト: jeffpanici75/Tsuki
 public static GetIndexBinder New(StaticMetaTables metaTables, CallInfo info)
 {
     return new GetIndexBinder(metaTables, info);
 }
コード例 #19
0
 public EqualityOperationBinder(StaticMetaTables metaTables)
     : base(ExpressionType.Equal)
 {
     _metaTables = metaTables;
     _info = typeof (Compare).GetMethod("ApplyEqualBool");
 }
コード例 #20
0
ファイル: LengthBinder.cs プロジェクト: jeffpanici75/Tsuki
 public LengthBinder(StaticMetaTables metaTables)
 {
     _metaTables = metaTables;
 }