Examples of IConstructor


Examples of org.eclipse.imp.pdb.facts.IConstructor

    // enum constant declaration and classinstancecreation gives types for anonymousclasses
    ASTNode parent = node.getParent();
    if (parent instanceof ClassInstanceCreation) {
      ISourceLocation superclass = resolveBinding(((ClassInstanceCreation) parent).getType());
      insert(typeDependency, ownValue, superclass);
      IConstructor type = bindingsResolver.resolveType(((ClassInstanceCreation) parent).getType().resolveBinding(), false);
        insert(types, ownValue, type);
       
        if (!superclass.getScheme().contains("+interface")) {
          insert(extendsRelations, ownValue, superclass);
        }
        else {
          insert(implementsRelations, ownValue, superclass);
        }
    }
    else if (parent instanceof EnumConstantDeclaration) {
      insert(typeDependency, ownValue, resolveBinding(((EnumConstantDeclaration) parent).resolveVariable()));
      IConstructor type = bindingsResolver.resolveType(((EnumConstantDeclaration) parent).resolveVariable().getType(), false);
        insert(types, ownValue, type);
    }
    insert(declarations, ownValue, getSourceLocation(node));
    scopeManager.push((ISourceLocation) ownValue);
    return true;
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

    ownValue = scopeManager.pop();
    computeTypeSymbol(node);
  }

  private void computeTypeSymbol(AbstractTypeDeclaration node) {
    IConstructor type = bindingsResolver.resolveType(node.resolveBinding(), true);
    insert(types, ownValue, type);
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

    }
    else if (parent instanceof AnonymousClassDeclaration) {
      fillOverrides(node.resolveBinding(), ((AnonymousClassDeclaration)parent).resolveBinding());
    }
   
    IConstructor type = bindingsResolver.resolveType(node.resolveBinding(), true);
    insert(types, ownValue, type);
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

    return true;
  }
 
  public void endVisit(SingleVariableDeclaration node) {
    ownValue = scopeManager.pop();
      IConstructor type = bindingsResolver.resolveType(node.getType().resolveBinding(), false);
        insert(types, ownValue, type);
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

    insert(containment, getParent(), ownValue);
    scopeManager.push((ISourceLocation) ownValue);
    IVariableBinding binding = node.resolveBinding();
   
    if (binding != null) {
      IConstructor type = bindingsResolver.resolveType(binding.getType(), false);
      insert(types, ownValue, type);
    }
    else {
      insert(messages, values.constructor(DATATYPE_RASCAL_MESSAGE_ERROR_NODE_TYPE,
          values.string("No binding for: " + node),
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

     

      @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());
          return new Response(Status.INTERNAL_ERROR, "text/plain", rascalException.getMessage());
        }
        catch (Throwable unexpected) {
          ctx.getStdErr().println(unexpected.getMessage());
          unexpected.printStackTrace(ctx.getStdErr());
          return new Response(Status.INTERNAL_ERROR, "text/plain", unexpected.getMessage());
        }
      }

      private Response translateResponse(Method method, IValue value) {
        IConstructor cons = (IConstructor) value;
        initMethodAndStatusValues(ctx);
       
        if (cons.getName().equals("fileResponse")) {
          return translateFileResponse(method, cons);
        }
        else {
          return translateTextResponse(method, cons);
        }
      }
     
      private Response translateFileResponse(Method method, IConstructor cons) {
        ISourceLocation l = (ISourceLocation) cons.get("file");
        IString mimeType = (IString) cons.get("mimeType");
        IMap header = (IMap) cons.get("header");
        URI uri = l.getURI();
       
        Response response;
        try {
          response = new Response(Status.OK, mimeType.getValue(), ctx.getResolverRegistry().getInputStream(uri));
          addHeaders(response, header);
          return response;
        } catch (IOException e) {
          e.printStackTrace(ctx.getStdErr());
          return new Response(Status.NOT_FOUND, "text/plain", l + " not found.\n" + e);
        }
      }

      private Response translateTextResponse(Method method, IConstructor cons) {
        IString mimeType = (IString) cons.get("mimeType");
        IMap header = (IMap) cons.get("header");
        IString data = (IString) cons.get("content");
        Status status = translateStatus((IConstructor) cons.get("status"));
       
        if (method != Method.HEAD) {
          switch (status) {
          case BAD_REQUEST:
          case UNAUTHORIZED:
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

      if (!nonDefault && !func.isDefault()) {
        continue;
      }

      String label = null;
      IConstructor prod = null;

      if (func.isPatternDispatched()) {
        // this one is already hashed, but we might find more to add to that map in the next round
        Map<String, List<AbstractFunction>> funcMap = ((AbstractPatternDispatchedFunction) func).getMap();
        for (String key : funcMap.keySet()) {
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

  public IValue visitAbstractData(Type type) {
    LinkedList<Type> alternatives = new LinkedList<Type>();
    alternatives.addAll(this.rootEnv.lookupAlternatives(type));
    Collections.shuffle(alternatives);
    for (Type pick : alternatives) {
      IConstructor result = (IConstructor) this.generate(pick);
      if (result != null) {
        RandomValueTypeVisitor visitor = descend();
        Map<String, Type> annotations = rootEnv.getStore()
            .getAnnotations(type);
        for (Map.Entry<String, Type> entry : annotations.entrySet()) {
          IValue value = visitor.generate(entry.getValue());
          if (value == null) {
            return null;

          }
          result = result.asAnnotatable().setAnnotation(entry.getKey(), value);
        }

        return result;

      }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

    }
    return "";
  }
 
  private static Module buildModule(String name, ModuleEnvironment env,  IEvaluator<Result<IValue>> eval) throws IOException {
    IConstructor tree = eval.parseModule(eval, URIUtil.createRascalModule(name));
    return getBuilder().buildModule(tree);
  }
View Full Code Here

Examples of org.eclipse.imp.pdb.facts.IConstructor

    try {
      eval.startJob("Parsing " + location, 10);
      eval.event("initial parse");

      IConstructor tree = new RascalParser().parse(Parser.START_MODULE, location, data, actions, new DefaultNodeFlattener<IConstructor, IConstructor, ISourceLocation>(), new UPTRNodeFactory());

      if (TreeAdapter.isAmb(tree)) {
        // Ambiguity is dealt with elsewhere
        return tree;
      }

      IConstructor top = TreeAdapter.getStartTop(tree);

      String name = Modules.getName(top);

      // create the current module if it does not exist yet
      GlobalEnvironment heap = eval.getHeap();
      ModuleEnvironment env = heap.getModule(name);
      if(env == null){
        env = new ModuleEnvironment(name, heap);
        // do not add the module to the heap here.
      }
      env.setBootstrap(needBootstrapParser(data));

      // make sure all the imported and extended modules are loaded
      // since they may provide additional syntax definitions\
      Environment old = eval.getCurrentEnvt();
      try {
        eval.setCurrentEnvt(env);
        env.setInitialized(true);

        eval.event("defining syntax");
        ISet rules = Modules.getSyntax(top);
        for (IValue rule : rules) {
          evalImport(eval, (IConstructor) rule);
        }

        eval.event("importing modules");
        ISet imports = Modules.getImports(top);
        for (IValue mod : imports) {
          evalImport(eval, (IConstructor) mod);
        }

        eval.event("extending modules");
        ISet extend = Modules.getExtends(top);
        for (IValue mod : extend) {
          evalImport(eval, (IConstructor) mod);
        }

        eval.event("generating modules");
        ISet externals = Modules.getExternals(top);
        for (IValue mod : externals) {
          evalImport(eval, (IConstructor) mod);
        }
      }
      finally {
        eval.setCurrentEnvt(old);
      }

      // parse the embedded concrete syntax fragments of the current module
      IConstructor result = tree;
      if (!eval.getHeap().isBootstrapper() && (needBootstrapParser(data) || (env.definesSyntax() && containsBackTick(data, 0)))) {
        eval.event("parsing concrete syntax");
        result = parseFragments(eval, tree, location, env);
      }
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.