コード例 #1
0
  @Override
  public Node typeCheck(ContextVisitor tc) throws SemanticException {
    RuleDef sym = null;

    MethodInstance mi = call.methodInstance();
    IbexClassType ct = (IbexClassType) mi.container();
    for (RuleInstance rule : ct.rules()) {
      if (rule.name() == mi.name()) sym = rule.def();
    }

    if (sym == null) throw new SemanticException("Cannot find rule for " + mi);

    RhsInvoke n = (RhsInvoke) symbol(sym.asNonterminal()).type(call.type());

    if (assocTag) {
      Context c = tc.context();
      CodeDef code = c.currentCode();
      if (code instanceof RuleDef) {
        RuleDef rd = (RuleDef) code;
        if (rd != sym)
          throw new SemanticException(
              "Associativity annotation must be self-recursive.", position());
      }
    }

    if (!call.type().isVoid()) {
      TypeSystem ts = tc.typeSystem();
      LocalDef li = ts.localDef(position(), Flags.FINAL, Types.ref(call.type()), call.name().id());
      // Formal parameters are never compile-time constants.
      li.setNotConstant();

      IbexNodeFactory nf = (IbexNodeFactory) tc.nodeFactory();
      LocalDecl ld =
          nf.LocalDecl(
              position(),
              nf.FlagsNode(position(), li.flags()),
              nf.CanonicalTypeNode(position(), li.type()),
              nf.Id(position(), li.name()));
      ld = ld.localDef(li);
      ld = ld.init(n);

      return nf.RhsSyntheticBind(position(), ld).type(n.type());
    }

    return n;
  }
コード例 #2
0
ファイル: X10SourceFile_c.java プロジェクト: cogumbreiro/x10
  /** Type check the source file. */
  public Node typeCheck(ContextVisitor tc) {
    boolean hasPublic = false;

    // Override method to not check for duplicate declarations. This will be
    // caught during type building. But, we need to allow duplicates to handle
    // overloaded typedefs.
    for (TopLevelDecl d : decls) {
      if (d instanceof X10ClassDecl && d.flags().flags().isPublic()) {
        if (hasPublic) {
          Errors.issue(
              tc.job(), new Errors.SourceContainsMoreThanOnePublicDeclaration(d.position()), this);
        }
        hasPublic = true;
      }
    }

    return this.hasBeenTypeChecked(true);
  }
コード例 #3
0
ファイル: StmtExpr_c.java プロジェクト: cogumbreiro/x10
 /** Type check the expression. */
 public Node typeCheck(ContextVisitor tc) {
   return type(result == null ? tc.typeSystem().Void() : result.type());
 }