01: /*
02: * @(#)isGenerator.java 1.2 04/12/06
03: *
04: * Copyright (c) 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.Context;
12: import pnuts.lang.PnutsFunction;
13: import pnuts.lang.Generator;
14:
15: public class isGenerator extends PnutsFunction {
16:
17: public isGenerator() {
18: super ("isGenerator");
19: }
20:
21: public boolean defined(int narg) {
22: return narg == 1;
23: }
24:
25: protected Object exec(Object[] args, Context context) {
26: int nargs = args.length;
27: if (nargs == 1) {
28: return new Boolean(args[0] instanceof Generator);
29: } else {
30: undefined(args, context);
31: return null;
32: }
33: }
34:
35: public String toString() {
36: return "function isGenerator(obj)";
37: }
38: }
|