@Override
  public SMPLValue<SMPLObject> invoke(final SMPLEvaluator evaluator, final SMPLEnvironment newFrame)
      throws ASTException {
    final SMPLValue<SMPLObject> e1 = newFrame.lookUp("e1");
    final SMPLValue<SMPLObject> e2 = newFrame.lookUp("e2");

    final SMPLObject e1Obj = e1.getInternalValue(evaluator, newFrame);
    final SMPLObject e2Obj = e2.getInternalValue(evaluator, newFrame);

    final SMPLBoolean result = new SMPLBoolean(e1Obj.equals(e2Obj));

    return new SMPLValue<SMPLObject>(result);
  }
예제 #2
0
  @Override
  public SMPLValue<SMPLObject> invoke(final SMPLEvaluator evaluator, final SMPLEnvironment newFrame)
      throws ASTException {
    final SMPLObject vectorValue = newFrame.lookUp("vector").getInternalValue(evaluator, newFrame);

    if (!(vectorValue instanceof SMPLVector))
      throw new SMPLException(
          "Size function requires a vetor as its argument. \n Given: " + vectorValue.toRepr());
    else {
      final SMPLVector vector = (SMPLVector) vectorValue;

      final SMPLInteger result =
          new SMPLInteger(new BigInteger(((Integer) vector.size()).toString()));

      return new SMPLValue<SMPLObject>(result);
    }
  }