Changeset 13834
- Timestamp:
- 01/30/12 20:13:16 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/Closure.java
r13833 r13834 172 172 public LispObject execute() 173 173 { 174 if (arity == 0)175 {176 return progn(executionBody, environment,177 LispThread.currentThread());178 }179 else180 174 return execute(new LispObject[0]); 181 175 } 182 176 183 private final LispObject bindParametersAndExecute(LispObject... objects)184 185 {186 final LispThread thread = LispThread.currentThread();187 final SpecialBindingsMark mark = thread.markSpecialBindings();188 189 Environment ext = new Environment(environment);190 LispObject[] args = arglist.match(objects, environment, ext, thread);191 arglist.bindVars(args, ext, thread);192 declareFreeSpecials(ext);193 try194 {195 return progn(executionBody, ext, thread);196 }197 finally198 {199 thread.resetSpecialBindings(mark);200 }201 }202 203 public final LispObject invokeArrayExecute(LispObject... objects)204 205 {206 return execute(objects);207 }208 209 177 @Override 210 178 public LispObject execute(LispObject arg) 211 179 { 212 if (minArgs == 1) 213 { 214 return bindParametersAndExecute(arg); 215 } 216 else 217 { 218 return invokeArrayExecute(arg); 219 } 180 return execute(new LispObject[] {arg}); 220 181 } 221 182 222 183 @Override 223 184 public LispObject execute(LispObject first, LispObject second) 224 225 { 226 if (minArgs == 2) 227 { 228 return bindParametersAndExecute(first, second); 229 } 230 else 231 { 232 return invokeArrayExecute(first, second); 233 } 185 { 186 return execute(new LispObject[] {first, second}); 234 187 } 235 188 … … 237 190 public LispObject execute(LispObject first, LispObject second, 238 191 LispObject third) 239 240 { 241 if (minArgs == 3) 242 { 243 return bindParametersAndExecute(first, second, third); 244 } 245 else 246 { 247 return invokeArrayExecute(first, second, third); 248 } 192 { 193 return execute(new LispObject[] {first, second, third}); 249 194 } 250 195 … … 252 197 public LispObject execute(LispObject first, LispObject second, 253 198 LispObject third, LispObject fourth) 254 255 { 256 if (minArgs == 4) 257 { 258 return bindParametersAndExecute(first, second, third, fourth); 259 } 260 else 261 { 262 return invokeArrayExecute(first, second, third, fourth); 263 } 199 { 200 return execute(new LispObject[] {first, second, third, fourth}); 264 201 } 265 202 … … 268 205 LispObject third, LispObject fourth, 269 206 LispObject fifth) 270 271 { 272 if (minArgs == 5) 273 { 274 return bindParametersAndExecute(first, second, third, fourth, 275 fifth); 276 } 277 else 278 { 279 return invokeArrayExecute(first, second, third, fourth, fifth); 280 } 207 { 208 return execute(new LispObject[] {first, second, third, fourth, fifth}); 281 209 } 282 210 … … 285 213 LispObject third, LispObject fourth, 286 214 LispObject fifth, LispObject sixth) 287 288 { 289 if (minArgs == 6) 290 { 291 return bindParametersAndExecute(first, second, third, fourth, 292 fifth, sixth); 293 } 294 else 295 { 296 return invokeArrayExecute(first, second, third, fourth, fifth, 297 sixth); 298 } 215 { 216 return execute(new LispObject[] {first, second, third, fourth, fifth, 217 sixth}); 299 218 } 300 219 … … 304 223 LispObject fifth, LispObject sixth, 305 224 LispObject seventh) 306 307 { 308 if (minArgs == 7) 309 { 310 return bindParametersAndExecute(first, second, third, fourth, 311 fifth, sixth, seventh); 312 } 313 else 314 { 315 return invokeArrayExecute(first, second, third, fourth, fifth, 316 sixth, seventh); 317 } 225 { 226 return execute(new LispObject[] {first, second, third, fourth, fifth, 227 sixth, seventh}); 318 228 } 319 229 … … 323 233 LispObject fifth, LispObject sixth, 324 234 LispObject seventh, LispObject eighth) 325 326 { 327 if (minArgs == 8) 328 { 329 return bindParametersAndExecute(first, second, third, fourth, 330 fifth, sixth, seventh, eighth); 331 } 332 else 333 { 334 return invokeArrayExecute(first, second, third, fourth, fifth, 335 sixth, seventh, eighth); 336 } 337 } 338 339 private void declareFreeSpecials(Environment ext) 340 { 341 for (Symbol special : freeSpecials) 342 ext.declareSpecial(special); 235 { 236 return execute(new LispObject[] {first, second, third, fourth, fifth, 237 sixth, seventh, eighth}); 343 238 } 344 239 … … 351 246 args = arglist.match(args, environment, ext, thread); 352 247 arglist.bindVars(args, ext, thread); 353 declareFreeSpecials(ext); 248 for (Symbol special : freeSpecials) 249 ext.declareSpecial(special); 354 250 try 355 251 {
Note: See TracChangeset
for help on using the changeset viewer.