예제 #1
0
  @Test
  public void constructor() {
    Kind kind = new Kind(vnaam, fnaam, gdatum);

    assertEquals(vnaam, kind.getVoornaam());
    assertEquals(fnaam, kind.getFamilieNaam());
    assertEquals(gdatum, kind.getGeboorteDatum());
  }
예제 #2
0
 public static Kind fromSwig(int swigValue) {
   Kind[] enumValues = Kind.class.getEnumConstants();
   for (Kind ev : enumValues) {
     if (ev.getSwig() == swigValue) {
       return ev;
     }
   }
   return UNKNOWN;
 }
예제 #3
0
  @Test
  public void leeftijd() {
    Kind kind = new Kind(vnaam, fnaam, new Datum(1, 6, 2010));

    assertEquals(1, kind.getLeeftijd(new Datum(1, 6, 2011)));
    assertEquals(2, kind.getLeeftijd(new Datum(1, 6, 2012)));
    assertEquals(1, kind.getLeeftijd(new Datum(1, 1, 2012)));
    assertEquals(0, kind.getLeeftijd(new Datum(1, 1, 2011)));
  }
예제 #4
0
 public static long saturate(long v, Kind kind) {
   long max = kind.getMaxValue();
   if (v > max) {
     return max;
   }
   long min = kind.getMinValue();
   if (v < min) {
     return min;
   }
   return v;
 }
예제 #5
0
  static {
    // Create maps to speed up lookup from raw value to enum
    kindMap = new HashMap<Integer, Kind>();
    for (Kind next : Kind.values()) {
      kindMap.put(next.getId(), next);
    }

    audioProfileMap = new HashMap<Integer, AudioProfile>();
    for (AudioProfile next : AudioProfile.values()) {
      audioProfileMap.put(next.getId(), next);
    }
  }
예제 #6
0
 private static Stamp narrowingKindConvertion(IntegerStamp fromStamp, Kind toKind) {
   long mask = fromStamp.mask() & IntegerStamp.defaultMask(toKind);
   long lowerBound = saturate(fromStamp.lowerBound(), toKind);
   long upperBound = saturate(fromStamp.upperBound(), toKind);
   if (fromStamp.lowerBound() < toKind.getMinValue()) {
     upperBound = toKind.getMaxValue();
   }
   if (fromStamp.upperBound() > toKind.getMaxValue()) {
     lowerBound = toKind.getMinValue();
   }
   return StampFactory.forInteger(toKind.getStackKind(), lowerBound, upperBound, mask);
 }
예제 #7
0
  public String toString() {
    String str = kind.name();

    if (!kind.hasStaticLexeme()) str += "(" + lexeme() + ")";

    str += "(";
    str += "lineNum:" + lineNum;
    str += ", ";
    str += "charPos:" + charPos;
    str += ")";

    return str;
  }
예제 #8
0
 /**
  * Ensure that the frame state is formatted as expected by the JVM, with null or Illegal in the
  * slot following a double word item. This should really be checked in FrameState itself but
  * because of Word type rewriting and alternative backends that can't be done.
  */
 public boolean validateFormat() {
   if (caller() != null) {
     caller().validateFormat();
   }
   for (int i = 0; i < numLocals + numStack; i++) {
     if (values[i] != null) {
       Kind kind = values[i].getKind();
       if (kind.needsTwoSlots()) {
         assert values.length > i + 1 : String.format("missing second word %s", this);
         assert values[i + 1] == null || values[i + 1].getKind() == Kind.Illegal : this;
       }
     }
   }
   return true;
 }
예제 #9
0
 public static Stamp negate(Stamp stamp) {
   Kind kind = stamp.kind();
   if (stamp instanceof IntegerStamp) {
     IntegerStamp integerStamp = (IntegerStamp) stamp;
     if (integerStamp.lowerBound() != kind.getMinValue()) {
       // TODO(ls) check if the mask calculation is correct...
       return new IntegerStamp(
           kind,
           -integerStamp.upperBound(),
           -integerStamp.lowerBound(),
           IntegerStamp.defaultMask(kind) & (integerStamp.mask() | -integerStamp.mask()));
     }
   }
   return StampFactory.forKind(kind);
 }
예제 #10
0
  public Token(String lexeme, int lineNum, int charPos) {
    this.lineNum = lineNum;
    this.charPos = charPos;

    for (Kind tok : Token.Kind.values()) {
      if (tok.matches(lexeme)) {
        this.kind = tok;
        return;
      }
    }

    // if we don't match anything, signal error
    this.kind = Kind.ERROR;
    this.lexeme = "Unrecognized lexeme: " + lexeme;
  }
예제 #11
0
  public Token(String lexeme, int lineNum, int charPos) {
    boolean foundPredefined = false;

    this.lineNum = lineNum;
    this.charPos = charPos;
    this.lexeme = lexeme;

    for (Kind k : Kind.values()) {
      if (lexeme.equals(k.default_lexeme)) {
        this.kind = k;
        foundPredefined = true;
      }
    }

    // not found in reserved words or character sequences
    if (!foundPredefined) {

      if (isInteger(lexeme)) this.kind = Kind.INTEGER;
      else if (isFloatingPoint(lexeme)) this.kind = Kind.FLOAT;
      else if (isIdentifier(lexeme)) this.kind = Kind.IDENTIFIER;
      else this.kind = Kind.ERROR;

      // TODO: IF ALL ELSE FAILS IT IS IDENTIFIER????
    }

    // maybe need to check if identifier or etc.

    // if we don't match anything, signal error
    // this.kind = Kind.ERROR; I COMMENTED THIS OUT NOT SURE WHAT TO DO WITH IT
    // this.lexeme = "Unrecognized lexeme: " + lexeme;
  }
예제 #12
0
  private synchronized void save() {
    myDir.mkdirs();

    Properties props = new Properties();

    props.setProperty(KIND_KEY, myKind.toString());
    props.setProperty(ID_KEY, myRepositoryId);
    props.setProperty(PATH_OR_URL_KEY, myRepositoryPathOrUrl);
    props.setProperty(INDEX_VERSION_KEY, CURRENT_VERSION);
    if (myUpdateTimestamp != null)
      props.setProperty(TIMESTAMP_KEY, String.valueOf(myUpdateTimestamp));
    if (myDataDirName != null) props.setProperty(DATA_DIR_NAME_KEY, myDataDirName);
    if (myFailureMessage != null) props.setProperty(FAILURE_MESSAGE_KEY, myFailureMessage);

    try {
      FileOutputStream s = new FileOutputStream(new File(myDir, INDEX_INFO_FILE));
      try {
        props.store(s, null);
      } finally {
        s.close();
      }
    } catch (IOException e) {
      MavenLog.LOG.warn(e);
    }
  }
예제 #13
0
 /**
  * Return the lexeme representing or held by this token.
  *
  * @return The lexeme string.
  */
 public String lexeme() {
   if (kind.hasStaticLexeme()) {
     return kind.default_lexeme;
   } else {
     return lexeme;
   }
 }
예제 #14
0
 /**
  * Get a string represenation of this token instance.
  *
  * @return A formatted string describing the token.
  */
 public String toString() {
   StringBuilder builder = new StringBuilder();
   builder.append(kind.name());
   switch (kind) {
     case ERROR:
       builder.append("(");
       builder.append("Unexpected character: ");
       builder.append(lexeme);
       builder.append(")");
       break;
     case INTEGER:
     case FLOAT:
     case IDENTIFIER:
       builder.append("(");
       builder.append(lexeme);
       builder.append(")");
       break;
   }
   builder.append("(");
   builder.append("lineNum:").append(lineNum);
   builder.append(", ");
   builder.append("charPos:").append(charPos);
   builder.append(")");
   return builder.toString();
 }
예제 #15
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((kind == null) ? 0 : kind.hashCode());
   result = prime * result + ((path == null) ? 0 : path.hashCode());
   return result;
 }
예제 #16
0
  private void print(StringBuilder builder, int indent, Predicate<GExpansion> filter) {
    if (!filter.test(this)) return;

    builder.append("\n");
    Utils.printIndent(builder, indent);
    String kindString = kind.toString();
    if (negativeLookahead) kindString = "negative" + kindString;
    builder.append(Utils.lowerCaseFirst(kindString)).append("(");

    switch (kind) {
      case LookAhead:
        if (semanticLookahead != null) {
          builder.append("{ ");
          builder.append(Printer.printToString(semanticLookahead, true).trim());
          builder.append(" }");
          break;
        }
        if (amount != -1) {
          builder.append(amount);
          break;
        }
      case Choice:
      case Sequence:
      case ZeroOrOne:
      case ZeroOrMore:
      case OneOrMore:
        for (GExpansion child : children) {
          child.print(builder, indent + 1, filter);
        }
        builder.append("\n");
        Utils.printIndent(builder, indent);
        break;
      case NonTerminal:
        if (this.name != null) builder.append(this.name).append(", ");
        builder.append(symbol);
        break;
      case Terminal:
        if (this.name != null) builder.append(this.name).append(", ");
        builder.append(symbol);
        break;
      case Action:
        builder.append("{");
        if (action.size() == 1 && action.first().kind() != org.jlato.tree.Kind.IfStmt) {
          builder.append(" ");
          builder.append(Printer.printToString(action.first(), true).trim());
          builder.append(" ");
        } else {
          builder.append("\n");
          Utils.printIndented(action, builder, indent + 1);
          Utils.printIndent(builder, indent);
        }
        builder.append("}");
        break;
      default:
    }

    builder.append(")");
  }
예제 #17
0
  public void writeToNBT(NBTTagCompound nbttagcompound) {
    nbttagcompound.setByte("kind", (byte) kind.ordinal());

    nbttagcompound.setInteger("xMin", xMin);
    nbttagcompound.setInteger("yMin", yMin);
    nbttagcompound.setInteger("zMin", zMin);

    nbttagcompound.setInteger("xMax", xMax);
    nbttagcompound.setInteger("yMax", yMax);
    nbttagcompound.setInteger("zMax", zMax);
  }
예제 #18
0
  public void initialize(NBTTagCompound nbttagcompound) {
    kind = Kind.values()[nbttagcompound.getShort("kind")];

    initialize(
        nbttagcompound.getInteger("xMin"),
        nbttagcompound.getInteger("yMin"),
        nbttagcompound.getInteger("zMin"),
        nbttagcompound.getInteger("xMax"),
        nbttagcompound.getInteger("yMax"),
        nbttagcompound.getInteger("zMax"));
  }
예제 #19
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = 1;
   result = prime * result + ((bool_val == null) ? 0 : bool_val.hashCode());
   result = prime * result + ((float_val == null) ? 0 : float_val.hashCode());
   result = prime * result + ((kind == null) ? 0 : kind.hashCode());
   result = prime * result + ((name == null) ? 0 : name.hashCode());
   result = prime * result + ((num_val == null) ? 0 : num_val.hashCode());
   result = prime * result + ((string_val == null) ? 0 : string_val.hashCode());
   result = prime * result + ((type == null) ? 0 : type.hashCode());
   return result;
 }
  SourceInstruction(
      Kind kind,
      InstructionType instructionNode,
      ASTNode markerReferenceNode,
      InstructionBindingType instructionNodeBinding,
      String displayName) {
    if (!kind.isCompatible(instructionNode, instructionNodeBinding)) {
      throw new IllegalArgumentException(
          String.format(
              "Attempt to instantiate an instruction of kind %s with a %s instruction.",
              kind, instructionNode.getClass().getSimpleName()));
    }

    this.kind = kind;
    this.instructionNode = instructionNode;
    this.markerReferenceNode = markerReferenceNode;
    this.instructionNodeBinding = instructionNodeBinding;
    this.displayName = displayName;
  }
예제 #21
0
  public MavenIndex(MavenIndexerWrapper indexer, File dir, IndexListener listener)
      throws MavenIndexException {
    myIndexer = indexer;
    myDir = dir;
    myListener = listener;

    Properties props = new Properties();
    try {
      FileInputStream s = new FileInputStream(new File(dir, INDEX_INFO_FILE));
      try {
        props.load(s);
      } finally {
        s.close();
      }
    } catch (IOException e) {
      throw new MavenIndexException("Cannot read " + INDEX_INFO_FILE + " file", e);
    }

    if (!CURRENT_VERSION.equals(props.getProperty(INDEX_VERSION_KEY))) {
      throw new MavenIndexException("Incompatible index version, needs to be updated: " + dir);
    }

    myKind = Kind.valueOf(props.getProperty(KIND_KEY));
    myRepositoryId = props.getProperty(ID_KEY);
    myRepositoryPathOrUrl = normalizePathOrUrl(props.getProperty(PATH_OR_URL_KEY));

    try {
      String timestamp = props.getProperty(TIMESTAMP_KEY);
      if (timestamp != null) myUpdateTimestamp = Long.parseLong(timestamp);
    } catch (Exception ignored) {
    }

    myDataDirName = props.getProperty(DATA_DIR_NAME_KEY);
    myFailureMessage = props.getProperty(FAILURE_MESSAGE_KEY);

    if (!getUpdateDir().exists()) {
      myUpdateTimestamp = null;
    }

    open();
  }
예제 #22
0
 public long createObject(Kind k) {
   return JavaControllerJNI.Controller_createObject(swigCPtr, this, k.ordinal());
 }
예제 #23
0
 public UpdateStatus setObjectProperty(long uid, Kind k, ObjectProperties p, VectorOfScicosID v) {
   return UpdateStatus.class
       .getEnumConstants()[
       JavaControllerJNI.Controller_setObjectProperty__SWIG_10(
           swigCPtr, this, uid, k.ordinal(), p.ordinal(), VectorOfScicosID.getCPtr(v), v)];
 }
예제 #24
0
 public UpdateStatus setObjectProperty(long uid, Kind k, ObjectProperties p, String v) {
   return UpdateStatus.class
       .getEnumConstants()[
       JavaControllerJNI.Controller_setObjectProperty__SWIG_4(
           swigCPtr, this, uid, k.ordinal(), p.ordinal(), v)];
 }
예제 #25
0
 public boolean getObjectProperty(long uid, Kind k, ObjectProperties p, VectorOfScicosID v) {
   return JavaControllerJNI.Controller_getObjectProperty__SWIG_10(
       swigCPtr, this, uid, k.ordinal(), p.ordinal(), VectorOfScicosID.getCPtr(v), v);
 }
예제 #26
0
 public VectorOfScicosID getAll(Kind k) {
   return new VectorOfScicosID(
       JavaControllerJNI.Controller_getAll(swigCPtr, this, k.ordinal()), true);
 }
예제 #27
0
 /**
  * specifies if this piece is part of the read cache or the write cache.
  *
  * @return
  */
 public Kind getKind() {
   return Kind.fromSwig(i.getKind().swigValue());
 }
예제 #28
0
 private MethodInvocationExpr factoryCall(NodeList<Expr> args) {
   Name methodName = name(lowerCaseFirst(kind.name()));
   return methodInvocationExpr(methodName).withArgs(args).prependLeadingNewLine();
 }
예제 #29
0
 public boolean getObjectProperty(long uid, Kind k, ObjectProperties p, long[] v) {
   return JavaControllerJNI.Controller_getObjectProperty__SWIG_5(
       swigCPtr, this, uid, k.ordinal(), p.ordinal(), v);
 }
예제 #30
0
 /** Query this token if it's of a given kind. */
 public boolean is(Kind rhs) {
   return kind.equals(rhs);
 }