Ticket #240: ticket-240.patch
File ticket-240.patch, 2.6 KB (added by , 11 years ago) |
---|
-
Environment.java
42 42 private Binding blocks; 43 43 private Binding tags; 44 44 public boolean inactive; //default value: false == active 45 private static final ConcurrentHashMap<Symbol, LispObject> classMap; 45 46 46 47 public Environment() {} 47 48 … … 53 54 lastFunctionBinding = parent.lastFunctionBinding; 54 55 blocks = parent.blocks; 55 56 tags = parent.tags; 57 classMap = parent.classMap; 56 58 } 59 else 60 classMap = new ConcurrentHashMap<Symbol, LispObject>(); 61 57 62 } 58 63 59 64 // Construct a new Environment extending parent with the specified symbol- … … 217 222 return null; 218 223 } 219 224 225 final public LispObject addClass(LispObject name, LispObject c) 226 { 227 classMap.put(checkSymbol(name), c); 228 return c; 229 } 230 231 final public LispObject findClass(LispObject name, boolean errorp) 232 { 233 final Symbol symbol = checkSymbol(name); 234 final LispObject c = classMap.get(symbol); 235 236 if (c != null) 237 return c; 238 239 if (errorp) 240 { 241 StringBuilder sb = 242 new StringBuilder("There is no class named "); 243 sb.append(name.princToString()); 244 sb.append('.'); 245 return error(new LispError(sb.toString())); 246 } 247 return NIL; 248 } 249 250 final public void removeClass(LispObject name) 251 { 252 classMap.remove(checkSymbol(name)); 253 } 254 220 255 // Returns body with declarations removed. 221 256 public LispObject processDeclarations(LispObject body) 222 257 -
LispClass.java
328 328 LispObject third) 329 329 330 330 { 331 // FIXME Use environment! 332 return findClass(first, second != NIL); 331 return checkEnvironment(third).findClass(first, second != NIL); 333 332 } 334 333 }; 335 334 … … 339 338 { 340 339 @Override 341 340 public LispObject execute(LispObject first, LispObject second) 342 343 341 { 344 342 final Symbol name = checkSymbol(first); 345 343 if (second == NIL) … … 350 348 addClass(name, second); 351 349 return second; 352 350 } 351 352 @Override 353 public LispObject execute(LispObject first, LispObject second, 354 LispObject third, LispObject fourth) 355 { 356 if (second == NIL) 357 { 358 checkEnvironment.removeClass(first); 359 return second; 360 } 361 362 return checkEnvironment(fourth).addCleass(first, second); 353 363 }; 354 364 355 365 // ### subclassp