Package sisc

Examples of sisc.Interpreter


    parser.parse(input);

    SchemeInterpreter interpreters
      = (SchemeInterpreter)manager.lookup(SchemeInterpreter.ROLE);
    Symbol mainFunction = interpreters.getMainFunction();
    Interpreter interp = interpreters.getInterpreter();

    try {
      return interp.eval(handler.getContent());
    }
    finally {
      interpreters.releaseInterpreter(interp);
    }
  }
View Full Code Here


    J2S.JavaObject ssource = new J2S.JavaObject(sitemapSource);
    Value[] args = new Value[] { ssitemap, sManager, ssource };

    SchemeInterpreter interpreters
      = (SchemeInterpreter)manager.lookup(SchemeInterpreter.ROLE);
    Interpreter interp = interpreters.getInterpreter();
    Symbol sitemapParseFunction = interpreters.getSitemapParseFunction();

    try {
      interp.eval((Procedure)interp.ctx.toplevel_env.lookup(sitemapParseFunction),
                  args);
    }
    finally {
      interpreters.releaseInterpreter(interp);
    }
View Full Code Here

    ImmutableString servletPath = new ImmutableString(requestedURI);
    Value[] args = new Value[] {servletPath, ssitemap, senv};

    SchemeInterpreter interpreters
      = (SchemeInterpreter)manager.lookup(SchemeInterpreter.ROLE);
    Interpreter interp = interpreters.getInterpreter();
    Symbol mainFunction = interpreters.getMainFunction();
    Value result = sisc.Util.FALSE;

    try {
      result
        = interp.eval((Procedure)interp.ctx.toplevel_env.lookup(mainFunction),
                      args);
    }
    finally {
      interpreters.releaseInterpreter(interp);
    }
View Full Code Here

      if (siscContext == null) {
        siscContext = new AppContext();
        httpContext.setAttribute(REPLGenericServlet.appCtxAttrName, siscContext);

        interPool = new ArrayList();
        Interpreter interp = getInterpreter();

        try {
          org.apache.cocoon.environment.Context context =
            (org.apache.cocoon.environment.Context)cocoonContext.get(Constants.CONTEXT_ENVIRONMENT_CONTEXT);
View Full Code Here

        return (Interpreter)interPool.remove(size - 1);
    }

    // Create a new interpreter and return it
    DynamicEnv environment = new DynamicEnv(System.in, System.out);
    Interpreter interp = new Interpreter(siscContext, environment);
    return interp;
  }
View Full Code Here

  {
    super.init(config);
    servletContext = config.getServletContext();
    interPool = new Stack();

    Interpreter interp;

    synchronized (servletContext) {
      AppContext ctx = (AppContext)servletContext.getAttribute(appCtxAttrName);

      if (ctx == null) {
        ctx = new AppContext();
        servletContext.setAttribute(appCtxAttrName, ctx);

        interp = getInterpreter();
        // Read the heap file
        String realPath = servletContext.getRealPath("/");
        String heapFileName = realPath + config.getInitParameter("heap");
        System.out.println("loading heap " + heapFileName);
        File heapFile = new File(heapFileName);

        try {
          FileInputStream fis = new FileInputStream(heapFileName);
          BufferedInputStream bis
            = new BufferedInputStream(fis, (int)heapFile.length());
          GZIPInputStream gzis = new GZIPInputStream(bis);
          DataInputStream dis
            = new DataInputStream(new BufferedInputStream(gzis));
          ctx.loadEnv(interp, dis);
     
        } catch (IOException ex) {
          System.err.println("Error loading heap:" + ex);
          ex.printStackTrace();
          throw new ServletException(ex);
        }

        ctx.setEvaluator("eval");
      }
      else {
        interp = getInterpreter();
      }     
    }

    initExpression = config.getInitParameter("init-expression");
    destroyExpression = config.getInitParameter("destroy-expression");
    String main = config.getInitParameter("main-function");
    if (main != null)
      mainFunction = Symbol.get(main);
//         = new FreeReferenceExp(Symbol.get(main), -1, interp.ctx.toplevel_env);

    // Evaluate the init expression, discard the returned value and
    // any exception thrown
    try {
      if (initExpression != null && !initExpression.equals(""))
        interp.eval(initExpression);
    }
    catch (Exception ex) {
      System.out.println("Exception evaluating the init expression: " + ex);
    }
View Full Code Here

        return (Interpreter)interPool.pop();

      // Create a new interpreter and return it
      AppContext ctx = (AppContext)servletContext.getAttribute(appCtxAttrName);
      DynamicEnv environment = new DynamicEnv(System.in, System.out);
      Interpreter interp = new Interpreter(ctx, environment);
      return interp;
    }
  }
View Full Code Here

        sbuf.append(buffer, 0, len);
      }

      System.out.println("executing '" + sbuf + "'");

      Interpreter interp = getInterpreter();
      out.println(interp.eval(sbuf.toString()));
      releaseInterpreter(interp);
    }
    catch (Exception ex) {
      out.println("ERROR: " + ex);
      throw new ServletException(ex);
View Full Code Here

    J2S.JavaObject ssource = new J2S.JavaObject(sitemapSource);
    Value[] args = new Value[] { sManager, ssource };

    SchemeInterpreter interpreters
      = (SchemeInterpreter)manager.lookup(SchemeInterpreter.ROLE);
    Interpreter interp = interpreters.getInterpreter();
    Symbol sitemapParseFunction = interpreters.getSitemapParseFunction();

    try {
      interp.eval((Procedure)interp.ctx.toplevel_env.lookup(sitemapParseFunction),
                  args);
    }
    finally {
      interpreters.releaseInterpreter(interp);
    }
View Full Code Here

    ImmutableString servletPath = new ImmutableString(requestedURI);
    Value[] args = new Value[] {servletPath, ssitemap, senv};

    SchemeInterpreter interpreters
      = (SchemeInterpreter)manager.lookup(SchemeInterpreter.ROLE);
    Interpreter interp = interpreters.getInterpreter();
    Symbol mainFunction = interpreters.getMainFunction();
    Value result = sisc.Util.FALSE;

    try {
      result
        = interp.eval((Procedure)interp.ctx.toplevel_env.lookup(mainFunction),
                      args);
    }
    finally {
      interpreters.releaseInterpreter(interp);
    }
View Full Code Here

TOP

Related Classes of sisc.Interpreter

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.