Examples of ICallableValue


Examples of org.rascalmpl.interpreter.result.ICallableValue

   
    Result<IValue> var = env.getVariable("amb");
   
    if (var != null && var instanceof ICallableValue) {
      Type type = RascalTypeFactory.getInstance().nonTerminalType(ambCluster);
      ICallableValue func = (ICallableValue) var;
      try {
        Result<IValue> result = func.call(
            new Type[] {TF.setType(type)}, new IValue[] {alts}, null
        );
       
        if (result.getType().isBottom()) {
          return ambCluster;
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

    if (cons != null) {
      Environment env = (Environment) environment;
      Result<IValue> var = env.getVariable(cons);
     
      if (var != null && var instanceof ICallableValue) {
        ICallableValue function = (ICallableValue) var;
       
       
        try{
          Result<IValue> result = null;
          if(TreeAdapter.isContextFree(tree)){
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

  public void setGenerator(IValue f) {
    FunctionType functionType = (FunctionType) f.getType();
    Type returnType = functionType.getReturnType();

    ICallableValue generator = (ICallableValue) f;

    generators.put(returnType, generator);
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

    checkCursorness("first", cursor);
    checkUnaryFunction("second", to);
    checkUnaryFunction("third", from);
    ICursor c = (ICursor)cursor;
    Context ctx = new InvertorContext(c.getCtx(), (ICallableValue)from);
    ICallableValue f = (ICallableValue)to;
    IValue computed = f.call(new Type[] {c.getWrappedValue().getType()}, new IValue[] { c.getWrappedValue() }, null).getValue();
    return CursorFactory.makeCursor(computed, ctx);
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

     
      String moduleName = Names.fullName(this.getName());
      IString mn = this.VF.string(moduleName);
     
      // Using the scheme, get back the correct importer
      ICallableValue importer = getImporter(resourceScheme, eval.getCurrentEnvt());
     
      if (importer != null) {
        Type[] argTypes = new org.eclipse.imp.pdb.facts.type.Type[] {TF.stringType(), TF.sourceLocationType()};
        IValue[] argValues = new IValue[] { mn, sl };
       
        // Invoke the importer, which should generate the text of the module that we need
        // to actually import.
        IValue module = importer.call(argTypes, argValues, null).getValue();
        String moduleText = module.getType().isString() ? ((IString) module).getValue() : TreeAdapter.yield((IConstructor) module);
       
        moduleText = "@generated\n" + moduleText;
       
        try {
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

    if (depthLimit < 0) {
      return null;
    }
    TypeFactory tf = TypeFactory.getInstance();

    ICallableValue generator = generators.get(type);
    Result<IValue> result = generator.call(new Type[] { tf.integerType() },
        new IValue[] { vf.integer(depthLimit) }, null);
    return result.getValue();
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

  public void serve(ISourceLocation url, final IValue callback, final IEvaluatorContext ctx) {
        URI uri = url.getURI();
    int port = uri.getPort() != -1 ? uri.getPort() : 80;
    String host = uri.getHost() != null ? uri.getHost() : "localhost";
    final ICallableValue callee = (ICallableValue) callback;
   
    NanoHTTPD server = new NanoHTTPD(host, port) {
     

      @Override
      public Response serve(String uri, Method method, Map<String, String> headers, Map<String, String> parms,
          Map<String, String> files) {
        IConstructor methodVal = makeMethod(method);
        IMap headersVal = makeMap(headers);
        IMap paramsVal= makeMap(parms);
        IMap filesVal= makeMap(files);
        ISourceLocation loc = vf.sourceLocation(URIUtil.assumeCorrect("request", "", uri));
        try {
          synchronized (callee.getEval()) {
            callee.getEval().__setInterrupt(false);
            Result<IValue> response = callee.call(argTypes, new IValue[] { loc, methodVal, headersVal, paramsVal, filesVal }, null);
            return translateResponse(method, response.getValue())
          }
        }
        catch (Throw rascalException) {
          ctx.getStdErr().println(rascalException.getMessage());
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

 
  public ISourceLocation resolveSourceLocation(ISourceLocation loc) {
    String scheme = loc.getURI().getScheme();
    int pos;
   
    ICallableValue resolver = sourceResolvers.get(scheme);
    if (resolver == null) {
      for (char sep : new char[] {'+',':'}) {
        pos = scheme.indexOf(sep);
        if (pos != -1) {
          scheme = scheme.substring(0, pos);
        }
      }

      resolver = sourceResolvers.get(scheme);
      if (resolver == null) {
        return loc;
      }
    }
   
    Type[] argTypes = new Type[] { TypeFactory.getInstance().sourceLocationType() };
    IValue[] argValues = new IValue[] { loc };
   
    return (ISourceLocation) resolver.call(argTypes, argValues, null).getValue();
  }
View Full Code Here

Examples of org.rascalmpl.interpreter.result.ICallableValue

 
  public ISourceLocation resolveSourceLocation(ISourceLocation loc) {
    String scheme = loc.getURI().getScheme();
    int pos;
   
    ICallableValue resolver = sourceResolvers.get(scheme);
    if (resolver == null) {
      for (char sep : new char[] {'+',':'}) {
        pos = scheme.indexOf(sep);
        if (pos != -1) {
          scheme = scheme.substring(0, pos);
        }
      }

      resolver = sourceResolvers.get(scheme);
      if (resolver == null) {
        return loc;
      }
    }
   
    Type[] argTypes = new Type[] { TypeFactory.getInstance().sourceLocationType() };
    IValue[] argValues = new IValue[] { loc };
   
    return (ISourceLocation) resolver.call(argTypes, argValues, null).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.