rootScope.java :  » Scripting » Pnuts » org » pnuts » lib » Java Open Source

Java Open Source » Scripting » Pnuts 
Pnuts » org » pnuts » lib » rootScope.java
/*
 * @(#)rootScope.java 1.2 04/12/06
 *
 * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
 *
 * See the file "LICENSE.txt" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 */
package org.pnuts.lib;

import pnuts.lang.PnutsFunction;
import pnuts.lang.Package;
import pnuts.lang.Context;

public class rootScope extends PnutsFunction {

  public rootScope(){
    super("rootScope");
  }

  public boolean defined(int narg){
    return (narg == 0);
  }

  protected Object exec(Object args[], Context context){
    if (args.length != 0){
      undefined(args, context);
      return null;
    }
    Package p = context.getCurrentPackage();
    Package parent = p.getParent();
    while (parent != null){
      p = parent;
      parent = p.getParent();
    }
    return p;
  }

  public String toString(){
    return "function rootScope()";
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.