summaryrefslogtreecommitdiffstats
path: root/scilab/modules/core
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab.org>2010-03-19 17:27:45 +0100
committerSylvestre Ledru <sylvestre.ledru@scilab.org>2010-03-19 17:27:45 +0100
commit1a602260d1f08d2bd08cd3c2ed45ff57df882af7 (patch)
tree019d26c21683b0330ab096b7d574cf7cafe9242c /scilab/modules/core
parent29f0c81ab4fc5dc69051518f5c94a3368e6c0bcb (diff)
downloadscilab-1a602260d1f08d2bd08cd3c2ed45ff57df882af7.zip
scilab-1a602260d1f08d2bd08cd3c2ed45ff57df882af7.tar.gz
Checkstyle
Diffstat (limited to 'scilab/modules/core')
-rw-r--r--scilab/modules/core/src/cpp/search_functions.cpp217
1 files changed, 125 insertions, 92 deletions
diff --git a/scilab/modules/core/src/cpp/search_functions.cpp b/scilab/modules/core/src/cpp/search_functions.cpp
index 539983d..2ba2cae 100644
--- a/scilab/modules/core/src/cpp/search_functions.cpp
+++ b/scilab/modules/core/src/cpp/search_functions.cpp
@@ -6,104 +6,137 @@ extern "C" {
6#include "stack-def.h" /* C2F(basbrk) */ 6#include "stack-def.h" /* C2F(basbrk) */
7#include "intmacr2tree.h" /*#define idstk(x,y) (C2F(vstk).idstk+(x-1)+(y-1)*nsiz) */ 7#include "intmacr2tree.h" /*#define idstk(x,y) (C2F(vstk).idstk+(x-1)+(y-1)*nsiz) */
8 8
9void C2F(siflibs)(int* id, int* k_ptr, int* istr, int* lbibn, int* nbibn, int* ilp, int* nn, int* should_return); 9 void C2F(siflibs)(int* id, int* k_ptr, int* istr, int* lbibn, int* nbibn, int* ilp, int* nn, int* should_return);
10void C2F(sivars)(int* id, int* should_return); 10 void C2F(sivars)(int* id, int* should_return);
11void C2F(namstr)(int* id, int* str, int* n, char const* job); 11 void C2F(namstr)(int* id, int* str, int* n, char const* job);
12} 12}
13 13
14namespace { 14namespace
15 char const f_true= 1; 15{
16 char const f_false=0; 16 char const f_true = 1;
17 int const percent= 56; 17 char const f_false = 0;
18 int const nclas= 29; 18 int const percent = 56;
19 char const from_id=1; 19 int const nclas = 29;
20 20 char const from_id = 1;
21 // directly convert from id to upper char 21
22 int upper_char(int id){ return std::abs((int)((id & 0x80) ? (id |0xffffff00) : (id & 0xff))); } 22 // directly convert from id to upper char
23 // gives the discriminating char (either first of second if first=percent) 23 int upper_char(int id)
24 int id_char(int const* id){ 24 {
25 int ch(upper_char(*id)); 25 /* @TODO: add comment about 0xffffff00 and the other */
26 if(ch == percent){ 26 return std::abs((int)((id & 0x80) ? (id |0xffffff00) : (id & 0xff)));
27 ch= upper_char((*id)>>8); 27 }
28 } 28
29 return ch; 29 // gives the discriminating char (either first of second if first=percent)
30 } 30 int id_char(int const* id)
31 {
32 int ch(upper_char(*id));
33 if(ch == percent)
34 {
35 return upper_char((*id)>>8);
36 }
37 return ch;
38 }
31} 39}
32// search for an id in the libraries 40// search for an id in the libraries
33void C2F(siflibs)(int* id, int* k_ptr, int* istr, int* lbibn_ptr, int* nbibn_ptr, int* ilp_ptr, int* nn_ptr, int* should_return){ 41void C2F(siflibs)(int* id, int* k_ptr, int* istr, int* lbibn_ptr, int* nbibn_ptr, int* ilp_ptr, int* nn_ptr, int* should_return)
34 static int const* const lstk_ptr = (int*)C2F(vstk).lstk-1; 42{
35 static int const* const istk_ptr = ((int*)C2F(stack).Stk)-1; 43
36 *should_return= f_false; 44 static int const* const lstk_ptr = (int*)C2F(vstk).lstk-1;
37 int k, ilp, nbibn, lbibn; 45 static int const* const istk_ptr = ((int*)C2F(stack).Stk)-1;
38 for(k= Bot; k < C2F(vstk).isiz; ++k){ 46 int k, ilp, nbibn, lbibn;
39 int il=iadr(lstk_ptr[k]); 47
40 int ip; 48 *should_return= f_false;
41 if(istk_ptr[il] == sci_lib){ 49
42 nbibn=istk_ptr[il+1]; 50 for (k= Bot; k < C2F(vstk).isiz; ++k)
43 lbibn=il+2; 51 {
44 il+= nbibn+2; 52 int il = iadr(lstk_ptr[k]);
45 ilp=il+1; 53 int ip;
46 ip=std::max(1, id_char(id)-9); 54
47 if(ip <= nclas){ 55 if (istk_ptr[il] == sci_lib)
48 int n=istk_ptr[ilp+ip] -istk_ptr[ilp+ip-1]; 56 {
49 if(n != 0){ 57 nbibn=istk_ptr[il+1];
50 int iln= ilp+nclas+1+(istk_ptr[ilp+ip-1]-1)*nsiz; 58 lbibn=il+2;
51 for(int i= 1; i<=n; ++i, iln+= nsiz){ 59 il+= nbibn+2;
52 if(eq_n<nsiz>(id, istk_ptr+iln)){ // 39 60 ilp=il+1;
53 if((Fin == -1) || (Fin == -3)){ 61 ip=std::max(1, id_char(id)-9);
54 C2F(com).fun= k; 62 if (ip <= nclas)
55 Fin= i; 63 {
56 *should_return= f_true; 64
57 return; 65 int n=istk_ptr[ilp+ip] -istk_ptr[ilp+ip-1];
58 } 66 if (n != 0)
59 Fin= i; 67 {
60 if(C2F(errgst).err1 != 0){ 68 int iln= ilp+nclas+1+(istk_ptr[ilp+ip-1]-1)*nsiz;
61 C2F(com).fun= Fin= 0; 69
62 *should_return= f_true; 70 for (int i= 1; i<=n; ++i, iln+= nsiz)
63 return; 71 {
72 if(eq_n<nsiz>(id, istk_ptr+iln))
73 { // 39
74 if((Fin == -1) || (Fin == -3))
75 {
76 C2F(com).fun= k;
77 Fin= i;
78 *should_return= f_true;
79 return;
80 }
81
82 Fin= i;
83 if(C2F(errgst).err1 != 0)
84 {
85 C2F(com).fun= Fin= 0;
86 *should_return= f_true;
87 return;
88 }
89
90 C2F(namstr)(id,istr, nn_ptr, &from_id);
91 *k_ptr= k;
92 *lbibn_ptr= lbibn;
93 *nbibn_ptr= nbibn;
94 *ilp_ptr= ilp;
95 *should_return= f_false;
96 return;
97 }
98 }
99 }
100
101 }
102
64 } 103 }
65 C2F(namstr)(id,istr, nn_ptr, &from_id); 104
66 *k_ptr= k; 105 }
67 *lbibn_ptr= lbibn; 106 C2F(com).fun= Fin= 0;
68 *nbibn_ptr= nbibn; 107 *should_return= f_true;
69 *ilp_ptr= ilp; 108 return;
70 *should_return= f_false;
71 return;
72 }
73 }
74 }
75
76 }
77
78 }
79
80 }
81 C2F(com).fun= Fin= 0;
82 *should_return= f_true;
83 return;
84} 109}
85 110
86// search for an id in vars 111// search for an id in vars
87void C2F(sivars)(int* id, int* should_return){ 112void C2F(sivars)(int* id, int* should_return)
88 int* const lstk_ptr = (int*)C2F(vstk).lstk-1; 113{
89 114 int* const lstk_ptr = (int*)C2F(vstk).lstk-1;
90 int k; 115
91 // idstk(x,y) (C2F(vstk).idstk+(x-1)+(y-1)*nsiz) 116 int k;
92 int* id_addr=C2F(vstk).idstk; 117 // idstk(x,y) (C2F(vstk).idstk+(x-1)+(y-1)*nsiz)
93 for( *should_return= f_false, k= Bot, id_addr+=(k-1)*nsiz 118 int* id_addr=C2F(vstk).idstk;
94 ; k <= C2F(vstk).isiz && !eq_n<nsiz>(id_addr, id); ++k, id_addr+=nsiz){ 119 for( *should_return= f_false, k= Bot, id_addr+=(k-1)*nsiz;
95 } 120 k <= C2F(vstk).isiz && !eq_n<nsiz>(id_addr, id);
96 if( k <= C2F(vstk).isiz ){// eq_id 121 ++k, id_addr+=nsiz)
97 int il=lstk_ptr[k];//iadr() 122 {
98 il<<=1; 123 }
99 ++il; 124
100 if((*istk(il)!=sci_u_function) &&(*istk(il)!=sci_c_function)) { 125 if( k <= C2F(vstk).isiz )
101 C2F(com).fun= Fin= 0; 126 {// eq_id
102 *should_return= f_true; 127 int il=lstk_ptr[k];//iadr()
103 } 128 il<<=1;
104 C2F(com).fun= -1; 129 ++il;
105 Fin= k; 130
106 *should_return= f_true; 131 if((*istk(il)!=sci_u_function) &&(*istk(il)!=sci_c_function))
107 } 132 {
108 return; // *should_return= f_false; 133 C2F(com).fun= Fin= 0;
134 *should_return= f_true;
135 }
136
137 C2F(com).fun= -1;
138 Fin= k;
139 *should_return= f_true;
140 }
141 return; // *should_return= f_false;
109} 142}