Package org.luaj.vm2

Examples of org.luaj.vm2.LuaValue.type()


    final LuaValue[] k = f.k;
    int i, n = k.length;
    dumpInt(n);
    for (i = 0; i < n; i++) {
      final LuaValue o = k[i];
      switch ( o.type() ) {
      case LuaValue.TNIL:
        writer.write(LuaValue.TNIL);
        break;
      case LuaValue.TBOOLEAN:
        writer.write(LuaValue.TBOOLEAN);
View Full Code Here


    {
      LuaThread t = new LuaThread(new LuaClosure(p2,_G), _G);
      Varargs v = t.resume(LuaValue.NONE);
      assertEquals(LuaValue.TRUE, v.arg(1) );
      LuaValue f = v.arg(2);
      assertEquals( LuaValue.TFUNCTION, f.type() );
      assertEquals( aaa, f.call() );
      assertEquals( _G, f.getfenv() );
    }
    {
      // change the thread environment after creation!
View Full Code Here

      LuaThread t = new LuaThread(new LuaClosure(p2,_G), _G);
      t.setfenv(newenv);
      Varargs v = t.resume(LuaValue.NONE);
      assertEquals(LuaValue.TRUE, v.arg(1) );
      LuaValue f = v.arg(2);
      assertEquals( LuaValue.TFUNCTION, f.type() );
      assertEquals( eee, f.call() );
      assertEquals( newenv, f.getfenv() );
    }
    {
      // let the closure have a different environment from the thread
View Full Code Here

      Prototype p3 = createPrototype( "return function() return a end", "envtester" );
      LuaThread t = new LuaThread(new LuaClosure(p3,newenv), _G);
      Varargs v = t.resume(LuaValue.NONE);
      assertEquals(LuaValue.TRUE, v.arg(1) );
      LuaValue f = v.arg(2);
      assertEquals( LuaValue.TFUNCTION, f.type() );
      assertEquals( eee, f.call() );
      assertEquals( newenv, f.getfenv() );
    }
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.