Package org.luaj.vm2

Examples of org.luaj.vm2.LuaClosure


import java.io.IOException;

public class ModuleExecutor {
    public String run(IWikiModel model, String module, String method, Frame frame) throws IOException {
        final Globals globals = getGlobals();
        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }
View Full Code Here


        MwCommon common = new MwCommon(model, globals);
        return common.execute(module, method, frame);
    }

    private Globals getGlobals() {
        final Globals globals = JsePlatform.standardGlobals();
//        LuaJC.install(globals);
        return globals;
    }
View Full Code Here

    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

    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

    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

    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

  }
 
  /** 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

  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

            // 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

          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

TOP

Related Classes of org.luaj.vm2.LuaClosure

Copyright © 2018 www.massapicom. 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.