コード例 #1
0
  @Override
  public <U extends IValue> Result<U> fieldAccess(String name, TypeStore store) {
    IConstructor tree = getValue();

    if (TreeAdapter.isAppl(tree)) {
      int found = -1;
      IConstructor foundType = null;
      IConstructor prod = TreeAdapter.getProduction(tree);

      if (!ProductionAdapter.isRegular(prod)) {
        IList syms = ProductionAdapter.getSymbols(prod);

        // TODO: find deeper into optionals, checking the actual arguments for presence/absence of
        // optional trees.
        for (int i = 0; i < syms.length(); i++) {
          IConstructor sym = (IConstructor) syms.get(i);

          while (SymbolAdapter.isConditional(sym)) {
            sym = SymbolAdapter.getSymbol(sym);
          }
          if (SymbolAdapter.isLabel(sym)) {
            if (SymbolAdapter.getLabel(sym).equals(name)) {
              found = i;
              foundType = SymbolAdapter.delabel(sym);
            }
          }
        }

        if (found != -1) {
          Type nont = RascalTypeFactory.getInstance().nonTerminalType(foundType);
          IValue child = TreeAdapter.getArgs(tree).get(found);
          return makeResult(nont, child, ctx);
        }
      }
    }

    if (tree.getConstructorType().hasField(name)) {
      return makeResult(tree.getConstructorType().getFieldType(name), tree.get(name), ctx);
    }

    throw RuntimeExceptionFactory.noSuchField(name, ctx.getCurrentAST(), ctx.getStackTrace());
  }
コード例 #2
0
ファイル: ErrorAdapter.java プロジェクト: BertLisser/rascal
 public String getDescription() {
   return ((IString) error.get("description")).getValue();
 }
コード例 #3
0
ファイル: ErrorAdapter.java プロジェクト: BertLisser/rascal
 public IList getSubjects() {
   return (IList) error.get("subjects");
 }
コード例 #4
0
 private IValue desugarChildren(IConstructor o) throws E {
   for (int i = 0; i < o.arity(); i++) {
     o = o.set(i, o.get(i).accept(this));
   }
   return fVisitor.visitConstructor(o);
 }