PageRenderTime 649ms CodeModel.GetById 201ms app.highlight 251ms RepoModel.GetById 192ms app.codeStats 1ms

/indra/lscript/lscript_compile/lscript_typecheck.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 586 lines | 438 code | 48 blank | 100 comment | 24 complexity | cf11431d6203123dbf56b14f98340a0b MD5 | raw file
  1/** 
  2 * @file lscript_typecheck.cpp
  3 * @brief typechecks script
  4 *
  5 * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#include "linden_common.h"
 28
 29#include "lscript_tree.h"
 30
 31/*
 32  LScript automatic type casting
 33
 34  LST_INTEGER			-> LST_INTEGER
 35
 36  LST_FLOATINGPOINT		-> LST_FLOATINGPOINT
 37  LST_INTEGER			-> LST_FLOATINGPOINT
 38
 39  LST_FLOATINGPOINT		-> LST_STRING
 40  LST_INTEGER			-> LST_STRING
 41  LST_STRING			-> LST_STRING
 42  LST_VECTOR			-> LST_STRING
 43  LST_QUATERNION		-> LST_STRING
 44  LST_LIST				-> LST_STRING
 45
 46  LST_VECTOR			-> LST_VECTOR
 47  
 48  LST_QUATERNION		-> LST_QUATERNION
 49  
 50  LST_FLOATINGPOINT		-> LST_LIST
 51  LST_INTEGER			-> LST_LIST
 52  LST_STRING			-> LST_LIST
 53  LST_VECTOR			-> LST_LIST
 54  LST_QUATERNION		-> LST_LIST
 55  LST_LIST				-> LST_LIST
 56*/
 57
 58LSCRIPTType implicit_casts(LSCRIPTType left_side, LSCRIPTType right_side)
 59{
 60	switch(left_side)
 61	{
 62		// shouldn't be doing an operation on void types
 63	case LST_NULL:
 64		switch(right_side)
 65		{
 66		case LST_NULL:
 67			return LST_NULL;
 68		default:
 69			return LST_UNDEFINED;
 70		}
 71	// shouldn't be doing an operation on undefined types
 72	case LST_UNDEFINED:
 73		return LST_UNDEFINED;
 74	// only integers can become integers
 75	case LST_INTEGER:
 76		switch(right_side)
 77		{
 78		case LST_INTEGER:
 79			return LST_INTEGER;
 80		default:
 81			return LST_UNDEFINED;
 82		}
 83	// only integers and floats can become floats
 84	case LST_FLOATINGPOINT:
 85		switch(right_side)
 86		{
 87		case LST_INTEGER:
 88		case LST_FLOATINGPOINT:
 89			return LST_FLOATINGPOINT;
 90		default:
 91			return LST_UNDEFINED;
 92		}
 93	// only strings and keys can become strings
 94	case LST_STRING:
 95		switch(right_side)
 96		{
 97		case LST_STRING:
 98		case LST_KEY:
 99			return LST_STRING;
100		default:
101			return LST_UNDEFINED;
102		}
103	// only strings and keys can become keys
104	case LST_KEY:
105		switch(right_side)
106		{
107		case LST_STRING:
108		case LST_KEY:
109			return LST_KEY;
110		default:
111			return LST_UNDEFINED;
112		}
113	// only vectors can become vectors
114	case LST_VECTOR:
115		switch(right_side)
116		{
117		case LST_VECTOR:
118			return LST_VECTOR;
119		default:
120			return LST_UNDEFINED;
121		}
122	// only quaternions can become quaternions
123	case LST_QUATERNION:
124		switch(right_side)
125		{
126		case LST_QUATERNION:
127			return LST_QUATERNION;
128		default:
129			return LST_UNDEFINED;
130		}
131	// only lists can become lists
132	case LST_LIST:
133		switch(right_side)
134		{
135		case LST_LIST:
136			return LST_LIST;
137		default:
138			return LST_UNDEFINED;
139		}
140	default:
141		return LST_UNDEFINED;
142	}
143}
144
145LSCRIPTType promote(LSCRIPTType left_side, LSCRIPTType right_side)
146{
147	LSCRIPTType type;
148	type = implicit_casts(left_side, right_side);
149	if (type != LST_UNDEFINED)
150	{
151		return type;
152	}
153	type = implicit_casts(right_side, left_side);
154	if (type != LST_UNDEFINED)
155	{
156		return type;
157	}
158	return LST_UNDEFINED;
159}
160
161BOOL legal_assignment(LSCRIPTType left_side, LSCRIPTType right_side)
162{
163	// this is to prevent cascading errors
164	if (  (left_side == LST_UNDEFINED)
165		||(right_side == LST_UNDEFINED))
166	{
167		return TRUE;
168	}
169
170	if (implicit_casts(left_side, right_side) != LST_UNDEFINED)
171	{
172		return TRUE;
173	}
174	else
175	{
176		return FALSE;
177	}
178}
179
180BOOL legal_casts(LSCRIPTType cast, LSCRIPTType base)
181{
182	switch(base)
183	{
184	// shouldn't be doing an operation on void types
185	case LST_NULL:
186		return FALSE;
187	// shouldn't be doing an operation on undefined types
188	case LST_UNDEFINED:
189		return FALSE;
190	case LST_INTEGER:
191		switch(cast)
192		{
193		case LST_INTEGER:
194		case LST_FLOATINGPOINT:
195		case LST_STRING:
196		case LST_LIST:
197			return TRUE;
198			break;
199		default:
200			return FALSE;
201			break;
202		}
203		break;
204	case LST_FLOATINGPOINT:
205		switch(cast)
206		{
207		case LST_INTEGER:
208		case LST_FLOATINGPOINT:
209		case LST_STRING:
210		case LST_LIST:
211			return TRUE;
212			break;
213		default:
214			return FALSE;
215			break;
216		}
217		break;
218	case LST_STRING:
219		switch(cast)
220		{
221		case LST_INTEGER:
222		case LST_FLOATINGPOINT:
223		case LST_STRING:
224		case LST_KEY:
225		case LST_VECTOR:
226		case LST_QUATERNION:
227		case LST_LIST:
228			return TRUE;
229			break;
230		default:
231			return FALSE;
232			break;
233		}
234		break;
235	case LST_KEY:
236		switch(cast)
237		{
238		case LST_STRING:
239		case LST_KEY:
240		case LST_LIST:
241			return TRUE;
242			break;
243		default:
244			return FALSE;
245			break;
246		}
247		break;
248	case LST_VECTOR:
249		switch(cast)
250		{
251		case LST_VECTOR:
252		case LST_STRING:
253		case LST_LIST:
254			return TRUE;
255			break;
256		default:
257			return FALSE;
258			break;
259		}
260		break;
261	case LST_QUATERNION:
262		switch(cast)
263		{
264		case LST_QUATERNION:
265		case LST_STRING:
266		case LST_LIST:
267			return TRUE;
268			break;
269		default:
270			return FALSE;
271			break;
272		}
273		break;
274	// lists can only be cast to lists and strings
275	case LST_LIST:
276		switch(cast)
277		{
278		case LST_LIST:
279		case LST_STRING:
280			return TRUE;
281			break;
282		default:
283			return FALSE;
284			break;
285		}
286		break;
287	default:
288		return FALSE;
289		break;
290	}
291}
292
293LSCRIPTType gSupportedExpressionArray[LET_EOF][LST_EOF][LST_EOF];
294
295void init_supported_expressions(void)
296{
297	S32 i, j, k;
298	// zero out, then set the ones that matter
299	for (i = 0; i < LET_EOF; i++)
300	{
301		for (j = 0; j < LST_EOF; j++)
302		{
303			for (k = 0; k < LST_EOF; k++)
304			{
305				gSupportedExpressionArray[i][j][k] = LST_NULL;
306			}
307		}
308	}
309
310	// LET_ASSIGNMENT
311	gSupportedExpressionArray[LET_ASSIGNMENT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
312	gSupportedExpressionArray[LET_ASSIGNMENT][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
313	gSupportedExpressionArray[LET_ASSIGNMENT][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
314	gSupportedExpressionArray[LET_ASSIGNMENT][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
315	gSupportedExpressionArray[LET_ASSIGNMENT][LST_STRING][LST_STRING] = LST_STRING;
316	gSupportedExpressionArray[LET_ASSIGNMENT][LST_KEY][LST_KEY] = LST_KEY;
317	gSupportedExpressionArray[LET_ASSIGNMENT][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
318	gSupportedExpressionArray[LET_ASSIGNMENT][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
319	gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_INTEGER] = LST_LIST;
320	gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
321	gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_STRING] = LST_LIST;
322	gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_KEY] = LST_LIST;
323	gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_VECTOR] = LST_LIST;
324	gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_QUATERNION] = LST_LIST;
325	gSupportedExpressionArray[LET_ASSIGNMENT][LST_LIST][LST_LIST] = LST_LIST;
326
327	// LET_ADD_ASSIGN
328	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
329	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
330	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
331	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_STRING][LST_STRING] = LST_STRING;
332	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
333	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
334	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_INTEGER] = LST_LIST;
335	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
336	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_STRING] = LST_LIST;
337	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_KEY] = LST_LIST;
338	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_VECTOR] = LST_LIST;
339	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_QUATERNION] = LST_LIST;
340	gSupportedExpressionArray[LET_ADD_ASSIGN][LST_LIST][LST_LIST] = LST_LIST;
341
342	// LET_SUB_ASSIGN
343	gSupportedExpressionArray[LET_SUB_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
344	gSupportedExpressionArray[LET_SUB_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
345	gSupportedExpressionArray[LET_SUB_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
346	gSupportedExpressionArray[LET_SUB_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
347	gSupportedExpressionArray[LET_SUB_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
348
349	// LET_MUL_ASSIGN
350	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
351	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
352	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
353	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
354	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
355	//gSupportedExpressionArray[LET_MUL_ASSIGN][LST_INTEGER][LST_VECTOR] = LST_VECTOR;
356	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
357	//gSupportedExpressionArray[LET_MUL_ASSIGN][LST_FLOATINGPOINT][LST_VECTOR] = LST_VECTOR;
358	//gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_FLOATINGPOINT;
359	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
360	gSupportedExpressionArray[LET_MUL_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
361
362	// LET_DIV_ASSIGN
363	gSupportedExpressionArray[LET_DIV_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
364	gSupportedExpressionArray[LET_DIV_ASSIGN][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
365	gSupportedExpressionArray[LET_DIV_ASSIGN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
366	gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
367	gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
368	gSupportedExpressionArray[LET_DIV_ASSIGN][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
369	gSupportedExpressionArray[LET_DIV_ASSIGN][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
370
371	// LET_MOD_ASSIGN
372	gSupportedExpressionArray[LET_MOD_ASSIGN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
373	gSupportedExpressionArray[LET_MOD_ASSIGN][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
374
375	// LET_EQUALITY
376	gSupportedExpressionArray[LET_EQUALITY][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
377	gSupportedExpressionArray[LET_EQUALITY][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
378	gSupportedExpressionArray[LET_EQUALITY][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
379	gSupportedExpressionArray[LET_EQUALITY][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
380	gSupportedExpressionArray[LET_EQUALITY][LST_STRING][LST_STRING] = LST_INTEGER;
381	gSupportedExpressionArray[LET_EQUALITY][LST_STRING][LST_KEY] = LST_INTEGER;
382	gSupportedExpressionArray[LET_EQUALITY][LST_KEY][LST_STRING] = LST_INTEGER;
383	gSupportedExpressionArray[LET_EQUALITY][LST_KEY][LST_KEY] = LST_INTEGER;
384	gSupportedExpressionArray[LET_EQUALITY][LST_VECTOR][LST_VECTOR] = LST_INTEGER;
385	gSupportedExpressionArray[LET_EQUALITY][LST_QUATERNION][LST_QUATERNION] = LST_INTEGER;
386	gSupportedExpressionArray[LET_EQUALITY][LST_LIST][LST_LIST] = LST_INTEGER;
387
388	// LET_NOT_EQUALS
389	gSupportedExpressionArray[LET_NOT_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
390	gSupportedExpressionArray[LET_NOT_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
391	gSupportedExpressionArray[LET_NOT_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
392	gSupportedExpressionArray[LET_NOT_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
393	gSupportedExpressionArray[LET_NOT_EQUALS][LST_STRING][LST_STRING] = LST_INTEGER;
394	gSupportedExpressionArray[LET_NOT_EQUALS][LST_STRING][LST_KEY] = LST_INTEGER;
395	gSupportedExpressionArray[LET_NOT_EQUALS][LST_KEY][LST_STRING] = LST_INTEGER;
396	gSupportedExpressionArray[LET_NOT_EQUALS][LST_KEY][LST_KEY] = LST_INTEGER;
397	gSupportedExpressionArray[LET_NOT_EQUALS][LST_VECTOR][LST_VECTOR] = LST_INTEGER;
398	gSupportedExpressionArray[LET_NOT_EQUALS][LST_QUATERNION][LST_QUATERNION] = LST_INTEGER;
399	gSupportedExpressionArray[LET_NOT_EQUALS][LST_LIST][LST_LIST] = LST_INTEGER;
400
401	// LET_LESS_EQUALS
402	gSupportedExpressionArray[LET_LESS_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
403	gSupportedExpressionArray[LET_LESS_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
404	gSupportedExpressionArray[LET_LESS_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
405	gSupportedExpressionArray[LET_LESS_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
406
407	// LET_GREATER_EQUALS
408	gSupportedExpressionArray[LET_GREATER_EQUALS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
409	gSupportedExpressionArray[LET_GREATER_EQUALS][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
410	gSupportedExpressionArray[LET_GREATER_EQUALS][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
411	gSupportedExpressionArray[LET_GREATER_EQUALS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
412
413	// LET_LESS_THAN
414	gSupportedExpressionArray[LET_LESS_THAN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
415	gSupportedExpressionArray[LET_LESS_THAN][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
416	gSupportedExpressionArray[LET_LESS_THAN][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
417	gSupportedExpressionArray[LET_LESS_THAN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
418
419	// LET_GREATER_THAN
420	gSupportedExpressionArray[LET_GREATER_THAN][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
421	gSupportedExpressionArray[LET_GREATER_THAN][LST_INTEGER][LST_FLOATINGPOINT] = LST_INTEGER;
422	gSupportedExpressionArray[LET_GREATER_THAN][LST_FLOATINGPOINT][LST_INTEGER] = LST_INTEGER;
423	gSupportedExpressionArray[LET_GREATER_THAN][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_INTEGER;
424
425	// LET_PLUS
426	gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
427	gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
428	gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
429	gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
430	gSupportedExpressionArray[LET_PLUS][LST_STRING][LST_STRING] = LST_STRING;
431	gSupportedExpressionArray[LET_PLUS][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
432	gSupportedExpressionArray[LET_PLUS][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
433	gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_INTEGER] = LST_LIST;
434	gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_FLOATINGPOINT] = LST_LIST;
435	gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_STRING] = LST_LIST;
436	gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_KEY] = LST_LIST;
437	gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_VECTOR] = LST_LIST;
438	gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_QUATERNION] = LST_LIST;
439	gSupportedExpressionArray[LET_PLUS][LST_INTEGER][LST_LIST] = LST_LIST;
440	gSupportedExpressionArray[LET_PLUS][LST_FLOATINGPOINT][LST_LIST] = LST_LIST;
441	gSupportedExpressionArray[LET_PLUS][LST_STRING][LST_LIST] = LST_LIST;
442	gSupportedExpressionArray[LET_PLUS][LST_KEY][LST_LIST] = LST_LIST;
443	gSupportedExpressionArray[LET_PLUS][LST_VECTOR][LST_LIST] = LST_LIST;
444	gSupportedExpressionArray[LET_PLUS][LST_QUATERNION][LST_LIST] = LST_LIST;
445	gSupportedExpressionArray[LET_PLUS][LST_LIST][LST_LIST] = LST_LIST;
446
447	// LET_MINUS
448	gSupportedExpressionArray[LET_MINUS][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
449	gSupportedExpressionArray[LET_MINUS][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
450	gSupportedExpressionArray[LET_MINUS][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
451	gSupportedExpressionArray[LET_MINUS][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
452	gSupportedExpressionArray[LET_MINUS][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
453	gSupportedExpressionArray[LET_MINUS][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
454
455	// LET_TIMES
456	gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
457	gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
458	gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
459	gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
460	gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
461	gSupportedExpressionArray[LET_TIMES][LST_INTEGER][LST_VECTOR] = LST_VECTOR;
462	gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
463	gSupportedExpressionArray[LET_TIMES][LST_FLOATINGPOINT][LST_VECTOR] = LST_VECTOR;
464	gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_VECTOR] = LST_FLOATINGPOINT;
465	gSupportedExpressionArray[LET_TIMES][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
466	gSupportedExpressionArray[LET_TIMES][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
467
468	// LET_DIVIDE
469	gSupportedExpressionArray[LET_DIVIDE][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
470	gSupportedExpressionArray[LET_DIVIDE][LST_INTEGER][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
471	gSupportedExpressionArray[LET_DIVIDE][LST_FLOATINGPOINT][LST_INTEGER] = LST_FLOATINGPOINT;
472	gSupportedExpressionArray[LET_DIVIDE][LST_FLOATINGPOINT][LST_FLOATINGPOINT] = LST_FLOATINGPOINT;
473	gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_INTEGER] = LST_VECTOR;
474	gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_FLOATINGPOINT] = LST_VECTOR;
475	gSupportedExpressionArray[LET_DIVIDE][LST_VECTOR][LST_QUATERNION] = LST_VECTOR;
476	gSupportedExpressionArray[LET_DIVIDE][LST_QUATERNION][LST_QUATERNION] = LST_QUATERNION;
477
478	// LET_MOD
479	gSupportedExpressionArray[LET_MOD][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
480	gSupportedExpressionArray[LET_MOD][LST_VECTOR][LST_VECTOR] = LST_VECTOR;
481
482	// LET_BIT_AND
483	gSupportedExpressionArray[LET_BIT_AND][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
484
485	// LET_BIT_OR
486	gSupportedExpressionArray[LET_BIT_OR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
487
488	// LET_BIT_XOR
489	gSupportedExpressionArray[LET_BIT_XOR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
490
491	// LET_BOOLEAN_AND
492	gSupportedExpressionArray[LET_BOOLEAN_AND][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
493
494	// LET_BOOLEAN_OR
495	gSupportedExpressionArray[LET_BOOLEAN_OR][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
496
497	// LET_SHIFT_LEFT
498	gSupportedExpressionArray[LET_SHIFT_LEFT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
499
500	// LET_SHIFT_RIGHT
501	gSupportedExpressionArray[LET_SHIFT_RIGHT][LST_INTEGER][LST_INTEGER] = LST_INTEGER;
502
503	// LET_PARENTHESIS
504	gSupportedExpressionArray[LET_PARENTHESIS][LST_INTEGER][LST_NULL] = LST_INTEGER;
505	gSupportedExpressionArray[LET_PARENTHESIS][LST_FLOATINGPOINT][LST_NULL] = LST_INTEGER;
506	gSupportedExpressionArray[LET_PARENTHESIS][LST_STRING][LST_NULL] = LST_INTEGER;
507	gSupportedExpressionArray[LET_PARENTHESIS][LST_LIST][LST_NULL] = LST_INTEGER;
508
509	// LET_UNARY_MINUS
510	gSupportedExpressionArray[LET_UNARY_MINUS][LST_INTEGER][LST_NULL] = LST_INTEGER;
511	gSupportedExpressionArray[LET_UNARY_MINUS][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
512	gSupportedExpressionArray[LET_UNARY_MINUS][LST_VECTOR][LST_NULL] = LST_VECTOR;
513	gSupportedExpressionArray[LET_UNARY_MINUS][LST_QUATERNION][LST_NULL] = LST_QUATERNION;
514
515	// LET_BOOLEAN_NOT
516	gSupportedExpressionArray[LET_BOOLEAN_NOT][LST_INTEGER][LST_NULL] = LST_INTEGER;
517
518	// LET_BIT_NOT
519	gSupportedExpressionArray[LET_BIT_NOT][LST_INTEGER][LST_NULL] = LST_INTEGER;
520
521	// LET_PRE_INCREMENT
522	gSupportedExpressionArray[LET_PRE_INCREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
523	gSupportedExpressionArray[LET_PRE_INCREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
524
525	// LET_PRE_DECREMENT
526	gSupportedExpressionArray[LET_PRE_DECREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
527	gSupportedExpressionArray[LET_PRE_DECREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
528
529	// LET_POST_INCREMENT
530	gSupportedExpressionArray[LET_POST_INCREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
531	gSupportedExpressionArray[LET_POST_INCREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
532
533	// LET_POST_DECREMENT
534	gSupportedExpressionArray[LET_POST_DECREMENT][LST_INTEGER][LST_NULL] = LST_INTEGER;
535	gSupportedExpressionArray[LET_POST_DECREMENT][LST_FLOATINGPOINT][LST_NULL] = LST_FLOATINGPOINT;
536}
537
538BOOL legal_binary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTType right_side, LSCRIPTExpressionType expression)
539{
540	if (  (left_side == LST_UNDEFINED)
541		||(right_side == LST_UNDEFINED))
542	{
543		result = LST_UNDEFINED;
544		return TRUE;
545	}
546
547	if (  (left_side == LST_NULL)
548		||(right_side == LST_NULL))
549	{
550		result = LST_UNDEFINED;
551		return FALSE;
552	}
553
554	result = gSupportedExpressionArray[expression][left_side][right_side];
555	if (result)
556		return TRUE;
557	else
558	{
559		result = LST_UNDEFINED;
560		return FALSE;
561	}
562}
563
564BOOL legal_unary_expression(LSCRIPTType &result, LSCRIPTType left_side, LSCRIPTExpressionType expression)
565{
566	if (left_side == LST_UNDEFINED)
567	{
568		result = LST_UNDEFINED;
569		return TRUE;
570	}
571
572	if (left_side == LST_NULL)
573	{
574		result = LST_UNDEFINED;
575		return FALSE;
576	}
577
578	result = gSupportedExpressionArray[expression][left_side][LST_NULL];
579	if (result)
580		return TRUE;
581	else
582	{
583		result = LST_UNDEFINED;
584		return FALSE;
585	}
586}