01 
02 /*
03  *  JScripter Emulation 1.0 - To Script Java
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.emu.gc;
21 
22 import js.ObjectLike;
23 import jsx.core.ObjectLikes;
24 
25 /**
26  * <p>An <tt>internal</tt> class for DOM-enabled depth-first-search object revivers emulating 
27  * garbage collection based finalization in JavaScript.</p>
28  * <p>This class is only used internally by JS re-compiler implementations.</p>
29  * 
30  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
31  * 
32  * @javascript This class is only loaded and resolved by re-compiler implementations.
33  */
34 public final class DFSReviver extends DFS
35 {
36     /**
37      * <p>Internally constructs an object visitor of this type.</p>
38      * @since 1.0
39      * @javascript Re-compilers must report error on end-users directly using this constructor.
40      */
41     public DFSReviver() {}
42 
43     /**
44      * <p>Internally visits an object.</p>
45      * @param o An object to visit.
46      * @since 1.0
47      * @javascript Re-compilers must report error on end-users directly using this method.
48      */
49     @Override
50     public void visit(ObjectLike o) {
51         if (ObjectLikes.get(o, LIVES) < 1) {
52             o.var(LIVES, 1);
53             traverse(o);
54         }
55     }
56 }