01: /*
02: * @(#)rootScope.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.lib;
10:
11: import pnuts.lang.PnutsFunction;
12: import pnuts.lang.Package;
13: import pnuts.lang.Context;
14:
15: public class rootScope extends PnutsFunction {
16:
17: public rootScope() {
18: super ("rootScope");
19: }
20:
21: public boolean defined(int narg) {
22: return (narg == 0);
23: }
24:
25: protected Object exec(Object args[], Context context) {
26: if (args.length != 0) {
27: undefined(args, context);
28: return null;
29: }
30: Package p = context.getCurrentPackage();
31: Package parent = p.getParent();
32: while (parent != null) {
33: p = parent;
34: parent = p.getParent();
35: }
36: return p;
37: }
38:
39: public String toString() {
40: return "function rootScope()";
41: }
42: }
|