예제 #1
0
  public ClassDecl ClassDeclAttribute(
      Position pos,
      Flags flags,
      String name,
      TypeNode superClass,
      List interfaces,
      ClassBody body,
      TypeNode domain,
      TypeSystem typeSys) {
    JeddTypeSystem ts = (JeddTypeSystem) typeSys;
    body =
        body.addMember(
            FieldDecl(
                pos,
                Flags.PUBLIC.set(Flags.FINAL),
                domain,
                "domain",
                Cast(pos, domain, Call(pos, domain, "v"))));
    body =
        body.addMember(
            MethodDecl(
                pos,
                Flags.PUBLIC,
                CanonicalTypeNode(pos, ts.domain()),
                "domain",
                Collections.EMPTY_LIST,
                Collections.EMPTY_LIST,
                Block(pos, Return(pos, AmbExpr(pos, "domain")))));
    body =
        body.addMember(
            MethodDecl(
                pos,
                Flags.PUBLIC.set(Flags.STATIC),
                CanonicalTypeNode(pos, ts.attribute()),
                "v",
                Collections.EMPTY_LIST,
                Collections.EMPTY_LIST,
                Block(pos, Return(pos, AmbExpr(pos, "instance")))));
    body =
        body.addMember(
            FieldDecl(
                pos,
                Flags.PRIVATE.set(Flags.STATIC),
                CanonicalTypeNode(pos, ts.attribute()),
                "instance",
                New(pos, AmbTypeNode(pos, name), Collections.EMPTY_LIST)));

    return ClassDecl(pos, flags, name, superClass, interfaces, body);
  }
예제 #2
0
  public ClassDecl ClassDeclPhysDom(
      Position pos,
      Flags flags,
      String name,
      TypeNode superClass,
      List interfaces,
      ClassBody body,
      TypeSystem typeSys) {
    JeddTypeSystem ts = (JeddTypeSystem) typeSys;
    body =
        body.addMember(
            MethodDecl(
                pos,
                Flags.PUBLIC,
                CanonicalTypeNode(pos, ts.Int()),
                "bits",
                Collections.EMPTY_LIST,
                Collections.EMPTY_LIST,
                Block(pos, Return(pos, IntLit(pos, IntLit.INT, 0)))));
    body =
        body.addMember(
            MethodDecl(
                pos,
                Flags.PUBLIC.set(Flags.STATIC),
                CanonicalTypeNode(pos, ts.physicalDomain()),
                "v",
                Collections.EMPTY_LIST,
                Collections.EMPTY_LIST,
                Block(pos, Return(pos, AmbExpr(pos, "instance")))));
    body =
        body.addMember(
            FieldDecl(
                pos,
                Flags.PRIVATE.set(Flags.STATIC),
                CanonicalTypeNode(pos, ts.physicalDomain()),
                "instance",
                New(pos, AmbTypeNode(pos, name), Collections.EMPTY_LIST)));

    return ClassDecl(pos, flags, name, superClass, interfaces, body);
  }