#include <stdlib.h>#include "intersci-n.h"#include "getrhs.h"#include "crerhs.h"#include "check.h"Include dependency graph for opt.c:

Go to the source code of this file.
Functions | |
| void | WriteOptArg (FILE *f, VARPTR var) |
| void | WriteOptArgPhase2 (FILE *f, IVAR i) |
| void | OptMATRIX (FILE *f, VARPTR var) |
| void | OptOpointer (FILE *f, VARPTR var) |
| void | OptvarGetSize (char *optvar, char *lsize, char *ldata) |
Variables | |
| static char | size [MAXNAM] |
| static char | data [MAXNAM] |
| void OptMATRIX | ( | FILE * | f, | |
| VARPTR | var | |||
| ) |
Definition at line 138 of file opt.c.
References AddDeclare1(), ChangeForName2(), CHECKTAB, data, DEC_DATA, DEC_INT, Fprintf(), indent, MATRIX, SCALAR, SGetCDec(), SGetForTypeAbrev(), SGetForTypeStack(), size, STRING, var, and variables.
Referenced by WriteOptArgPhase2().
00139 { 00140 int opt_posi = basfun->NewMaxOpt - (basfun->nin - var->stack_position)-1; 00141 Fprintf(f,indent++,"if ( opts[%d].position == -1 ){\n",opt_posi); 00142 Fprintf(f,indent,"iopos++ ; opts[%d].position = iopos;\n",opt_posi); 00143 AddDeclare1(DEC_DATA,"%s xdat%d[]= %s, *dat%d = xdat%d", 00144 SGetCDec(var->for_type), 00145 opt_posi,data,opt_posi,opt_posi); 00146 AddDeclare1(DEC_INT,"m%d",var->stack_position); 00147 AddDeclare1(DEC_INT,"n%d",var->stack_position); 00148 AddDeclare1(DEC_INT,"l%d",var->stack_position); 00149 00150 switch ( var->type ) 00151 { 00152 case MATRIX : 00153 Fprintf(f,indent,"opts[%d].m = 1;opts[%d].n = %s; opts[%d].type = \"%s\";\n", 00154 opt_posi,opt_posi,size,opt_posi,SGetForTypeAbrev(var)); 00155 break; 00156 case STRING : 00157 Fprintf(f,indent,"opts[%d].m = %s;opts[%d].n = 1; opts[%d].type = \"%s\";\n", 00158 opt_posi,size,opt_posi,opt_posi,SGetForTypeAbrev(var)); 00159 break; 00160 case SCALAR: 00161 Fprintf(f,indent,"opts[%d].m = 1;opts[%d].n = 1;\n",opt_posi,opt_posi); 00162 break; 00163 00164 } 00165 Fprintf(f,indent,"CreateVarFromPtr(opts[%d].position,opts[%d].type,&opts[%d].m,&opts[%d].n,&dat%d);\n", 00166 opt_posi,opt_posi,opt_posi,opt_posi, 00167 opt_posi); 00168 Fprintf(f,indent,"opts[%d].l = VarPtr(opts[%d].position);\n",opt_posi, opt_posi); 00169 switch ( var->type ) 00170 { 00171 case MATRIX : 00172 ChangeForName2(variables[var->el[0]-1],"opts[%d].m",opt_posi); 00173 ChangeForName2(variables[var->el[1]-1],"opts[%d].n",opt_posi); 00174 break; 00175 case STRING : 00176 ChangeForName2(variables[var->el[0]-1],"opts[%d].m",opt_posi); 00177 break; 00178 } 00179 ChangeForName2(var,"%s(opts[%d].l)",SGetForTypeStack(var), opt_posi); 00180 Fprintf(f,--indent,"}\n"); 00181 Fprintf(f,indent," else { \n"); 00182 /* should be optimized to exploit dimension infos stored in opts */ 00183 Fprintf(f,indent++,"GetRhsVar(%d,\"%s\",&m%d,&n%d,&l%d);\n",var->stack_position, 00184 SGetForTypeAbrev(var),var->stack_position,var->stack_position,var->stack_position); 00185 (*(CHECKTAB[var->type].fonc))(f,var,0); 00186 Fprintf(f,--indent,"} \n"); 00187 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void OptOpointer | ( | FILE * | f, | |
| VARPTR | var | |||
| ) |
Definition at line 189 of file opt.c.
References AddDeclare1(), data, DEC_INT, Fprintf(), indent, and var.
Referenced by WriteOptArgPhase2().
00190 { 00191 00192 Fprintf(f,indent++,"if ( %sok == 0) {\n",var->name); 00193 Fprintf(f,indent,"%spos=iopos=iopos+1;\n",var->name); 00194 Fprintf(f,indent,"CreateSCO(iopos,&lr%d,%s);\n", 00195 var->stack_position,data); 00196 AddDeclare1(DEC_INT,"lr%d",var->stack_position); 00197 Fprintf(f,--indent,"}\n"); 00198 00199 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void OptvarGetSize | ( | char * | optvar, | |
| char * | lsize, | |||
| char * | ldata | |||
| ) |
Definition at line 209 of file opt.c.
00210 { 00211 int i,j=0,ok=0; 00212 for ( i = 0 ; i < (int) strlen(optvar) ; i++ ) 00213 { 00214 if ( optvar[i] == ')' ) 00215 { 00216 lsize[j++] = '\0'; break; 00217 } 00218 if ( ok ==1 ) lsize[j++]= optvar[i]; 00219 if ( optvar[i] == '(' ) ok =1 ; 00220 } 00221 if ( i < (int) strlen(optvar)) strcpy(ldata,optvar+i+1); 00222 ok=0; 00223 for ( i = 0 ; i < (int) strlen(ldata) ; i++ ) 00224 if ( ldata[i] == '/' ) 00225 { 00226 if (ok ==0 ) { 00227 ldata[i]='{';ok=1;} 00228 else 00229 ldata[i]='}'; 00230 } 00231 }
| void WriteOptArg | ( | FILE * | f, | |
| VARPTR | var | |||
| ) |
Definition at line 15 of file opt.c.
References AddDeclare(), AddDeclare1(), CRERHSTAB, DEC_DATA, DEC_INT, DEC_LOGICAL, Fprintf(), indent, MATRIX, MAXNAM, NAME, OptvarGetSize(), RHSTAB, SCALAR, SCIOPOINTER, SGetCDec(), SGetForTypeAbrev(), SGetForTypeStack(), STRING, VALUE, and var.
Referenced by WriteArgCheck().
00016 { 00017 char lsize[MAXNAM]; 00018 char ldata[MAXNAM]; 00019 00020 Fprintf(f,indent++,"if( Rhs <= %d) \n", 00021 var->stack_position-1 ); 00022 Fprintf(f,indent,"{\n"); 00023 00024 switch (var->opt_type) 00025 { 00026 case NAME: 00027 AddDeclare(DEC_LOGICAL,"optvarget"); 00028 Fprintf(f,indent,"if (.not.optvarget(fname,topk,%d,'%s ')) return\n", 00029 var->stack_position,var->opt_name); 00030 break; 00031 case VALUE: 00032 switch (var->type) 00033 { 00034 case SCALAR: 00035 (*(CRERHSTAB[var->type].fonc))(f,var); 00036 Fprintf(f,indent,"stk(lr%d)= %s\n",var->stack_position, 00037 var->opt_name); 00038 break; 00039 case MATRIX: 00040 OptvarGetSize(var->opt_name,lsize,ldata); 00041 00042 AddDeclare1(DEC_DATA,"%s dat%d[]= %s", 00043 SGetCDec(var->for_type), 00044 var->stack_position,ldata); 00045 Fprintf(f,indent,"m%d = 1;n%d = %s;\n",var->stack_position, 00046 var->stack_position,lsize); 00047 (*(CRERHSTAB[var->type].fonc))(f,var); 00048 AddDeclare1(DEC_INT,"un=1"); 00049 Fprintf(f,indent,"C2F(%scopy)(&m%d,dat%d,&un,%s(l%d),&un);\n", 00050 SGetForTypeAbrev(var), 00051 var->stack_position, 00052 var->stack_position, 00053 SGetForTypeStack(var),var->stack_position); 00054 00055 break; 00056 case STRING: 00057 Fprintf(f,indent,"m%d = %d\n",var->stack_position, 00058 strlen(var->opt_name)); 00059 (*(CRERHSTAB[var->type].fonc))(f,var); 00060 Fprintf(f,indent,"call stringcopy(m%d,'%s',cstk(lr%d))\n", 00061 var->stack_position,var->opt_name,var->stack_position); 00062 break; 00063 case SCIOPOINTER : 00064 (*(CRERHSTAB[var->type].fonc))(f,var); 00065 break; 00066 default: 00067 printf("Optional variable with value must be \"SCALAR\" or \"STRING\"\n"); 00068 exit(1); 00069 break; 00070 } 00071 break; 00072 } 00073 00074 Fprintf(f,indent--,"}\n"); 00075 Fprintf(f,indent++,"else\n"); 00076 Fprintf(f,indent,"{\n"); 00077 (*(RHSTAB[var->type].fonc))(f,var,0); 00078 Fprintf(f,indent--,"}\n"); 00079 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void WriteOptArgPhase2 | ( | FILE * | f, | |
| IVAR | i | |||
| ) |
Definition at line 86 of file opt.c.
References AddDeclare1(), ChangeForName2(), data, DEC_INT, Fprintf(), indent, MATRIX, NAME, OptMATRIX(), OptOpointer(), OptvarGetSize(), SCALAR, SCIOPOINTER, SGetForTypeStack(), size, STRING, VALUE, var, and variables.
Referenced by WriteFunctionCode().
00087 { 00088 VARPTR var = variables[basfun->in[i]-1]; 00089 int opt_posi = basfun->NewMaxOpt - (basfun->nin - var->stack_position)-1; 00090 Fprintf(f,indent,"/* default value to optional argument %s */\n",var->name); 00091 switch (var->opt_type) 00092 { 00093 case NAME: 00094 Fprintf(f,indent++,"if ( opts[%d].position == -1 ){\n",opt_posi); 00095 Fprintf(f,indent,"iopos++ ; opts[%d].position = iopos;\n",opt_posi); 00096 AddDeclare1(DEC_INT,"opt%d",opt_posi); 00097 Fprintf(f,indent,"GetMatrixptr(\"%s\",&opts[%d].m, &opts[%d].n,&opt%d);\n", 00098 var->opt_name,opt_posi,opt_posi,opt_posi); 00099 Fprintf(f,indent,"CreateVarFrom(opts[%d].position,\"d\",&opts[%d].m, &opts[%d].n,&opts[%d].l,&opt%d)\n", 00100 opt_posi,opt_posi,opt_posi,opt_posi,opt_posi); 00101 ChangeForName2(var,"%s(opts[%d].l)",SGetForTypeStack(var), opt_posi); 00102 Fprintf(f,--indent,"}\n"); 00103 break; 00104 case VALUE: 00105 switch (var->type) 00106 { 00107 00108 case SCALAR: 00109 sprintf(data,"{%s}",var->opt_name); 00110 OptvarGetSize(var->opt_name,size,data); 00111 OptMATRIX(f,var); 00112 break; 00113 00114 case MATRIX: 00115 OptvarGetSize(var->opt_name,size,data); 00116 OptMATRIX(f,var); 00117 break; 00118 case STRING: 00119 sprintf(size,"%d",strlen(var->opt_name)); 00120 sprintf(data,"\"%s\"",var->opt_name); 00121 OptMATRIX(f,var); 00122 break; 00123 case SCIOPOINTER : 00124 sprintf(size,"size-[%d]",strlen(var->opt_name)); 00125 sprintf(data,"%s",var->opt_name); 00126 OptOpointer(f,var); 00127 break; 00128 default: 00129 printf("Optional variable with value must be \"SCALAR\" or \"STRING\"\n"); 00130 exit(1); 00131 break; 00132 } 00133 break; 00134 } 00135 }
Here is the call graph for this function:

Here is the caller graph for this function:

char data[MAXNAM] [static] |
Definition at line 9 of file opt.c.
Referenced by __PARAMS(), BTI_add(), C2F(), get_data_property(), gsorts(), int_objfscanf(), intreadxls(), Load_primitives_from_file(), MakeXImage(), md5_file(), md5_finish(), mxDuplicateArray(), OptMATRIX(), OptOpointer(), ReadbdfFont(), SciChoiceFree(), TryChildren(), WriteArgCheck(), WriteOptArgPhase2(), XctCreate(), XmuCallInitializers(), XmuClientWindow(), XmuCvtStringToBitmap(), XmuLocatePixmapFile(), and XmuReadBitmapData().
1.5.1