lscript_typecheck.cpp

Go to the documentation of this file.
00001 
00032 #include "linden_common.h"
00033 
00034 #include "lscript_tree.h"
00035 
00036 /*
00037   LScript automatic type casting
00038 
00039   LST_INTEGER                   -> LST_INTEGER
00040 
00041   LST_FLOATINGPOINT             -> LST_FLOATINGPOINT
00042   LST_INTEGER                   -> LST_FLOATINGPOINT
00043 
00044   LST_FLOATINGPOINT             -> LST_STRING
00045   LST_INTEGER                   -> LST_STRING
00046   LST_STRING                    -> LST_STRING
00047   LST_VECTOR                    -> LST_STRING
00048   LST_QUATERNION                -> LST_STRING
00049   LST_LIST                              -> LST_STRING
00050 
00051   LST_VECTOR                    -> LST_VECTOR
00052   
00053   LST_QUATERNION                -> LST_QUATERNION
00054   
00055   LST_FLOATINGPOINT             -> LST_LIST
00056   LST_INTEGER                   -> LST_LIST
00057   LST_STRING                    -> LST_LIST
00058   LST_VECTOR                    -> LST_LIST
00059   LST_QUATERNION                -> LST_LIST
00060   LST_LIST                              -> LST_LIST
00061 */
00062 
00063 LSCRIPTType implicit_casts(LSCRIPTType left_side, LSCRIPTType right_side)
00064 {
00065         switch(left_side)
00066         {
00067                 // shouldn't be doing an operation on void types
00068         case LST_NULL:
00069                 return LST_NULL;
00070         // shouldn't be doing an operation on undefined types
00071         case LST_UNDEFINED:
00072                 return LST_UNDEFINED;
00073         // only integers can become integers
00074         case LST_INTEGER:
00075                 switch(right_side)
00076                 {
00077                 case LST_INTEGER:
00078                         return LST_INTEGER;
00079                 default:
00080                         return LST_UNDEFINED;
00081                 }
00082         // only integers and floats can become floats
00083         case LST_FLOATINGPOINT:
00084                 switch(right_side)
00085                 {
00086                 case LST_INTEGER:
00087                 case LST_FLOATINGPOINT:
00088                         return LST_FLOATINGPOINT;
00089                 default:
00090                         return LST_UNDEFINED;
00091                 }
00092         // only strings and keys can become strings
00093         case LST_STRING:
00094                 switch(right_side)
00095                 {
00096                 case LST_STRING:
00097                 case LST_KEY:
00098                         return LST_STRING;
00099                 default:
00100                         return LST_UNDEFINED;
00101                 }
00102         // only strings and keys can become keys
00103         case LST_KEY:
00104                 switch(right_side)
00105                 {
00106                 case LST_STRING:
00107                 case LST_KEY:
00108                         return LST_KEY;
00109                 default:
00110                         return LST_UNDEFINED;
00111                 }
00112         // only vectors can become vectors
00113         case LST_VECTOR:
00114                 switch(right_side)
00115                 {
00116                 case LST_VECTOR:
00117                         return LST_VECTOR;
00118                 default:
00119                         return LST_UNDEFINED;
00120                 }
00121         // only quaternions can become quaternions
00122         case LST_QUATERNION:
00123                 switch(right_side)
00124                 {
00125                 case LST_QUATERNION:
00126                         return LST_QUATERNION;
00127                 default:
00128                         return LST_UNDEFINED;
00129                 }
00130         // only lists can become lists
00131         case LST_LIST:
00132                 switch(right_side)
00133                 {
00134                 case LST_LIST:
00135                         return LST_LIST;
00136                 default:
00137                         return LST_UNDEFINED;
00138                 }
00139         default:
00140                 return LST_UNDEFINED;
00141         }
00142 }
00143 
00144 LSCRIPTType promote(LSCRIPTType left_side, LSCRIPTType right_side)
00145 {
00146         LSCRIPTType type;
00147         type = implicit_casts(left_side, right_side);
00148         if (type != LST_UNDEFINED)
00149         {
00150                 return type;
00151         }
00152         type = implicit_casts(right_side, left_side);
00153         if (type != LST_UNDEFINED)
00154         {
00155                 return type;
00156         }
00157         return LST_UNDEFINED;
00158 }
00159 
00160 BOOL legal_assignment(LSCRIPTType left_side, LSCRIPTType right_side)
00161 {
00162         // this is to prevent cascading errors
00163         if (  (left_side == LST_UNDEFINED)
00164                 ||(right_side == LST_UNDEFINED))
00165         {
00166                 return TRUE;
00167         }
00168 
00169         if (implicit_casts(left_side, right_side) != LST_UNDEFINED)
00170         {
00171                 return TRUE;
00172         }
00173         else
00174         {
00175                 return FALSE;
00176         }
00177 }
00178 
00179 BOOL legal_casts(LSCRIPTType cast, LSCRIPTType base)
00180 {
00181         switch(base)
00182         {
00183         // shouldn't be doing an operation on void types
00184         case LST_NULL:
00185                 return FALSE;
00186         // shouldn't be doing an operation on undefined types
00187         case LST_UNDEFINED:
00188                 return FALSE;
00189         case LST_INTEGER:
00190                 switch(cast)
00191                 {
00192                 case LST_INTEGER:
00193                 case LST_FLOATINGPOINT:
00194                 case LST_STRING:
00195                 case LST_LIST:
00196                         return TRUE;
00197                         break;
00198                 default:
00199                         return FALSE;
00200                         break;
00201                 }
00202                 break;
00203         case LST_FLOATINGPOINT:
00204                 switch(cast)
00205                 {
00206                 case LST_INTEGER:
00207                 case LST_FLOATINGPOINT:
00208                 case LST_STRING:
00209                 case LST_LIST:
00210                         return TRUE;
00211                         break;
00212                 default:
00213                         return FALSE;
00214                         break;
00215                 }
00216                 break;
00217         case LST_STRING:
00218                 switch(cast)
00219                 {
00220                 case LST_INTEGER:
00221                 case LST_FLOATINGPOINT:
00222                 case LST_STRING:
00223                 case LST_KEY:
00224                 case LST_VECTOR:
00225                 case LST_QUATERNION:
00226                 case LST_LIST:
00227                         return TRUE;
00228                         break;
00229                 default:
00230                         return FALSE;
00231                         break;
00232                 }
00233                 break;
00234         case LST_KEY:
00235                 switch(cast)
00236                 {
00237                 case LST_STRING:
00238                 case LST_KEY:
00239                 case LST_LIST:
00240                         return TRUE;
00241                         break;
00242                 default:
00243                         return FALSE;
00244                         break;
00245                 }
00246                 break;
00247         case LST_VECTOR:
00248                 switch(cast)
00249                 {
00250                 case LST_VECTOR:
00251                 case LST_STRING:
00252                 case LST_LIST:
00253                         return TRUE;
00254                         break;
00255                 default:
00256                         return FALSE;
00257                         break;
00258                 }
00259                 break;
00260         case LST_QUATERNION:
00261                 switch(cast)
00262                 {
00263                 case LST_QUATERNION:
00264                 case LST_STRING:
00265                 case LST_LIST:
00266                         return TRUE;
00267                         break;
00268                 default:
00269                         return FALSE;
00270                         break;
00271                 }
00272                 break;
00273         // lists can only be cast to lists and strings
00274         case LST_LIST:
00275                 switch(cast)
00276                 {
00277                 case LST_LIST:
00278                 case LST_STRING:
00279                         return TRUE;
00280                         break;
00281                 default:
00282                         return FALSE;
00283                         break;
00284                 }
00285                 break;
00286         default:
00287                 return FALSE;
00288                 break;
00289         }
00290 }
00291 
00292 LSCRIPTType gSupportedExpressionArray[LET_EOF][LST_EOF][LST_EOF];
00293 
00294 void init_supported_expressions(void)
00295 {
00296         S32 i, j, k;
00297         // zero out, then set the ones that matter
00298         for (i = 0; i < LET_EOF; i++)
00299         {
00300                 for (j = 0; j < LST_EOF; j++)
00301                 {
00302                         for (k = 0; k < LST_EOF; k++)
00303                         {
00304                                 gSupportedExpressionArray[i][j][k] = LST_NULL;
00305                         }
00306                 }
00307         }
00308 
00309         // LET_ASSIGNMENT
00310         gSupportedExpressionArray[LET_ASSIGNMENT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00311         gSupportedExpressionArray[LET_ASSIGNMENT][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00312         gSupportedExpressionArray[LET_ASSIGNMENT][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00313         gSupportedExpressionArray[LET_ASSIGNMENT][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00314         gSupportedExpressionArray[LET_ASSIGNMENT][LST_STRING][LST_STRING] = LST_STRING;
00315         gSupportedExpressionArray[LET_ASSIGNMENT][LST_KEY][LST_KEY] = LST_KEY;
00316         gSupportedExpressionArray[LET_ASSIGNMENT][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
00317         gSupportedExpressionArray[LET_ASSIGNMENT][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00318         gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_INTEGER] = LST_LIST;
00319         gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
00320         gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_STRING] = LST_LIST;
00321         gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_KEY] = LST_LIST;
00322         gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_VECTOR] = LST_LIST;
00323         gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_QUATERNION] = LST_LIST;
00324         gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_LIST] = LST_LIST;
00325 
00326         // LET_ADD_ASSIGN
00327         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00328         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00329         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00330         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_STRING][LST_STRING] = LST_STRING;
00331         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
00332         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00333         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_INTEGER] = LST_LIST;
00334         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
00335         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_STRING] = LST_LIST;
00336         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_KEY] = LST_LIST;
00337         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_VECTOR] = LST_LIST;
00338         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_QUATERNION] = LST_LIST;
00339         gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_LIST] = LST_LIST;
00340 
00341         // LET_SUB_ASSIGN
00342         gSupportedExpressionArray[LET_SUB_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00343         gSupportedExpressionArray[LET_SUB_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00344         gSupportedExpressionArray[LET_SUB_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00345         gSupportedExpressionArray[LET_SUB_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
00346         gSupportedExpressionArray[LET_SUB_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00347 
00348         // LET_MUL_ASSIGN
00349         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00350         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00351         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00352         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00353         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
00354         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_VECTOR] = LST_VECTOR;
00355         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
00356         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_VECTOR] = LST_VECTOR;
00357         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_FLOATINGPOINT;
00358         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
00359         gSupportedExpressionArray[LET_MUL_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00360 
00361         // LET_DIV_ASSIGN
00362         gSupportedExpressionArray[LET_DIV_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00363         gSupportedExpressionArray[LET_DIV_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00364         gSupportedExpressionArray[LET_DIV_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00365         gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
00366         gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
00367         gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
00368         gSupportedExpressionArray[LET_DIV_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00369 
00370         // LET_MOD_ASSIGN
00371         gSupportedExpressionArray[LET_MOD_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00372         gSupportedExpressionArray[LET_MOD_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
00373 
00374         // LET_EQUALITY
00375         gSupportedExpressionArray[LET_EQUALITY][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00376         gSupportedExpressionArray[LET_EQUALITY][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
00377         gSupportedExpressionArray[LET_EQUALITY][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
00378         gSupportedExpressionArray[LET_EQUALITY][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
00379         gSupportedExpressionArray[LET_EQUALITY][LST_STRING][LST_STRING] = LST_INTEGER;
00380         gSupportedExpressionArray[LET_EQUALITY][LST_STRING][LST_KEY] = LST_INTEGER;
00381         gSupportedExpressionArray[LET_EQUALITY][LST_KEY][LST_STRING] = LST_INTEGER;
00382         gSupportedExpressionArray[LET_EQUALITY][LST_KEY][LST_KEY] = LST_INTEGER;
00383         gSupportedExpressionArray[LET_EQUALITY][LST_VECTOR][LST_VECTOR] = LST_INTEGER;
00384         gSupportedExpressionArray[LET_EQUALITY][LST_QUATERNION][LST_QUATERNION] = LST_INTEGER;
00385         gSupportedExpressionArray[LET_EQUALITY][LST_LIST][LST_LIST] = LST_INTEGER;
00386 
00387         // LET_NOT_EQUALS
00388         gSupportedExpressionArray[LET_NOT_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00389         gSupportedExpressionArray[LET_NOT_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
00390         gSupportedExpressionArray[LET_NOT_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
00391         gSupportedExpressionArray[LET_NOT_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
00392         gSupportedExpressionArray[LET_NOT_EQUALS][LST_STRING][LST_STRING] = LST_INTEGER;
00393         gSupportedExpressionArray[LET_NOT_EQUALS][LST_STRING][LST_KEY] = LST_INTEGER;
00394         gSupportedExpressionArray[LET_NOT_EQUALS][LST_KEY][LST_STRING] = LST_INTEGER;
00395         gSupportedExpressionArray[LET_NOT_EQUALS][LST_KEY][LST_KEY] = LST_INTEGER;
00396         gSupportedExpressionArray[LET_NOT_EQUALS][LST_VECTOR][LST_VECTOR] = LST_INTEGER;
00397         gSupportedExpressionArray[LET_NOT_EQUALS][LST_QUATERNION][LST_QUATERNION] = LST_INTEGER;
00398         gSupportedExpressionArray[LET_NOT_EQUALS][LST_LIST][LST_LIST] = LST_INTEGER;
00399 
00400         // LET_LESS_EQUALS
00401         gSupportedExpressionArray[LET_LESS_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00402         gSupportedExpressionArray[LET_LESS_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
00403         gSupportedExpressionArray[LET_LESS_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
00404         gSupportedExpressionArray[LET_LESS_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
00405 
00406         // LET_GREATER_EQUALS
00407         gSupportedExpressionArray[LET_GREATER_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00408         gSupportedExpressionArray[LET_GREATER_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
00409         gSupportedExpressionArray[LET_GREATER_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
00410         gSupportedExpressionArray[LET_GREATER_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
00411 
00412         // LET_LESS_THAN
00413         gSupportedExpressionArray[LET_LESS_THAN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00414         gSupportedExpressionArray[LET_LESS_THAN][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
00415         gSupportedExpressionArray[LET_LESS_THAN][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
00416         gSupportedExpressionArray[LET_LESS_THAN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
00417 
00418         // LET_GREATER_THAN
00419         gSupportedExpressionArray[LET_GREATER_THAN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00420         gSupportedExpressionArray[LET_GREATER_THAN][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
00421         gSupportedExpressionArray[LET_GREATER_THAN][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
00422         gSupportedExpressionArray[LET_GREATER_THAN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
00423 
00424         // LET_PLUS
00425         gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00426         gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00427         gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00428         gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00429         gSupportedExpressionArray[LET_PLUS][LST_STRING][LST_STRING] = LST_STRING;
00430         gSupportedExpressionArray[LET_PLUS][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
00431         gSupportedExpressionArray[LET_PLUS][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00432         gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_INTEGER] = LST_LIST;
00433         gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
00434         gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_STRING] = LST_LIST;
00435         gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_KEY] = LST_LIST;
00436         gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_VECTOR] = LST_LIST;
00437         gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_QUATERNION] = LST_LIST;
00438         gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_LIST] = LST_LIST;
00439         gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_LIST] = LST_LIST;
00440         gSupportedExpressionArray[LET_PLUS][LST_STRING][LST_LIST] = LST_LIST;
00441         gSupportedExpressionArray[LET_PLUS][LST_KEY][LST_LIST] = LST_LIST;
00442         gSupportedExpressionArray[LET_PLUS][LST_VECTOR][LST_LIST] = LST_LIST;
00443         gSupportedExpressionArray[LET_PLUS][LST_QUATERNION][LST_LIST] = LST_LIST;
00444         gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_LIST] = LST_LIST;
00445 
00446         // LET_MINUS
00447         gSupportedExpressionArray[LET_MINUS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00448         gSupportedExpressionArray[LET_MINUS][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00449         gSupportedExpressionArray[LET_MINUS][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00450         gSupportedExpressionArray[LET_MINUS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00451         gSupportedExpressionArray[LET_MINUS][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
00452         gSupportedExpressionArray[LET_MINUS][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00453 
00454         // LET_TIMES
00455         gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00456         gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00457         gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00458         gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00459         gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
00460         gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_VECTOR] = LST_VECTOR;
00461         gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
00462         gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_VECTOR] = LST_VECTOR;
00463         gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_VECTOR] = LST_FLOATINGPOINT;
00464         gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
00465         gSupportedExpressionArray[LET_TIMES][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00466 
00467         // LET_DIVIDE
00468         gSupportedExpressionArray[LET_DIVIDE][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00469         gSupportedExpressionArray[LET_DIVIDE][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00470         gSupportedExpressionArray[LET_DIVIDE][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
00471         gSupportedExpressionArray[LET_DIVIDE][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
00472         gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
00473         gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
00474         gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
00475         gSupportedExpressionArray[LET_DIVIDE][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
00476 
00477         // LET_MOD
00478         gSupportedExpressionArray[LET_MOD][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00479         gSupportedExpressionArray[LET_MOD][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
00480 
00481         // LET_BIT_AND
00482         gSupportedExpressionArray[LET_BIT_AND][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00483 
00484         // LET_BIT_OR
00485         gSupportedExpressionArray[LET_BIT_OR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00486 
00487         // LET_BIT_XOR
00488         gSupportedExpressionArray[LET_BIT_XOR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00489 
00490         // LET_BOOLEAN_AND
00491         gSupportedExpressionArray[LET_BOOLEAN_AND][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00492 
00493         // LET_BOOLEAN_OR
00494         gSupportedExpressionArray[LET_BOOLEAN_OR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00495 
00496         // LET_SHIFT_LEFT
00497         gSupportedExpressionArray[LET_SHIFT_LEFT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00498 
00499         // LET_SHIFT_RIGHT
00500         gSupportedExpressionArray[LET_SHIFT_RIGHT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
00501 
00502         // LET_PARENTHESIS
00503         gSupportedExpressionArray[LET_PARENTHESIS][LST_INTEGER][LST_NULL] = LST_INTEGER;
00504         gSupportedExpressionArray[LET_PARENTHESIS][LST_FLOATINGPOINT][LST_NULL] = LST_INTEGER;
00505         gSupportedExpressionArray[LET_PARENTHESIS][LST_STRING][LST_NULL] = LST_INTEGER;
00506         gSupportedExpressionArray[LET_PARENTHESIS][LST_LIST][LST_NULL] = LST_INTEGER;
00507 
00508         // LET_UNARY_MINUS
00509         gSupportedExpressionArray[LET_UNARY_MINUS][LST_INTEGER][LST_NULL] = LST_INTEGER;
00510         gSupportedExpressionArray[LET_UNARY_MINUS][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
00511         gSupportedExpressionArray[LET_UNARY_MINUS][LST_VECTOR][LST_NULL] = LST_VECTOR;
00512         gSupportedExpressionArray[LET_UNARY_MINUS][LST_QUATERNION][LST_NULL] = LST_QUATERNION;
00513 
00514         // LET_BOOLEAN_NOT
00515         gSupportedExpressionArray[LET_BOOLEAN_NOT][LST_INTEGER][LST_NULL] = LST_INTEGER;
00516 
00517         // LET_BIT_NOT
00518         gSupportedExpressionArray[LET_BIT_NOT][LST_INTEGER][LST_NULL] = LST_INTEGER;
00519 
00520         // LET_PRE_INCREMENT
00521         gSupportedExpressionArray[LET_PRE_INCREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
00522         gSupportedExpressionArray[LET_PRE_INCREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
00523 
00524         // LET_PRE_DECREMENT
00525         gSupportedExpressionArray[LET_PRE_DECREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
00526         gSupportedExpressionArray[LET_PRE_DECREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
00527 
00528         // LET_POST_INCREMENT
00529         gSupportedExpressionArray[LET_POST_INCREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
00530         gSupportedExpressionArray[LET_POST_INCREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
00531 
00532         // LET_POST_DECREMENT
00533         gSupportedExpressionArray[LET_POST_DECREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
00534         gSupportedExpressionArray[LET_POST_DECREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
00535 }
00536 
00537 BOOL legal_binary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTType right_side, LSCRIPTExpressionType expression)
00538 {
00539         if (  (left_side == LST_UNDEFINED)
00540                 ||(right_side == LST_UNDEFINED))
00541         {
00542                 result = LST_UNDEFINED;
00543                 return TRUE;
00544         }
00545 
00546         if (  (left_side == LST_NULL)
00547                 ||(right_side == LST_NULL))
00548         {
00549                 result = LST_UNDEFINED;
00550                 return FALSE;
00551         }
00552 
00553         result = gSupportedExpressionArray[expression][left_side][right_side];
00554         if (result)
00555                 return TRUE;
00556         else
00557         {
00558                 result = LST_UNDEFINED;
00559                 return FALSE;
00560         }
00561 }
00562 
00563 BOOL legal_unary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTExpressionType expression)
00564 {
00565         if (left_side == LST_UNDEFINED)
00566         {
00567                 result = LST_UNDEFINED;
00568                 return TRUE;
00569         }
00570 
00571         if (left_side == LST_NULL)
00572         {
00573                 result = LST_UNDEFINED;
00574                 return FALSE;
00575         }
00576 
00577         result = gSupportedExpressionArray[expression][left_side][LST_NULL];
00578         if (result)
00579                 return TRUE;
00580         else
00581         {
00582                 result = LST_UNDEFINED;
00583                 return FALSE;
00584         }
00585 }

Generated on Thu Jul 1 06:09:54 2010 for Second Life Viewer by  doxygen 1.4.7