Forráskód Böngészése

Modification suite refonte LispElement

Arthur Brandao 6 éve
szülő
commit
6daad66591
2 módosított fájl, 12 hozzáadás és 12 törlés
  1. 11 11
      src/migl/lisp/LispImpl.java
  2. 1 1
      src/migl/lisp/LispOperator.java

+ 11 - 11
src/migl/lisp/LispImpl.java

@@ -78,7 +78,7 @@ public class LispImpl implements Lisp {
 		operators.put("+", (lisp) -> {
 			BigInteger resultInt = new BigInteger("0");
             while(!lisp.isEmpty()){
-                LispElement<?> eltInt = getElement(lisp.car());
+                LispElement eltInt = getElement(lisp.car());
                 if(eltInt.value.getClass() != BigInteger.class) break;
                 resultInt = resultInt.add(eltInt.toInt());
                 lisp = lisp.cdr();
@@ -88,7 +88,7 @@ public class LispImpl implements Lisp {
             //Sinon on continue en passant en double
             double result = resultInt.doubleValue();
             while(!lisp.isEmpty()) {
-                LispElement<?> elt = getElement(lisp.car());
+                LispElement elt = getElement(lisp.car());
                 result += elt.toNumber();
                 lisp = lisp.cdr();
             }
@@ -97,7 +97,7 @@ public class LispImpl implements Lisp {
 		operators.put("*", (lisp) -> {
 			BigInteger resultInt = new BigInteger("1");
             while(!lisp.isEmpty()){
-                LispElement<?> eltInt = getElement(lisp.car());
+                LispElement eltInt = getElement(lisp.car());
                 if(eltInt.value.getClass() != BigInteger.class) break;
                 resultInt = resultInt.multiply(eltInt.toInt());
                 lisp = lisp.cdr();
@@ -107,7 +107,7 @@ public class LispImpl implements Lisp {
             //Sinon on continue en passant en double
             double result = resultInt.doubleValue();
             while(!lisp.isEmpty()) {
-                LispElement<?> elt = getElement(lisp.car());
+                LispElement elt = getElement(lisp.car());
                 result *= elt.toNumber();
                 lisp = lisp.cdr();
             }
@@ -116,7 +116,7 @@ public class LispImpl implements Lisp {
 		operators.put("-", (lisp) -> {
 			switch(lisp.size()) {				
 				case 1:
-					LispElement<?> elt = getElement(lisp.car());
+					LispElement elt = getElement(lisp.car());
 					if(elt.value.getClass() == Double.class) {
 						//return LispElement.generate(elt.toNumber() * -1); //Pb pitest qui remplace * par / or *-1 == /-1
 						double value = elt.toNumber();
@@ -124,8 +124,8 @@ public class LispImpl implements Lisp {
 					}
 					return LispElement.generate(elt.toInt().multiply(new BigInteger("-1")));
 				case 2:
-					LispElement<?> elt1 = getElement(lisp.car());
-					LispElement<?> elt2 = getElement(lisp.cdr().car());
+					LispElement elt1 = getElement(lisp.car());
+					LispElement elt2 = getElement(lisp.cdr().car());
 					if(elt1.value.getClass() == Double.class || elt2.value.getClass() == Double.class) {
 						return LispElement.generate(elt1.toNumber() - elt2.toNumber());
 					}
@@ -138,8 +138,8 @@ public class LispImpl implements Lisp {
 			if(lisp.size() != 2) {
 				throw new LispError("Incorrect number of argument");
 			}
-			LispElement<?> elt1 = getElement(lisp.car());
-			LispElement<?> elt2 = getElement(lisp.cdr().car());
+			LispElement elt1 = getElement(lisp.car());
+			LispElement elt2 = getElement(lisp.cdr().car());
 			if(elt1.value.getClass() == Double.class || elt2.value.getClass() == Double.class) {
 				return LispElement.generate(elt1.toNumber() / elt2.toNumber());
 			}
@@ -316,7 +316,7 @@ public class LispImpl implements Lisp {
 	 * @return Valeur évaluer
 	 * @throws LispError
 	 */
-	private static LispElement<?> evaluateList(ConsList<Object> lisp) throws LispError {
+	private static LispElement evaluateList(ConsList<Object> lisp) throws LispError {
 		LispOperator op = operators.get(LispElement.generate(lisp.car()).toStr());
 		if(op == null) {
 			throw new LispError(new UnsupportedOperationException("Unknow expression"));
@@ -339,7 +339,7 @@ public class LispImpl implements Lisp {
 	 * @throws LispError
 	 */
 	@SuppressWarnings("unchecked")
-	private static LispElement<?> getElement(Object elt) throws LispError {
+	private static LispElement getElement(Object elt) throws LispError {
 		if(elt instanceof ConsList) {
 			return evaluateList((ConsList<Object>) elt);
 		}

+ 1 - 1
src/migl/lisp/LispOperator.java

@@ -5,6 +5,6 @@ import migl.util.ConsList;
 @FunctionalInterface
 public interface LispOperator {
 
-	LispElement<?> apply(ConsList<Object> lisp) throws LispError;
+	LispElement apply(ConsList<Object> lisp) throws LispError;
 	
 }