001: /*
002: * $Id: Matches.java,v 1.2 2002/09/16 08:05:03 jkl Exp $
003: *
004: * Copyright (c) 2002 Njet Communications Ltd. All Rights Reserved.
005: *
006: * Use is subject to license terms, as defined in
007: * Anvil Sofware License, Version 1.1. See LICENSE
008: * file, or http://njet.org/license-1.1.txt
009: */
010: package anvil.core.reflect;
011:
012: import anvil.core.Any;
013:
014: public class Matches implements ParameterTypes {
015:
016: public static final int[] MATCH = { JAVA_LANG_BOOLEAN,
017: Any.IS_BOOLEAN, BEST, JAVA_LANG_BOOLEAN, Any.IS_INT, GOOD,
018: JAVA_LANG_BOOLEAN, Any.IS_NULL, GOOD, JAVA_LANG_BOOLEAN,
019: Any.IS_UNDEFINED, GOOD, JAVA_LANG_BOOLEAN, -1, POOR,
020:
021: BOOLEAN, Any.IS_BOOLEAN, BEST, BOOLEAN, Any.IS_INT, GOOD,
022: BOOLEAN, Any.IS_NULL, POOR, BOOLEAN, Any.IS_UNDEFINED,
023: POOR, BOOLEAN, -1, POOR,
024:
025: JAVA_LANG_BYTE, Any.IS_INT, BEST, JAVA_LANG_BYTE,
026: Any.IS_NULL, GOOD, JAVA_LANG_BYTE, Any.IS_UNDEFINED, GOOD,
027: JAVA_LANG_BYTE, -1, NO,
028:
029: BYTE, Any.IS_INT, BEST, BYTE, -1, NO,
030:
031: JAVA_LANG_CHAR, Any.IS_STRING, BEST, JAVA_LANG_CHAR,
032: Any.IS_INT, GOOD, JAVA_LANG_CHAR, -1, POOR,
033:
034: CHAR, Any.IS_STRING, BEST, CHAR, Any.IS_INT, GOOD, CHAR,
035: -1, POOR,
036:
037: JAVA_LANG_SHORT, Any.IS_INT, BEST, JAVA_LANG_SHORT,
038: Any.IS_NULL, GOOD, JAVA_LANG_SHORT, Any.IS_UNDEFINED, GOOD,
039: JAVA_LANG_SHORT, -1, NO,
040:
041: SHORT, Any.IS_INT, BEST, SHORT, -1, NO,
042:
043: JAVA_LANG_INT, Any.IS_INT, BEST, JAVA_LANG_INT,
044: Any.IS_NULL, GOOD, JAVA_LANG_INT, Any.IS_UNDEFINED, GOOD,
045: JAVA_LANG_INT, Any.IS_NEG_INF, POOR, JAVA_LANG_INT,
046: Any.IS_INF, POOR, JAVA_LANG_INT, -1, NO,
047:
048: INT, Any.IS_INT, BEST, INT, Any.IS_NEG_INF, POOR, INT,
049: Any.IS_INF, POOR, INT, -1, NO,
050:
051: JAVA_LANG_LONG, Any.IS_INT, BEST, JAVA_LANG_LONG,
052: Any.IS_NULL, GOOD, JAVA_LANG_LONG, Any.IS_UNDEFINED, GOOD,
053: JAVA_LANG_LONG, Any.IS_NEG_INF, POOR, JAVA_LANG_LONG,
054: Any.IS_INF, POOR, JAVA_LANG_LONG, -1, NO,
055:
056: LONG, Any.IS_INT, BEST, LONG, Any.IS_NEG_INF, POOR, LONG,
057: Any.IS_INF, POOR, LONG, -1, NO,
058:
059: JAVA_LANG_FLOAT, Any.IS_DOUBLE, BEST, JAVA_LANG_FLOAT,
060: Any.IS_INT, GOOD, JAVA_LANG_FLOAT, Any.IS_NULL, GOOD,
061: JAVA_LANG_FLOAT, Any.IS_UNDEFINED, GOOD, JAVA_LANG_FLOAT,
062: Any.IS_NEG_INF, POOR, JAVA_LANG_FLOAT, Any.IS_INF, POOR,
063: JAVA_LANG_FLOAT, -1, NO,
064:
065: FLOAT, Any.IS_DOUBLE, BEST, FLOAT, Any.IS_INT, GOOD, FLOAT,
066: Any.IS_NEG_INF, POOR, FLOAT, Any.IS_INF, POOR, FLOAT, -1,
067: NO,
068:
069: JAVA_LANG_DOUBLE, Any.IS_DOUBLE, BEST, JAVA_LANG_DOUBLE,
070: Any.IS_INT, GOOD, JAVA_LANG_DOUBLE, Any.IS_NULL, GOOD,
071: JAVA_LANG_DOUBLE, Any.IS_UNDEFINED, GOOD, JAVA_LANG_DOUBLE,
072: Any.IS_NEG_INF, POOR, JAVA_LANG_DOUBLE, Any.IS_INF, POOR,
073: JAVA_LANG_DOUBLE, -1, NO,
074:
075: DOUBLE, Any.IS_DOUBLE, BEST, DOUBLE, Any.IS_INT, GOOD,
076: DOUBLE, Any.IS_NEG_INF, POOR, DOUBLE, Any.IS_INF, POOR,
077: DOUBLE, -1, NO,
078:
079: BOOLEAN_ARRAY, Any.IS_CLASS, MAYBE, BOOLEAN_ARRAY, -1, NO,
080:
081: BYTE_ARRAY, Any.IS_BINARY, BEST, BYTE_ARRAY, -1, NO,
082:
083: CHAR_ARRAY, Any.IS_STRING, GOOD, CHAR_ARRAY, Any.IS_BUFFER,
084: GOOD, CHAR_ARRAY, Any.IS_CLASS, MAYBE, CHAR_ARRAY, -1, NO,
085:
086: SHORT_ARRAY, Any.IS_CLASS, MAYBE, SHORT_ARRAY, -1, NO,
087:
088: INT_ARRAY, Any.IS_CLASS, MAYBE, INT_ARRAY, -1, NO,
089:
090: LONG_ARRAY, Any.IS_CLASS, MAYBE, LONG_ARRAY, -1, NO,
091:
092: FLOAT_ARRAY, Any.IS_CLASS, MAYBE, FLOAT_ARRAY, -1, NO,
093:
094: DOUBLE_ARRAY, Any.IS_CLASS, MAYBE, DOUBLE_ARRAY, -1, NO,
095:
096: JAVA_LANG_STRING, Any.IS_STRING, BEST, JAVA_LANG_STRING,
097: Any.IS_BUFFER, GOOD, JAVA_LANG_STRING, Any.IS_BINARY, GOOD,
098: JAVA_LANG_STRING, -1, POOR,
099:
100: JAVA_LANG_STRINGBUFFER, Any.IS_BUFFER, BEST,
101: JAVA_LANG_STRINGBUFFER, Any.IS_STRING, GOOD,
102: JAVA_LANG_STRINGBUFFER, Any.IS_BINARY, GOOD,
103: JAVA_LANG_STRINGBUFFER, -1, POOR,
104:
105: JAVA_LANG_STRING_ARRAY, Any.IS_CLASS, MAYBE,
106: JAVA_LANG_STRING_ARRAY, -1, NO,
107:
108: JAVA_LANG_NUMBER, Any.IS_INT, BEST, JAVA_LANG_NUMBER,
109: Any.IS_DOUBLE, BEST, JAVA_LANG_NUMBER, Any.IS_CLASS, MAYBE,
110: JAVA_LANG_NUMBER, -1, NO,
111:
112: JAVA_MATH_BIGINTEGER, Any.IS_INT, BEST,
113: JAVA_MATH_BIGINTEGER, Any.IS_CLASS, MAYBE,
114: JAVA_MATH_BIGINTEGER, -1, NO,
115:
116: JAVA_MATH_BIGDECIMAL, Any.IS_DOUBLE, BEST,
117: JAVA_MATH_BIGDECIMAL, Any.IS_INT, GOOD,
118: JAVA_MATH_BIGDECIMAL, Any.IS_CLASS, MAYBE,
119: JAVA_MATH_BIGDECIMAL, -1, NO,
120:
121: ANVIL_CORE_ANY, -1, BEST,
122:
123: JAVA_LANG_OBJECT, Any.IS_CLASS, MAYBE, JAVA_LANG_OBJECT,
124: -1, NO,
125:
126: JAVA_LANG_OBJECT_ARRAY, Any.IS_CLASS, MAYBE,
127: JAVA_LANG_OBJECT_ARRAY, -1, NO,
128:
129: };
130:
131: public static final void main(String[] args) {
132: int[][] t = new int[MAX_TYPES][MAX_ANYS];
133: int n = MATCH.length / 3;
134: for (int i = 0; i < n; i++) {
135: int target = MATCH[i * 3];
136: int source = MATCH[i * 3 + 1];
137: int match = MATCH[i * 3 + 2];
138: if (source == -1) {
139: for (int x = 0; x < MAX_ANYS; x++) {
140: if (t[target][x] == 0) {
141: t[target][x] = match;
142: }
143: }
144: } else {
145: t[target][source] = match;
146: }
147: }
148: System.out.println("{");
149: for (int y = 0; y < MAX_TYPES; y++) {
150: System.out.print(" ");
151: for (int x = 0; x < MAX_ANYS; x++) {
152: System.out.print(t[y][x]);
153: System.out.print(", ");
154: }
155: System.out.print("// ");
156: System.out.println(TYPES[y]);
157: }
158: System.out.println("};");
159: }
160: }
|