1 | How to add new kernel commands |
---|
2 | |
---|
3 | Example: bla |
---|
4 | |
---|
5 | - add a new CMD token to tok.h (in alphabetic order): |
---|
6 | .... |
---|
7 | BLA_CMD, |
---|
8 | ... |
---|
9 | - decide, how many argument bla should have and find the tok_type: |
---|
10 | 1: CMD_1 |
---|
11 | 2: CMD_2 |
---|
12 | 3:Â CMD_3 |
---|
13 | 1 or 2: CMD_12 |
---|
14 | 1 or 3: CMD_13 |
---|
15 | 2 or 3: CMD_23 |
---|
16 | 1, 2 or 3: CMD_123 |
---|
17 | not covered above: CMD_M |
---|
18 | |
---|
19 | - add a line describing the name, the token and the tok_type |
---|
20 | to array cmds in Singular/table.h: |
---|
21 | { "bla", 0, BLA_CMD, CMD_1}, |
---|
22 | (the array is sorted by the name). |
---|
23 | |
---|
24 | - choose the requirements: one from each group, combined by | |
---|
25 | ALLOW_PLURAL: non-commutative rings allowed |
---|
26 | NO_PLURAL: non-commutative rings not allowed |
---|
27 | |
---|
28 | ALLOW_RING: coefficients/cring elements may be a ring |
---|
29 | NO_RING: coefficients/cring elements must be a field |
---|
30 | |
---|
31 | ALLOW_ZERODIVISOR: coefficients/cring elements may be zero divisors |
---|
32 | NO_ZERODIVISOR: coefficients/cring elements must be a domain |
---|
33 | |
---|
34 | if a requirement from a group is ommited, |
---|
35 | the defaults are: NO_PLURAL | NO_RING | ALLOW_ZERODIVISOR |
---|
36 | |
---|
37 | - add one (or more) lines for the procedures to call: |
---|
38 | if there is more than one line, all lines for the same operation |
---|
39 | must directly following each other within dArith* |
---|
40 | |
---|
41 | if tok_type is CMD_1, CND_12, CMD_13, CMD_123, |
---|
42 | to dArith1: |
---|
43 | ,{D(jjBLAH1), BLA_CMD, <return type>, <argument type> , ALLOW_PLURAL |ALLOW_RING} |
---|
44 | |
---|
45 | analog for CMD_12, CMD_2, CMD_23, CMD_123 |
---|
46 | to dArith2: |
---|
47 | ,{D(jjBLAH2), BLA_CMD, <return type>, <arg1 type>, <arg2 type>, ALLOW_PLURAL |ALLOW_RING} |
---|
48 | |
---|
49 | analog for CMD_13, CMD_23, CMD_123, CMD_3 |
---|
50 | to dArith3: |
---|
51 | ,{D(jjBLAH3), BLA_CMD, <return type>, <arg1 type>, <arg2 type>, <arg3 type>, ALLOW_PLURAL |ALLOW_RING} |
---|
52 | |
---|
53 | CMD_M is different: |
---|
54 | ,{D(jjBLA_M), BLA_CMD, <return type>, <number of arguments>, ALLOW_PLURAL |ALLOW_RING} |
---|
55 | |
---|
56 | |
---|
57 | where a negative "number of arguments" represents: |
---|
58 | -1: any number of arguments |
---|
59 | -2: any number of arguments >0 |
---|
60 | |
---|
61 | Remark: the wrapper routines jjBLA* should be implemented as |
---|
62 | static routines in Singular/iparith.cc |
---|
63 | |
---|
64 | Remark: valid types for return type/arguments type are: |
---|
65 | - types from table.h: cmds with tok_type ROOT_DECL |
---|
66 | - types from table.h: cmds with tok_type ROOT_DECL_LIST |
---|
67 | - types from table.h: cmds with tok_type RING_DECL |
---|
68 | (require a base ring/currRing!=NULL) |
---|
69 | - types from table.h: cmds with tok_type RING_DECL_LIST |
---|
70 | (require a base ring/currRing!=NULL) |
---|
71 | - matrix types: INTMAT_CMD, BIGINTMAT_CMD, MATRIX_CMD |
---|
72 | (MATRIX_CMD requires a base ring/currRing!=NULL) |
---|
73 | - pseudo types for arguments: |
---|
74 | IDHDL: argument must be an interpreter variable |
---|
75 | ANY_TYPE: changes to pseudo data (for "defined", "typeof", etc.) |
---|
76 | - pseudo types for results: |
---|
77 | NONE: void |
---|
78 | ANY_TYPE: the jjBLA* routine decides about the return type |
---|
79 | (including NONE) |
---|
80 | |
---|
81 | Remark: the order of these lines is important: |
---|
82 | first the interpreter tries a perfect match of the data types, |
---|
83 | but, if none is found, the second pass tries automatic type conversion |
---|
84 | starting with the first line: |
---|
85 | for example: bla(<matrix>,<module>) |
---|
86 | ,{D(jjBLAH21), BLA_CMD, <return type>, MATRIX_CMD, MATRIX_CMD, ALLOW_PLURAL |ALLOW_RING} |
---|
87 | ,{D(jjBLAH22), BLA_CMD, <return type>, MODUL_CMD, MODUL_CMD, ALLOW_PLURAL |ALLOW_RING} |
---|
88 | would call jjBLAH21, while |
---|
89 | ,{D(jjBLAH22), BLA_CMD, <return type>, MODUL_CMD, MODUL_CMD, ALLOW_PLURAL |ALLOW_RING} |
---|
90 | ,{D(jjBLAH21), BLA_CMD, <return type>, MATRIX_CMD, MATRIX_CMD, ALLOW_PLURAL |ALLOW_RING} |
---|
91 | would call jjBLAH22. |
---|
92 | If certain conversions should not be allowed, add a line/several lines like: |
---|
93 | ,{jjWRONG, BLA_CMD, NONE, MATRIX_CMD, MODUL_CMD, ALLOW_PLURAL |ALLOW_RING} |
---|
94 | at the end of the block with operations for "bla". |
---|
95 | |
---|
96 | Remark: alias: 0: normal reserved word |
---|
97 | 1: alias for an reserver word: allowed as input, never as output |
---|
98 | 2: outdated alias: allowed as input, never as output, |
---|
99 | output a warning at first use |
---|