Examples of LuaClosure


Examples of org.luaj.vm2.LuaClosure

    if (packageLib.loaded.get(packageName).toboolean()) {
      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    packageLib.loaded.set(packageName, globals);
  }
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

    if (loadedTable.get(packageName).toboolean()) {
      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    loadedTable.set(packageName, LuaValue.TRUE);
  }
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

    if (loadedTable.get(packageName).toboolean()) {
      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    loadedTable.set(packageName, LuaValue.TRUE);
  }
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

    if (loadedTable.get(packageName).toboolean()) {
      return;
    }
   
    Prototype prototype = LuaCache.loadPackage(packageName, system);
    LuaClosure function = new LuaClosure(prototype, globals);
    function.invoke();
   
    loadedTable.set(packageName, LuaValue.TRUE);
  }
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

  }
 
  /** Load into a Closure or LuaFunction, with the supplied initial environment */
  public LuaFunction load(InputStream stream, String name, LuaValue env) throws IOException {
    Prototype p = compile( stream, name );
    return new LuaClosure( p, env );
  }
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

  public String pushfstring(String string) {
    return string;
  }

  public LuaFunction load(Prototype p, String filename, LuaValue env) {
    return new LuaClosure( p, env );
  }
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

            // compile into prototype
            InputStream is = new ByteArrayInputStream(script.getBytes());
            Prototype p = LuaC.instance.compile(is, "script");
           
            // double check script result before dumping
            LuaFunction f = new LuaClosure(p, _G);
            LuaValue r = f.call();
            String actual = r.tojstring();
            assertEquals( expectedPriorDump, actual );
           
            // dump into bytes
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                DumpState.dump(p, baos, stripDebug, numberFormat, littleEndian);
              if ( ! shouldPass )
                fail( "dump should not have succeeded" );
            } catch ( Exception e ) {
              if ( shouldPass )
                fail( "dump threw "+e );
              else
                return;
            }
            byte[] dumped = baos.toByteArray();
           
            // load again using compiler
            is = new ByteArrayInputStream(dumped);
            f = LoadState.load(is, "dumped", _G);
            r = f.call();
            actual = r.tojstring();
            assertEquals( expectedPostDump, actual );

            // write test chunk
            if ( System.getProperty(SAVECHUNKS) != null && script.equals(mixedscript) ) {
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

          if ( f.isclosure() ) {
            // most compiled functions are closures with prototypes
            final Prototype p = f.checkclosure().p;
          return new CompiledScriptImpl() {
            protected LuaFunction newFunctionInstance() {
              return new LuaClosure( p, null );
            }
          };
          } else {
            // when luajc is used, functions are java class instances
            final Class c = f.getClass();
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

    if ( di == null )
      return NIL;

    // start a table
    LuaTable info = new LuaTable();
    LuaClosure c = di.closure;
    for (int i = 0, j = what.length(); i < j; i++) {
      switch (what.charAt(i)) {
        case 'S': {
          if ( c != null ) {
            Prototype p = c.p;
View Full Code Here

Examples of org.luaj.vm2.LuaClosure

  static Varargs _getupvalue(Varargs args) {
    LuaValue func = args.checkfunction(1);
    int up = args.checkint(2);
    if ( func instanceof LuaClosure ) {
      LuaClosure c = (LuaClosure) func;
      LuaString name = findupvalue(c, up);
      if ( name != null ) {
        return varargsOf(name, c.upValues[up-1].getValue() );
      }
    }
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.