Exemple #1
0
 public GetIndexBinder(
     StaticMetaTables metaTables,
     CallInfo callInfo)
     : base(callInfo)
 {
     _metaTables = metaTables;
 }
Exemple #2
0
        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;
        }
Exemple #3
0
        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;
        }
 public HiddenStatefulBasicFunctions(
     LuaRuntime runtime, 
     StaticMetaTables metaTables)
 {
     _runtime = runtime;
     _metaTables = metaTables;
 }
 public CompareOperationBinder(
     StaticMetaTables metaTables,
     ExpressionType operation)
     : base(operation)
 {
     _metaTables = metaTables;
 }
 public static InvokeMemberBinder New(
     StaticMetaTables metaTables, 
     string name, 
     CallInfo info)
 {
     return new InvokeMemberBinder(metaTables, name, info);
 }
Exemple #7
0
        public LuaRuntime(Table environment = null)
        {
            if (environment != null)
                _environment = environment;

            StaticMetaTables = new StaticMetaTables();
        }
 public InvokeMemberBinder(
     StaticMetaTables metaTables, 
     string name, 
     CallInfo callInfo)
     : base(name, false, callInfo)
 {
     _metaTables = metaTables;
 }
 public LessThanOrEqualBinder(StaticMetaTables metaTables)
     : base(ExpressionType.LessThanOrEqual)
 {
     _metaTables = metaTables;
     _info = typeof (Compare).GetMethod("ApplyLessThanOrEqual");
 }
 public static void ImportStatefulBasicFunctions(
     this Table t,
     LuaRuntime runtime,
     StaticMetaTables st)
 {
     LuaExportAttribute.AssignExportedFunctions(
         typeof (HiddenStatefulBasicFunctions),
         t,
         new HiddenStatefulBasicFunctions(runtime, st));
 }
Exemple #11
0
 public static LessThanBinder New(StaticMetaTables st)
 {
     return new LessThanBinder(st);
 }
 public static NumericOperationBinder New(StaticMetaTables metaTables, ExpressionType op)
 {
     return new NumericOperationBinder(metaTables, op);
 }
 public NumericOperationBinder(StaticMetaTables metaTables, ExpressionType operation)
     : base(operation)
 {
     _metaTables = metaTables;
 }
 public static EqualityOperationBinder New(StaticMetaTables metaTables)
 {
     return new EqualityOperationBinder(metaTables);
 }
Exemple #15
0
 public static LengthBinder New(StaticMetaTables metaTables)
 {
     return new LengthBinder(metaTables);
 }
 public static LessThanOrEqualBinder New(StaticMetaTables metaTables)
 {
     return new LessThanOrEqualBinder(metaTables);
 }
 public static CompareOperationBinder New(StaticMetaTables st, ExpressionType op)
 {
     return new CompareOperationBinder(st, op);
 }
Exemple #18
0
 public static GetIndexBinder New(StaticMetaTables metaTables, CallInfo info)
 {
     return new GetIndexBinder(metaTables, info);
 }
 public EqualityOperationBinder(StaticMetaTables metaTables)
     : base(ExpressionType.Equal)
 {
     _metaTables = metaTables;
     _info = typeof (Compare).GetMethod("ApplyEqualBool");
 }
Exemple #20
0
 public LengthBinder(StaticMetaTables metaTables)
 {
     _metaTables = metaTables;
 }