01: // Copyright (c) 2001 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.mapping;
05:
06: public class CpsMethodProc extends CpsProcedure {
07: CpsMethodContainer module;
08: public final int selector;
09: private int numArgs;
10:
11: public CpsMethodProc(CpsMethodContainer module, int selector,
12: String name, int numArgs) {
13: this .module = module;
14: this .selector = selector;
15: this .numArgs = numArgs;
16: setName(name);
17: }
18:
19: public CpsMethodProc(CpsMethodContainer module, int selector,
20: String name, int numArgs, Object argTypes) {
21: this .module = module;
22: this .selector = selector;
23: this .numArgs = numArgs;
24: setName(name);
25: this .argTypes = argTypes;
26: }
27:
28: /*
29: protected void resolveParameterTypes()
30: {
31: }
32: */
33:
34: public int numArgs() {
35: return numArgs;
36: }
37:
38: /*
39: public final int match (CallContext ctx, Object[] args)
40: {
41: ctx.setArgsN(args);
42: return modele.match(this, ctx);
43: }
44: */
45:
46: public void apply(CallContext context) {
47: module.apply(this , context);
48: /*
49: int code = module.match(this, context);
50: if (code == 0)
51: module.apply(this, context);
52: else
53: {
54: int arg = (short) code;
55: code &= 0xffff0000;
56: if (code == NO_MATCH_TOO_FEW_ARGS || code == NO_MATCH_TOO_MANY_ARGS)
57: throw new WrongArguments(this, context.count);
58: if (code != NO_MATCH_BAD_TYPE)
59: arg = WrongType.ARG_UNKNOWN;
60: throw new WrongType(this, arg, null);
61: }
62: */
63: }
64:
65: /** Helper methods for default CpsMethodContainer actions. */
66:
67: public void applyError() {
68: throw new Error("internal error - bad selector for " + this);
69: }
70:
71: }
|