aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs220
1 files changed, 27 insertions, 193 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs
index 27fde5b..da17a13 100644
--- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs
+++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs
@@ -64,9 +64,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
64 64
65 public class ScriptCodeGen: IScriptCodeGen 65 public class ScriptCodeGen: IScriptCodeGen
66 { 66 {
67 private static readonly bool DEBUG_STACKCAPRES = false;
68 private static readonly bool DEBUG_TRYSTMT = false;
69
70 public static readonly string OBJECT_CODE_MAGIC = "YObjectCode"; 67 public static readonly string OBJECT_CODE_MAGIC = "YObjectCode";
71 // reserve positive version values for original xmr 68 // reserve positive version values for original xmr
72 public static int COMPILED_VERSION_VALUE = -2; // decremented when compiler or object file changes 69 public static int COMPILED_VERSION_VALUE = -2; // decremented when compiler or object file changes
@@ -972,11 +969,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine
972 string eventname = declFunc.GetSimpleName(); 969 string eventname = declFunc.GetSimpleName();
973 TokenArgDecl argDecl = declFunc.argDecl; 970 TokenArgDecl argDecl = declFunc.argDecl;
974 971
975 // Make sure event handler name is valid and that number and type of arguments is correct. 972 HeapLocals.Clear();
976 // Apparently some scripts exist with fewer than correct number of args in their declaration 973
977 // so allow for that. It is ok because the handlers are called with the arguments in an 974 // Make sure event handler name is valid and that number and type of arguments is correct.
978 // object[] array, and we just won't access the missing argments in the vector. But the 975 // Apparently some scripts exist with fewer than correct number of args in their declaration
979 // specified types must match one of the prototypes in legalEventHandlers. 976 // so allow for that. It is ok because the handlers are called with the arguments in an
977 // object[] array, and we just won't access the missing argments in the vector. But the
978 // specified types must match one of the prototypes in legalEventHandlers.
980 TokenDeclVar protoDeclFunc = legalEventHandlers.FindExact(eventname, argDecl.types); 979 TokenDeclVar protoDeclFunc = legalEventHandlers.FindExact(eventname, argDecl.types);
981 if(protoDeclFunc == null) 980 if(protoDeclFunc == null)
982 { 981 {
@@ -1113,7 +1112,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1113 */ 1112 */
1114 private void GenerateMethodBody(TokenDeclVar declFunc) 1113 private void GenerateMethodBody(TokenDeclVar declFunc)
1115 { 1114 {
1116 // Set up code generator for the function's contents. 1115 HeapLocals.Clear();
1116
1117 // Set up code generator for the function's contents.
1117 _ilGen = declFunc.ilGen; 1118 _ilGen = declFunc.ilGen;
1118 StartFunctionBody(declFunc); 1119 StartFunctionBody(declFunc);
1119 1120
@@ -1258,7 +1259,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1258 // resume at the correct spot. 1259 // resume at the correct spot.
1259 actCallLabels.Clear(); 1260 actCallLabels.Clear();
1260 allCallLabels.Clear(); 1261 allCallLabels.Clear();
1261 HeapLocals.Clear();
1262 openCallLabel = null; 1262 openCallLabel = null;
1263 1263
1264 // Alloc stack space for local vars. 1264 // Alloc stack space for local vars.
@@ -1405,18 +1405,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1405 // Build list of locals and temps active at all the call labels. 1405 // Build list of locals and temps active at all the call labels.
1406 activeTemps = new List<ScriptMyLocal>(); 1406 activeTemps = new List<ScriptMyLocal>();
1407 foreach (CallLabel cl in allCallLabels) 1407 foreach (CallLabel cl in allCallLabels)
1408 {
1409 foreach (ScriptMyLocal lcl in cl.callLabel.whereAmI.localsReadBeforeWritten)
1408 { 1410 {
1409 foreach(ScriptMyLocal lcl in cl.callLabel.whereAmI.localsReadBeforeWritten) 1411 if (!activeTemps.Contains(lcl))
1410 { 1412 {
1411 if(!activeTemps.Contains(lcl))
1412 {
1413 activeTemps.Add(lcl); 1413 activeTemps.Add(lcl);
1414 } 1414 }
1415 } 1415 }
1416 } 1416 }
1417 1417
1418 // Output code to restore the args, locals and temps then jump to 1418 // Output code to restore the args, locals and temps then jump to
1419 // the call label that we were interrupted at. 1419 // the call label that we were interrupted at.
1420 ilGen.MarkLabel(cmRestore); 1420 ilGen.MarkLabel(cmRestore);
1421 GenerateFrameRestoreCode(activeTemps); 1421 GenerateFrameRestoreCode(activeTemps);
1422 } 1422 }
@@ -1546,15 +1546,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1546 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, nSaves); 1546 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, nSaves);
1547 ilGen.Emit(curDeclFunc, OpCodes.Call, captureStackFrameMethodInfo); 1547 ilGen.Emit(curDeclFunc, OpCodes.Call, captureStackFrameMethodInfo);
1548 1548
1549 if(DEBUG_STACKCAPRES)
1550 {
1551 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, ilGen.methName + "*: capture mainCallNo=");
1552 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1553 ilGen.Emit(curDeclFunc, OpCodes.Ldloc, actCallNo);
1554 ilGen.Emit(curDeclFunc, OpCodes.Box, typeof(int));
1555 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1556 }
1557
1558 // Copy arg values to object array, boxing as needed. 1549 // Copy arg values to object array, boxing as needed.
1559 int i = 0; 1550 int i = 0;
1560 foreach(TokenDeclVar argVar in curDeclFunc.argDecl.varDict) 1551 foreach(TokenDeclVar argVar in curDeclFunc.argDecl.varDict)
@@ -1562,13 +1553,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1562 ilGen.Emit(curDeclFunc, OpCodes.Dup); 1553 ilGen.Emit(curDeclFunc, OpCodes.Dup);
1563 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, i); 1554 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, i);
1564 argVar.location.PushVal(this, argVar.name, tokenTypeObj); 1555 argVar.location.PushVal(this, argVar.name, tokenTypeObj);
1565 if(DEBUG_STACKCAPRES)
1566 {
1567 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, "\n arg:" + argVar.name.val + "=");
1568 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1569 ilGen.Emit(curDeclFunc, OpCodes.Dup);
1570 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1571 }
1572 ilGen.Emit(curDeclFunc, OpCodes.Stelem_Ref); 1556 ilGen.Emit(curDeclFunc, OpCodes.Stelem_Ref);
1573 i++; 1557 i++;
1574 } 1558 }
@@ -1596,20 +1580,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1596 { 1580 {
1597 ilGen.Emit(curDeclFunc, OpCodes.Box, t); 1581 ilGen.Emit(curDeclFunc, OpCodes.Box, t);
1598 } 1582 }
1599 if(DEBUG_STACKCAPRES)
1600 {
1601 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, "\n lcl:" + lcl.name + "=");
1602 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1603 ilGen.Emit(curDeclFunc, OpCodes.Dup);
1604 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1605 }
1606 ilGen.Emit(curDeclFunc, OpCodes.Stelem_Ref); 1583 ilGen.Emit(curDeclFunc, OpCodes.Stelem_Ref);
1607 } 1584 }
1608 if(DEBUG_STACKCAPRES)
1609 {
1610 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, "\n");
1611 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1612 }
1613 1585
1614 ilGen.Emit(curDeclFunc, OpCodes.Pop); 1586 ilGen.Emit(curDeclFunc, OpCodes.Pop);
1615 } 1587 }
@@ -1629,14 +1601,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1629 ilGen.Emit(curDeclFunc, OpCodes.Ldloca, actCallNo); // __mainCallNo 1601 ilGen.Emit(curDeclFunc, OpCodes.Ldloca, actCallNo); // __mainCallNo
1630 ilGen.Emit(curDeclFunc, OpCodes.Call, restoreStackFrameMethodInfo); 1602 ilGen.Emit(curDeclFunc, OpCodes.Call, restoreStackFrameMethodInfo);
1631 ilGen.Emit(curDeclFunc, OpCodes.Stloc, objArray); 1603 ilGen.Emit(curDeclFunc, OpCodes.Stloc, objArray);
1632 if(DEBUG_STACKCAPRES)
1633 {
1634 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, ilGen.methName + "*: restore mainCallNo=");
1635 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1636 ilGen.Emit(curDeclFunc, OpCodes.Ldloc, actCallNo);
1637 ilGen.Emit(curDeclFunc, OpCodes.Box, typeof(int));
1638 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1639 }
1640 1604
1641 // Restore argument values from object array, unboxing as needed. 1605 // Restore argument values from object array, unboxing as needed.
1642 // Although the caller has restored them to what it called us with, it's possible that this 1606 // Although the caller has restored them to what it called us with, it's possible that this
@@ -1649,13 +1613,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1649 ilGen.Emit(curDeclFunc, OpCodes.Ldloc, objArray); 1613 ilGen.Emit(curDeclFunc, OpCodes.Ldloc, objArray);
1650 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, i); 1614 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, i);
1651 ilGen.Emit(curDeclFunc, OpCodes.Ldelem_Ref); 1615 ilGen.Emit(curDeclFunc, OpCodes.Ldelem_Ref);
1652 if(DEBUG_STACKCAPRES)
1653 {
1654 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, "\n arg:" + argVar.name.val + "=");
1655 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1656 ilGen.Emit(curDeclFunc, OpCodes.Dup);
1657 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1658 }
1659 TypeCast.CastTopOfStack(this, argVar.name, tokenTypeObj, argLoc.type, true); 1616 TypeCast.CastTopOfStack(this, argVar.name, tokenTypeObj, argLoc.type, true);
1660 argLoc.PopPost(this, argVar.name); 1617 argLoc.PopPost(this, argVar.name);
1661 i++; 1618 i++;
@@ -1679,13 +1636,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1679 ilGen.Emit(curDeclFunc, OpCodes.Ldloc, objArray); 1636 ilGen.Emit(curDeclFunc, OpCodes.Ldloc, objArray);
1680 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, i++); 1637 ilGen.Emit(curDeclFunc, OpCodes.Ldc_I4, i++);
1681 ilGen.Emit(curDeclFunc, OpCodes.Ldelem_Ref); 1638 ilGen.Emit(curDeclFunc, OpCodes.Ldelem_Ref);
1682 if(DEBUG_STACKCAPRES)
1683 {
1684 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, "\n lcl:" + lcl.name + "=");
1685 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1686 ilGen.Emit(curDeclFunc, OpCodes.Dup);
1687 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1688 }
1689 if(u.IsValueType) 1639 if(u.IsValueType)
1690 { 1640 {
1691 ilGen.Emit(curDeclFunc, OpCodes.Unbox_Any, u); 1641 ilGen.Emit(curDeclFunc, OpCodes.Unbox_Any, u);
@@ -1708,11 +1658,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
1708 ilGen.Emit(curDeclFunc, OpCodes.Stloc, lcl); 1658 ilGen.Emit(curDeclFunc, OpCodes.Stloc, lcl);
1709 } 1659 }
1710 } 1660 }
1711 if(DEBUG_STACKCAPRES)
1712 {
1713 ilGen.Emit(curDeclFunc, OpCodes.Ldstr, "\n");
1714 ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo);
1715 }
1716 1661
1717 OutputCallNoSwitchStmt(); 1662 OutputCallNoSwitchStmt();
1718 } 1663 }
@@ -3235,34 +3180,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
3235 new CallLabel(this, tryStmt); // <oldcalllabel>: 3180 new CallLabel(this, tryStmt); // <oldcalllabel>:
3236 ilGen.BeginExceptionBlock(); // try { 3181 ilGen.BeginExceptionBlock(); // try {
3237 openCallLabel = null; 3182 openCallLabel = null;
3238 if(DEBUG_TRYSTMT)
3239 {
3240 ilGen.Emit(tryStmt, OpCodes.Ldstr, "enter try*: " + tryStmt.line + " callMode=");
3241 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3242 PushXMRInst();
3243 ilGen.Emit(tryStmt, OpCodes.Ldfld, callModeFieldInfo);
3244 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3245 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3246 ilGen.Emit(tryStmt, OpCodes.Ldstr, " tryCallNo=");
3247 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3248 tryCallNo.PushVal(this, tryStmt);
3249 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3250 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3251 ilGen.Emit(tryStmt, OpCodes.Ldstr, " catThrown.IsNull=");
3252 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3253 catThrown.PushVal(this, tryStmt);
3254 ilGen.Emit(tryStmt, OpCodes.Ldnull);
3255 ilGen.Emit(tryStmt, OpCodes.Ceq);
3256 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3257 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3258 ilGen.Emit(tryStmt, OpCodes.Ldstr, " catCallNo=");
3259 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3260 catCallNo.PushVal(this, tryStmt);
3261 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3262 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3263 ilGen.Emit(tryStmt, OpCodes.Ldstr, "\n");
3264 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3265 }
3266 3183
3267 GetCallNo(tryStmt, tryCallNo); // if (__tryCallNo >= 0) goto tryCallSw; 3184 GetCallNo(tryStmt, tryCallNo); // if (__tryCallNo >= 0) goto tryCallSw;
3268 ilGen.Emit(tryStmt, OpCodes.Ldc_I4_0); 3185 ilGen.Emit(tryStmt, OpCodes.Ldc_I4_0);
@@ -3282,31 +3199,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine
3282 } 3199 }
3283 3200
3284 CallLabel tryThrow = new CallLabel(this, tryStmt); // tryThrow:<tryCallLabel>: 3201 CallLabel tryThrow = new CallLabel(this, tryStmt); // tryThrow:<tryCallLabel>:
3285 if(DEBUG_TRYSTMT)
3286 {
3287 ilGen.Emit(tryStmt, OpCodes.Ldstr, "tryThrow*: " + tryStmt.line + " catThrown=");
3288 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3289 catThrown.PushVal(this, tryStmt);
3290 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3291 ilGen.Emit(tryStmt, OpCodes.Ldstr, "\n");
3292 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3293 }
3294 catThrown.PushVal(this, tryStmt); // throw new ScriptRestoreCatchException (__catThrown); 3202 catThrown.PushVal(this, tryStmt); // throw new ScriptRestoreCatchException (__catThrown);
3295 ilGen.Emit(tryStmt, OpCodes.Newobj, scriptRestoreCatchExceptionConstructorInfo); 3203 ilGen.Emit(tryStmt, OpCodes.Newobj, scriptRestoreCatchExceptionConstructorInfo);
3296 ilGen.Emit(tryStmt, OpCodes.Throw); 3204 ilGen.Emit(tryStmt, OpCodes.Throw);
3297 openCallLabel = null; 3205 openCallLabel = null;
3298 3206
3299 ilGen.MarkLabel(tryCallSw); // tryCallSw: 3207 ilGen.MarkLabel(tryCallSw); // tryCallSw:
3300 if(DEBUG_TRYSTMT)
3301 {
3302 ilGen.Emit(tryStmt, OpCodes.Ldstr, "tryCallSw*: " + tryStmt.line + " tryCallNo=");
3303 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3304 tryCallNo.PushVal(this, tryStmt);
3305 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3306 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3307 ilGen.Emit(tryStmt, OpCodes.Ldstr, "\n");
3308 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3309 }
3310 OutputCallNoSwitchStmt(); // switch (tryCallNo) ... 3208 OutputCallNoSwitchStmt(); // switch (tryCallNo) ...
3311 3209
3312 CompValuLocalVar catchVarLocExc = null; 3210 CompValuLocalVar catchVarLocExc = null;
@@ -3324,26 +3222,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
3324 ScriptMyLocal excLocal = ilGen.DeclareLocal(typeof(String), "catchstr_" + tryStmt.Unique); 3222 ScriptMyLocal excLocal = ilGen.DeclareLocal(typeof(String), "catchstr_" + tryStmt.Unique);
3325 3223
3326 ilGen.BeginCatchBlock(typeof(Exception)); // start of the catch block that can catch any exception 3224 ilGen.BeginCatchBlock(typeof(Exception)); // start of the catch block that can catch any exception
3327 if(DEBUG_TRYSTMT)
3328 {
3329 ilGen.Emit(tryStmt.catchStmt, OpCodes.Ldstr, "enter catch*: " + tryStmt.line + " callMode=");
3330 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, consoleWriteMethodInfo);
3331 PushXMRInst();
3332 ilGen.Emit(tryStmt.catchStmt, OpCodes.Ldfld, callModeFieldInfo);
3333 ilGen.Emit(tryStmt.catchStmt, OpCodes.Box, typeof(int));
3334 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, consoleWriteMethodInfo);
3335 ilGen.Emit(tryStmt.catchStmt, OpCodes.Ldstr, " catCallNo=");
3336 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, consoleWriteMethodInfo);
3337 catCallNo.PushVal(this, tryStmt);
3338 ilGen.Emit(tryStmt.catchStmt, OpCodes.Box, typeof(int));
3339 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, consoleWriteMethodInfo);
3340 ilGen.Emit(tryStmt.catchStmt, OpCodes.Ldstr, " exc=");
3341 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, consoleWriteMethodInfo);
3342 ilGen.Emit(tryStmt.catchStmt, OpCodes.Dup);
3343 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, consoleWriteMethodInfo);
3344 ilGen.Emit(tryStmt.catchStmt, OpCodes.Ldstr, "\n");
3345 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, consoleWriteMethodInfo);
3346 }
3347 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, scriptRestoreCatchExceptionUnwrap); 3225 ilGen.Emit(tryStmt.catchStmt, OpCodes.Call, scriptRestoreCatchExceptionUnwrap);
3348 // exc = ScriptRestoreCatchException.Unwrap (exc); 3226 // exc = ScriptRestoreCatchException.Unwrap (exc);
3349 ilGen.Emit(tryStmt.catchStmt, OpCodes.Dup); // rethrow if IXMRUncatchable (eg, StackCaptureException) 3227 ilGen.Emit(tryStmt.catchStmt, OpCodes.Dup); // rethrow if IXMRUncatchable (eg, StackCaptureException)
@@ -3475,34 +3353,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
3475 ilGen.BeginExceptionBlock(); // try { 3353 ilGen.BeginExceptionBlock(); // try {
3476 ilGen.BeginExceptionBlock(); // try { 3354 ilGen.BeginExceptionBlock(); // try {
3477 openCallLabel = null; 3355 openCallLabel = null;
3478 if(DEBUG_TRYSTMT)
3479 {
3480 ilGen.Emit(tryStmt, OpCodes.Ldstr, "enter try*: " + tryStmt.line + " callMode=");
3481 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3482 PushXMRInst();
3483 ilGen.Emit(tryStmt, OpCodes.Ldfld, callModeFieldInfo);
3484 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3485 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3486 ilGen.Emit(tryStmt, OpCodes.Ldstr, " tryCallNo=");
3487 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3488 tryCallNo.PushVal(this, tryStmt);
3489 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3490 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3491 ilGen.Emit(tryStmt, OpCodes.Ldstr, " finCallNo=");
3492 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3493 finCallNo.PushVal(this, tryStmt);
3494 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3495 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3496 ilGen.Emit(tryStmt, OpCodes.Ldstr, " catThrown.IsNull=");
3497 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3498 catThrown.PushVal(this, tryStmt);
3499 ilGen.Emit(tryStmt, OpCodes.Ldnull);
3500 ilGen.Emit(tryStmt, OpCodes.Ceq);
3501 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3502 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3503 ilGen.Emit(tryStmt, OpCodes.Ldstr, "\n");
3504 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3505 }
3506 3356
3507 GetCallNo(tryStmt, tryCallNo); // if (__tryCallNo >= 0) goto tryCallSw; 3357 GetCallNo(tryStmt, tryCallNo); // if (__tryCallNo >= 0) goto tryCallSw;
3508 ilGen.Emit(tryStmt, OpCodes.Ldc_I4_0); 3358 ilGen.Emit(tryStmt, OpCodes.Ldc_I4_0);
@@ -3529,15 +3379,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
3529 } 3379 }
3530 3380
3531 CallLabel tryThrow = new CallLabel(this, tryStmt); // tryThrow:<tryCallLabel>: 3381 CallLabel tryThrow = new CallLabel(this, tryStmt); // tryThrow:<tryCallLabel>:
3532 if(DEBUG_TRYSTMT)
3533 {
3534 ilGen.Emit(tryStmt, OpCodes.Ldstr, "tryThrow*: " + tryStmt.line + " catThrown=");
3535 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3536 catThrown.PushVal(this, tryStmt);
3537 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3538 ilGen.Emit(tryStmt, OpCodes.Ldstr, "\n");
3539 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3540 }
3541 catThrown.PushVal(this, tryStmt); // throw new ScriptRestoreCatchException (__catThrown); 3382 catThrown.PushVal(this, tryStmt); // throw new ScriptRestoreCatchException (__catThrown);
3542 ilGen.Emit(tryStmt, OpCodes.Newobj, scriptRestoreCatchExceptionConstructorInfo); 3383 ilGen.Emit(tryStmt, OpCodes.Newobj, scriptRestoreCatchExceptionConstructorInfo);
3543 ilGen.Emit(tryStmt, OpCodes.Throw); 3384 ilGen.Emit(tryStmt, OpCodes.Throw);
@@ -3548,21 +3389,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine
3548 // } 3389 // }
3549 3390
3550 ilGen.BeginCatchBlock(typeof(Exception)); // start of the catch block that can catch any exception 3391 ilGen.BeginCatchBlock(typeof(Exception)); // start of the catch block that can catch any exception
3551 if(DEBUG_TRYSTMT)
3552 {
3553 ilGen.Emit(tryStmt, OpCodes.Ldstr, "enter catch*: " + tryStmt.line + " callMode=");
3554 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3555 PushXMRInst();
3556 ilGen.Emit(tryStmt, OpCodes.Ldfld, callModeFieldInfo);
3557 ilGen.Emit(tryStmt, OpCodes.Box, typeof(int));
3558 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3559 ilGen.Emit(tryStmt, OpCodes.Ldstr, " exc=");
3560 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3561 ilGen.Emit(tryStmt, OpCodes.Dup);
3562 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3563 ilGen.Emit(tryStmt, OpCodes.Ldstr, "\n");
3564 ilGen.Emit(tryStmt, OpCodes.Call, consoleWriteMethodInfo);
3565 }
3566 ilGen.Emit(tryStmt, OpCodes.Call, scriptRestoreCatchExceptionUnwrap); // exc = ScriptRestoreCatchException.Unwrap (exc); 3392 ilGen.Emit(tryStmt, OpCodes.Call, scriptRestoreCatchExceptionUnwrap); // exc = ScriptRestoreCatchException.Unwrap (exc);
3567 PushXMRInst(); // if (callMode == CallMode_SAVE) goto catchRetro; 3393 PushXMRInst(); // if (callMode == CallMode_SAVE) goto catchRetro;
3568 ilGen.Emit(tryStmt, OpCodes.Ldfld, callModeFieldInfo); 3394 ilGen.Emit(tryStmt, OpCodes.Ldfld, callModeFieldInfo);
@@ -4154,11 +3980,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine
4154 3980
4155 // Maybe the expression can be converted to a constant. 3981 // Maybe the expression can be converted to a constant.
4156 bool didOne; 3982 bool didOne;
4157 do 3983 try
4158 { 3984 {
4159 didOne = false; 3985 do
4160 rVal = rVal.TryComputeConstant(LookupBodyConstants, ref didOne); 3986 {
4161 } while(didOne); 3987 didOne = false;
3988 rVal = rVal.TryComputeConstant(LookupBodyConstants, ref didOne);
3989 } while(didOne);
3990 }
3991 catch(Exception ex)
3992 {
3993 ErrorMsg(errorMessageToken, ex.Message);
3994 throw;
3995 }
4162 3996
4163 // Generate code for the computation and return resulting type and location. 3997 // Generate code for the computation and return resulting type and location.
4164 CompValu cVal = null; 3998 CompValu cVal = null;