01 
02 /*
03  *  JScripter Simulation 1.0 - For Java To Script
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package org.jscripter.sim.core;
21 
22 import js.Function;
23 import js.Vars;
24 import js.core.JsFunction;
25 import js.core.JsGlobal;
26 import js.core.JsObject;
27 
28 final class CreatorFunction extends CoreFunction<JsFunction<?>>
29 {
30     private CreatorFunction() {
31         super(JsGlobal.Function.toString());
32     }
33 
34     @Override
35     protected JsFunction<?> function(java.lang.Object jsthis, Call<JsFunction<?>> callee) {
36         return new Function<Void>() {
37             @Override
38             protected Void function(java.lang.Object jsthis, Call<Void> callee) {
39                 return null;
40             }
41         }.var();
42     }
43 
44     @Override
45     public final JsObject create(Object arg) {
46         throw new UnsupportedOperationException();
47     }
48 
49     @Override
50     public final JsObject create(Vars<?> args) {
51         throw new UnsupportedOperationException();
52     }
53 
54     private static CreatorFunction singleton;
55 
56     public final static synchronized CreatorFunction get() {
57         if (singleton == null) {
58             singleton = new CreatorFunction();
59         }
60         return singleton;
61     }
62 }