1 4 package gnu.kawa.functions; 5 import gnu.mapping.*; 6 import gnu.expr.*; 7 8 10 11 public class ConstantFunction0 extends Procedure0 implements CanInline 12 { 13 final Object value; 14 final QuoteExp constant; 15 16 public ConstantFunction0(String name, Object value) 17 { 18 super(name); 19 this.value = value; 20 this.constant = QuoteExp.getInstance(value); 21 } 22 23 public ConstantFunction0(String name, QuoteExp constant) 24 { 25 super(name); 26 this.value = constant.getValue(); 27 this.constant = constant; 28 } 29 30 public Object apply0() { return value; } 31 32 public Expression inline (ApplyExp exp, ExpWalker walker) 33 { 34 int nargs = exp.getArgCount(); 35 if (nargs != 0 && walker != null) 36 { 37 String message = WrongArguments.checkArgCount(this, nargs); 38 return walker.noteError(message); 39 } 40 return constant; 41 } 42 } 43 | Popular Tags |