Parcourir la source

Utilisation singleton

Arthur Brandao il y a 6 ans
Parent
commit
fdb6b4d1f8
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      src/migl/lisp/LispFactory.java

+ 6 - 1
src/migl/lisp/LispFactory.java

@@ -7,6 +7,8 @@ package migl.lisp;
  *
  */
 public class LispFactory {
+	
+	private static Lisp interpreter;
 
     private LispFactory() {
         // do nothing
@@ -18,6 +20,9 @@ public class LispFactory {
      * @return a new lisp interpreter.
      */
     public static Lisp makeIntepreter() {
-        return new LispImpl();
+    	if(interpreter == null) {
+    		interpreter = new LispImpl();
+    	}
+        return interpreter;
     }
 }