From 85b973ce1d8dc034546c9c572a7f57e73b6017d3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 25 Feb 2018 00:18:41 +0000 Subject: [PATCH] Y(xmr)engine cosmetics... --- .../YEngine/MMRInternalFuncDict.cs | 20 +- .../ScriptEngine/YEngine/MMRScriptCodeGen.cs | 1949 ++++++----------- .../YEngine/MMRScriptCollector.cs | 187 +- .../ScriptEngine/YEngine/MMRScriptCompValu.cs | 41 +- .../ScriptEngine/YEngine/MMRScriptConsts.cs | 30 +- .../ScriptEngine/YEngine/MMRScriptObjCode.cs | 16 +- .../YEngine/MMRScriptObjWriter.cs | 644 +++--- .../ScriptEngine/YEngine/MMRScriptReduce.cs | 1518 +++++-------- .../ScriptEngine/YEngine/MMRScriptTokenize.cs | 52 +- .../ScriptEngine/YEngine/MMRScriptTypeCast.cs | 98 +- .../ScriptEngine/YEngine/MMRScriptVarDict.cs | 97 +- .../Region/ScriptEngine/YEngine/XMRArray.cs | 64 +- .../ScriptEngine/YEngine/XMREngXmrTestLs.cs | 61 +- .../ScriptEngine/YEngine/XMRInstAbstract.cs | 333 ++- .../ScriptEngine/YEngine/XMRInstBackend.cs | 79 +- .../ScriptEngine/YEngine/XMRInstCtor.cs | 4 +- .../ScriptEngine/YEngine/XMRInstMisc.cs | 36 +- .../Region/ScriptEngine/YEngine/XMRInstRun.cs | 387 ++-- .../ScriptEngine/YEngine/XMRObjectTokens.cs | 198 +- 19 files changed, 2048 insertions(+), 3766 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs index 5d1cbc046e..ca7c372d6d 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRInternalFuncDict.cs @@ -35,7 +35,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine public class InternalFuncDict: VarDict { - /** * @brief build dictionary of internal functions from an interface. * @param iface = interface with function definitions @@ -46,27 +45,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine public InternalFuncDict(Type iface, bool inclSig) : base(false) { - /* - * Loop through list of all methods declared in the interface. - */ + // Loop through list of all methods declared in the interface. System.Reflection.MethodInfo[] ifaceMethods = iface.GetMethods(); foreach(System.Reflection.MethodInfo ifaceMethod in ifaceMethods) { string key = ifaceMethod.Name; - /* - * Only do ones that begin with lower-case letters... - * as any others can't be referenced by scripts - */ + // Only do ones that begin with lower-case letters... + // as any others can't be referenced by scripts if((key[0] < 'a') || (key[0] > 'z')) continue; try { - - /* - * Create a corresponding TokenDeclVar struct. - */ + // Create a corresponding TokenDeclVar struct. System.Reflection.ParameterInfo[] parameters = ifaceMethod.GetParameters(); TokenArgDecl argDecl = new TokenArgDecl(null); for(int i = 0; i < parameters.Length; i++) @@ -81,9 +73,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine declFunc.retType = TokenType.FromSysType(null, ifaceMethod.ReturnType); declFunc.argDecl = argDecl; - /* - * Add the TokenDeclVar struct to the dictionary. - */ + // Add the TokenDeclVar struct to the dictionary. this.AddEntry(declFunc); } catch(Exception except) diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs index a480263301..ea86b0b993 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs @@ -77,9 +77,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine public static Type xmrInstSuperType = null; // typeof whatever is actually malloc'd for script instances // - must inherit from XMRInstAbstract - /* - * Static tables that there only needs to be one copy of for all. - */ + // Static tables that there only needs to be one copy of for all. private static VarDict legalEventHandlers = CreateLegalEventHandlers(); private static CompValu[] zeroCompValus = new CompValu[0]; private static TokenType[] zeroArgs = new TokenType[0]; @@ -161,20 +159,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine public static bool CodeGen(TokenScript tokenScript, BinaryWriter objFileWriter, string sourceHash) { - /* - * Run compiler such that it has a 'this' context for convenience. - */ + // Run compiler such that it has a 'this' context for convenience. ScriptCodeGen scg = new ScriptCodeGen(tokenScript, objFileWriter, sourceHash); - /* - * Return pointer to resultant script object code. - */ + // Return pointer to resultant script object code. return !scg.youveAnError; } - /* - * There is one set of these variables for each script being compiled. - */ + // There is one set of these variables for each script being compiled. private bool mightGetHere = false; private bool youveAnError = false; private BreakContTarg curBreakTarg = null; @@ -246,24 +238,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void PerformCompilation() { - /* - * errorMessageToken is used only when the given token doesn't have a - * output delegate associated with it such as for backend API functions - * that only have one copy for the whole system. It is kept up-to-date - * approximately but is rarely needed so going to assume it doesn't have - * to be exact. - */ + // errorMessageToken is used only when the given token doesn't have a + // output delegate associated with it such as for backend API functions + // that only have one copy for the whole system. It is kept up-to-date + // approximately but is rarely needed so going to assume it doesn't have + // to be exact. errorMessageToken = tokenScript; - /* - * Set up dictionary to translate state names to their index number. - */ + // Set up dictionary to translate state names to their index number. stateIndices = new Dictionary(); - /* - * Assign each state its own unique index. - * The default state gets 0. - */ + // Assign each state its own unique index. + // The default state gets 0. nStates = 0; tokenScript.defaultState.body.index = nStates++; stateIndices.Add("default", 0); @@ -274,9 +260,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine stateIndices.Add(declState.name.val, declState.body.index); } - /* - * Make up an array that translates state indices to state name strings. - */ + // Make up an array that translates state indices to state name strings. stateNames = new string[nStates]; stateNames[0] = "default"; foreach(KeyValuePair kvp in tokenScript.states) @@ -285,11 +269,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine stateNames[declState.body.index] = declState.name.val; } - /* - * Make sure we have delegates for all script-defined functions and methods, - * creating anonymous ones if needed. Note that this includes all property - * getter and setter methods. - */ + // Make sure we have delegates for all script-defined functions and methods, + // creating anonymous ones if needed. Note that this includes all property + // getter and setter methods. foreach(TokenDeclVar declFunc in tokenScript.variablesStack) { if(declFunc.retType != null) @@ -347,42 +329,29 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * No more types can be defined or we won't be able to write them to the object file. - */ + // No more types can be defined or we won't be able to write them to the object file. tokenScript.sdSrcTypesSeal(); - /* - * Assign all global variables a slot in its corresponding XMRInstance.gbls[] array. - * Global variables are simply elements of those arrays at runtime, thus we don't need to create - * an unique class for each script, we can just use XMRInstance as is for all. - */ + // Assign all global variables a slot in its corresponding XMRInstance.gbls[] array. + // Global variables are simply elements of those arrays at runtime, thus we don't need to create + // an unique class for each script, we can just use XMRInstance as is for all. foreach(TokenDeclVar declVar in tokenScript.variablesStack) { - - /* - * Omit 'constant' variables as they are coded inline so don't need a slot. - */ + // Omit 'constant' variables as they are coded inline so don't need a slot. if(declVar.constant) continue; - /* - * Do functions later. - */ + // Do functions later. if(declVar.retType != null) continue; - /* - * Create entry in the value array for the variable or property. - */ + // Create entry in the value array for the variable or property. declVar.location = new CompValuGlobalVar(declVar, glblSizes); } - /* - * Likewise for any static fields in script-defined classes. - * They can be referenced anywhere by ., see - * GenerateFromLValSField(). - */ + // Likewise for any static fields in script-defined classes. + // They can be referenced anywhere by ., see + // GenerateFromLValSField(). foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { if(!(sdType is TokenDeclSDTypeClass)) @@ -391,40 +360,29 @@ namespace OpenSim.Region.ScriptEngine.Yengine foreach(TokenDeclVar declVar in sdtClass.members) { - - /* - * Omit 'constant' variables as they are coded inline so don't need a slot. - */ + // Omit 'constant' variables as they are coded inline so don't need a slot. if(declVar.constant) continue; - /* - * Do methods later. - */ + // Do methods later. if(declVar.retType != null) continue; - /* - * Ignore non-static fields for now. - * They get assigned below. - */ + // Ignore non-static fields for now. + // They get assigned below. if((declVar.sdtFlags & ScriptReduce.SDT_STATIC) == 0) continue; - /* - * Create entry in the value array for the static field or static property. - */ + // Create entry in the value array for the static field or static property. declVar.location = new CompValuGlobalVar(declVar, glblSizes); } } - /* - * Assign slots for all interface method prototypes. - * These indices are used to index the array of delegates that holds a class' implementation of an - * interface. - * Properties do not get a slot because they aren't called as such. But their corresponding - * $get() and $set() methods are in the table and they each get a slot. - */ + // Assign slots for all interface method prototypes. + // These indices are used to index the array of delegates that holds a class' implementation of an + // interface. + // Properties do not get a slot because they aren't called as such. But their corresponding + // $get() and $set() methods are in the table and they each get a slot. foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { if(!(sdType is TokenDeclSDTypeInterface)) @@ -440,9 +398,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Assign slots for all instance fields and virtual methods of script-defined classes. - */ + // Assign slots for all instance fields and virtual methods of script-defined classes. int maxExtends = tokenScript.sdSrcTypesCount; bool didOne; do @@ -456,10 +412,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(sdtClass.slotsAssigned) continue; - /* - * If this class extends another, the extended class has to already - * be set up, because our slots add on to the end of the extended class. - */ + // If this class extends another, the extended class has to already + // be set up, because our slots add on to the end of the extended class. TokenDeclSDTypeClass extends = sdtClass.extends; if(extends != null) { @@ -483,10 +437,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Extended class's slots all assigned, assign our instance fields - * slots in the XMRSDTypeClObj arrays. - */ + // Extended class's slots all assigned, assign our instance fields + // slots in the XMRSDTypeClObj arrays. foreach(TokenDeclVar declVar in sdtClass.members) { if(declVar.retType != null) @@ -501,31 +453,27 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * ... and assign virtual method vtable slots. - * - * - : error if any overridden method, doesn't need a slot - * abstract : error if any overridden method, alloc new slot but leave it empty - * new : ignore any overridden method, doesn't need a slot - * new abstract : ignore any overridden method, alloc new slot but leave it empty - * override : must have overridden abstract/virtual, use old slot - * override abstract : must have overridden abstract, use old slot but it is still empty - * static : error if any overridden method, doesn't need a slot - * static new : ignore any overridden method, doesn't need a slot - * virtual : error if any overridden method, alloc new slot and fill it in - * virtual new : ignore any overridden method, alloc new slot and fill it in - */ + // ... and assign virtual method vtable slots. + // + // - : error if any overridden method, doesn't need a slot + // abstract : error if any overridden method, alloc new slot but leave it empty + // new : ignore any overridden method, doesn't need a slot + // new abstract : ignore any overridden method, alloc new slot but leave it empty + // override : must have overridden abstract/virtual, use old slot + // override abstract : must have overridden abstract, use old slot but it is still empty + // static : error if any overridden method, doesn't need a slot + // static new : ignore any overridden method, doesn't need a slot + // virtual : error if any overridden method, alloc new slot and fill it in + // virtual new : ignore any overridden method, alloc new slot and fill it in foreach(TokenDeclVar declFunc in sdtClass.members) { if(declFunc.retType == null) continue; curDeclFunc = declFunc; - /* - * See if there is a method in an extended class that this method overshadows. - * If so, check for various conflicts. - * In any case, SDT_NEW on our method means to ignore any overshadowed method. - */ + // See if there is a method in an extended class that this method overshadows. + // If so, check for various conflicts. + // In any case, SDT_NEW on our method means to ignore any overshadowed method. string declLongName = sdtClass.longName.val + "." + declFunc.funcNameSig.val; uint declFlags = declFunc.sdtFlags; TokenDeclVar overridden = null; @@ -544,9 +492,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine string overLongName = overridden.sdtClass.longName.val; uint overFlags = overridden.sdtFlags; - /* - * See if overridden method allows itself to be overridden. - */ + // See if overridden method allows itself to be overridden. if((overFlags & ScriptReduce.SDT_ABSTRACT) != 0) { if((declFlags & (ScriptReduce.SDT_ABSTRACT | ScriptReduce.SDT_OVERRIDE)) == 0) @@ -573,9 +519,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine break; } - /* - * See if our method is capable of overriding the other method. - */ + // See if our method is capable of overriding the other method. if((declFlags & ScriptReduce.SDT_ABSTRACT) != 0) { if((overFlags & ScriptReduce.SDT_ABSTRACT) == 0) @@ -599,9 +543,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } while(false); - /* - * Now we can assign it a vtable slot if it needs one (ie, it is virtual). - */ + // Now we can assign it a vtable slot if it needs one (ie, it is virtual). declFunc.vTableIndex = -1; if(overridden != null) { @@ -618,11 +560,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine } curDeclFunc = null; - /* - * ... and assign implemented interface slots. - * Note that our implementations of a given interface is completely independent of any - * rootward class's implementation of that same interface. - */ + // ... and assign implemented interface slots. + // Note that our implementations of a given interface is completely independent of any + // rootward class's implementation of that same interface. int nIFaces = sdtClass.numInterfaces + sdtClass.implements.Count; sdtClass.iFaces = new TokenDeclSDTypeInterface[nIFaces]; sdtClass.iImplFunc = new TokenDeclVar[nIFaces][]; @@ -653,11 +593,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine curDeclFunc = classMeth; for(TokenIntfImpl intfImpl = classMeth.implements; intfImpl != null; intfImpl = (TokenIntfImpl)intfImpl.nextToken) { - - /* - * One of the class methods implements an interface method. - * Try to find the interface method that is implemented and verify its signature. - */ + // One of the class methods implements an interface method. + // Try to find the interface method that is implemented and verify its signature. TokenDeclSDTypeInterface intfType = intfImpl.intfType.decl; TokenDeclVar intfMeth = FindExactWithRet(intfType.methsNProps, intfImpl.methName, classMeth.retType, classMeth.argDecl.types); if(intfMeth == null) @@ -666,9 +603,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * See if this class was declared to implement that interface. - */ + // See if this class was declared to implement that interface. bool found = false; foreach(TokenDeclSDTypeInterface intf in sdtClass.implements) { @@ -684,11 +619,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Get index in iFaces[] and iImplFunc[] arrays. - * Start scanning from the end in case one of our rootward classes also implements the interface. - * We should always be successful because we know by now that this class implements the interface. - */ + // Get index in iFaces[] and iImplFunc[] arrays. + // Start scanning from the end in case one of our rootward classes also implements the interface. + // We should always be successful because we know by now that this class implements the interface. int i; for(i = sdtClass.numInterfaces; --i >= 0;) { @@ -696,9 +629,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine break; } - /* - * Now remember which of the class methods implements that interface method. - */ + // Now remember which of the class methods implements that interface method. int j = intfMeth.vTableIndex; if(sdtClass.iImplFunc[i][j] != null) { @@ -710,9 +641,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } curDeclFunc = null; - /* - * Now make sure this class implements all methods for all declared interfaces. - */ + // Now make sure this class implements all methods for all declared interfaces. for(int i = sdtClass.numInterfaces - sdtClass.implements.Count; i < sdtClass.numInterfaces; i++) { TokenDeclVar[] implementations = sdtClass.iImplFunc[i]; @@ -735,18 +664,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * All slots for this class have been assigned. - */ + // All slots for this class have been assigned. sdtClass.slotsAssigned = true; didOne = true; } } while(didOne); - /* - * Compute final values for all variables/fields declared as 'constant'. - * Note that there may be forward references. - */ + // Compute final values for all variables/fields declared as 'constant'. + // Note that there may be forward references. do { didOne = false; @@ -773,9 +698,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine currentSDTClass = null; } while(didOne); - /* - * Now we should be able to assign all those constants their type and location. - */ + // Now we should be able to assign all those constants their type and location. foreach(TokenDeclVar tdv in tokenScript.variablesStack) { if(tdv.constant) @@ -816,20 +739,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine } currentSDTClass = null; - /* - * For all classes that define all the methods needed for the class, ie, they aren't abstract, - * define a static class.$new() method with same args as the $ctor(s). This will allow the - * class to be instantiated via the new operator. - */ + // For all classes that define all the methods needed for the class, ie, they aren't abstract, + // define a static class.$new() method with same args as the $ctor(s). This will allow the + // class to be instantiated via the new operator. foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { if(!(sdType is TokenDeclSDTypeClass)) continue; TokenDeclSDTypeClass sdtClass = (TokenDeclSDTypeClass)sdType; - /* - * See if the class as it stands would be able to fill every slot of its vtable. - */ + // See if the class as it stands would be able to fill every slot of its vtable. bool[] filled = new bool[sdtClass.numVirtFuncs]; int numFilled = 0; for(TokenDeclSDTypeClass sdtc = sdtClass; sdtc != null; sdtc = sdtc.extends) @@ -847,11 +766,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If so, define a static class.$new() method for every constructor defined for the class. - * Give it the same access (private/protected/public) as the script declared for the constructor. - * Note that the reducer made sure there is at least a default constructor for every class. - */ + // If so, define a static class.$new() method for every constructor defined for the class. + // Give it the same access (private/protected/public) as the script declared for the constructor. + // Note that the reducer made sure there is at least a default constructor for every class. if(numFilled >= sdtClass.numVirtFuncs) { List newobjDeclFuncs = new List(); @@ -870,9 +787,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Write fixed portion of object file. - */ + // Write fixed portion of object file. objFileWriter.Write(OBJECT_CODE_MAGIC.ToCharArray()); objFileWriter.Write(COMPILED_VERSION_VALUE); objFileWriter.Write(sourceHash); @@ -884,9 +799,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine objFileWriter.Write(stateNames[i]); } - /* - * For debugging, we also write out global variable array slot assignments. - */ + // For debugging, we also write out global variable array slot assignments. foreach(TokenDeclVar declVar in tokenScript.variablesStack) { if(declVar.retType == null) @@ -909,9 +822,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } objFileWriter.Write(""); - /* - * Write out script-defined types. - */ + // Write out script-defined types. foreach(TokenDeclSDType sdType in tokenScript.sdSrcTypesValues) { objFileWriter.Write(sdType.longName.val); @@ -919,13 +830,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine } objFileWriter.Write(""); - /* - * Output function headers then bodies. - * Do all headers first in case bodies do forward references. - * Do both global functions, script-defined class static methods and - * script-defined instance methods, as we handle the differences - * during compilation of the functions/methods themselves. - */ + // Output function headers then bodies. + // Do all headers first in case bodies do forward references. + // Do both global functions, script-defined class static methods and + // script-defined instance methods, as we handle the differences + // during compilation of the functions/methods themselves. for(int pass = 0; pass < 2; pass++) { foreach(TokenDeclVar declFunc in tokenScript.variablesStack) @@ -957,11 +866,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Output default state event handler functions. - * Each event handler is a private static method named 'default '. - * Splice in a default state_entry() handler if none defined so we can init global vars. - */ + // Output default state event handler functions. + // Each event handler is a private static method named 'default '. + // Splice in a default state_entry() handler if none defined so we can init global vars. TokenDeclVar defaultStateEntry = null; for(defaultStateEntry = tokenScript.defaultState.body.eventFuncs; defaultStateEntry != null; @@ -984,10 +891,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } GenerateStateEventHandlers("default", tokenScript.defaultState.body); - /* - * Output script-defined state event handler methods. - * Each event handler is a private static method named - */ + // Output script-defined state event handler methods. + // Each event handler is a private static method named foreach(KeyValuePair kvp in tokenScript.states) { TokenDeclState declState = kvp.Value; @@ -1059,13 +964,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine string eventname = declFunc.GetSimpleName(); TokenArgDecl argDecl = declFunc.argDecl; - /* - * Make sure event handler name is valid and that number and type of arguments is correct. - * Apparently some scripts exist with fewer than correct number of args in their declaration - * so allow for that. It is ok because the handlers are called with the arguments in an - * object[] array, and we just won't access the missing argments in the vector. But the - * specified types must match one of the prototypes in legalEventHandlers. - */ + // Make sure event handler name is valid and that number and type of arguments is correct. + // Apparently some scripts exist with fewer than correct number of args in their declaration + // so allow for that. It is ok because the handlers are called with the arguments in an + // object[] array, and we just won't access the missing argments in the vector. But the + // specified types must match one of the prototypes in legalEventHandlers. TokenDeclVar protoDeclFunc = legalEventHandlers.FindExact(eventname, argDecl.types); if(protoDeclFunc == null) { @@ -1073,10 +976,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Output function header. - * They just have the XMRInstAbstract pointer as the one argument. - */ + // Output function header. + // They just have the XMRInstAbstract pointer as the one argument. string functionName = statename + " " + eventname; _ilGen = new ScriptObjWriter(tokenScript, functionName, @@ -1086,34 +987,25 @@ namespace OpenSim.Region.ScriptEngine.Yengine objFileWriter); StartFunctionBody(declFunc); - /* - * Create a temp to hold XMRInstanceSuperType version of arg 0. - */ + // Create a temp to hold XMRInstanceSuperType version of arg 0. instancePointer = ilGen.DeclareLocal(xmrInstSuperType, "__xmrinst"); ilGen.Emit(declFunc, OpCodes.Ldarg_0); ilGen.Emit(declFunc, OpCodes.Castclass, xmrInstSuperType); ilGen.Emit(declFunc, OpCodes.Stloc, instancePointer); - /* - * Output args as variable definitions and initialize each from __sw.ehArgs[]. - * If the script writer goofed, the typecast will complain. - */ + // Output args as variable definitions and initialize each from __sw.ehArgs[]. + // If the script writer goofed, the typecast will complain. int nArgs = argDecl.vars.Length; for(int i = 0; i < nArgs; i++) { - - /* - * Say that the argument variable is going to be located in a local var. - */ + // Say that the argument variable is going to be located in a local var. TokenDeclVar argVar = argDecl.vars[i]; TokenType argTokType = argVar.type; CompValuLocalVar local = new CompValuLocalVar(argTokType, argVar.name.val, this); argVar.location = local; - /* - * Copy from the ehArgs[i] element to the temp var. - * Cast as needed, there is a lot of craziness like OpenMetaverse.Quaternion. - */ + // Copy from the ehArgs[i] element to the temp var. + // Cast as needed, there is a lot of craziness like OpenMetaverse.Quaternion. local.PopPre(this, argVar.name); PushXMRInst(); // instance ilGen.Emit(declFunc, OpCodes.Ldfld, ehArgsFieldInfo); // instance.ehArgs (array of objects) @@ -1154,9 +1046,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine local.PopPost(this, argVar.name, stkTokType); // pop stack type into argtype } - /* - * Output code for the statements and clean up. - */ + // Output code for the statements and clean up. GenerateFuncBody(); } @@ -1168,12 +1058,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine { curDeclFunc = declFunc; - /* - * Make up array of all argument types as seen by the code generator. - * We splice in XMRInstanceSuperType or XMRSDTypeClObj for the first - * arg as the function itself is static, followed by script-visible - * arg types. - */ + // Make up array of all argument types as seen by the code generator. + // We splice in XMRInstanceSuperType or XMRSDTypeClObj for the first + // arg as the function itself is static, followed by script-visible + // arg types. TokenArgDecl argDecl = declFunc.argDecl; int nArgs = argDecl.vars.Length; Type[] argTypes = new Type[nArgs + 1]; @@ -1194,9 +1082,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine argNames[i + 1] = argDecl.vars[i].name.val; } - /* - * Set up entrypoint. - */ + // Set up entrypoint. string objCodeName = declFunc.GetObjCodeName(); declFunc.ilGen = new ScriptObjWriter(tokenScript, objCodeName, @@ -1205,9 +1091,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine argNames, objFileWriter); - /* - * This says how to generate a call to the function and to get a delegate. - */ + // This says how to generate a call to the function and to get a delegate. declFunc.location = new CompValuGlobalMeth(declFunc); curDeclFunc = null; @@ -1221,20 +1105,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void GenerateMethodBody(TokenDeclVar declFunc) { - /* - * Set up code generator for the function's contents. - */ + // Set up code generator for the function's contents. _ilGen = declFunc.ilGen; StartFunctionBody(declFunc); - /* - * Create a temp to hold XMRInstanceSuperType version of arg 0. - * For most functions, arg 0 is already XMRInstanceSuperType. - * But for script-defined class instance methods, arg 0 holds - * the XMRSDTypeClObj pointer and so we read the XMRInstAbstract - * pointer from its XMRSDTypeClObj.xmrInst field then cast it to - * XMRInstanceSuperType. - */ + // Create a temp to hold XMRInstanceSuperType version of arg 0. + // For most functions, arg 0 is already XMRInstanceSuperType. + // But for script-defined class instance methods, arg 0 holds + // the XMRSDTypeClObj pointer and so we read the XMRInstAbstract + // pointer from its XMRSDTypeClObj.xmrInst field then cast it to + // XMRInstanceSuperType. if(IsSDTInstMethod()) { instancePointer = ilGen.DeclareLocal(xmrInstSuperType, "__xmrinst"); @@ -1244,11 +1124,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(declFunc, OpCodes.Stloc, instancePointer); } - /* - * Define location of all script-level arguments so script body can access them. - * The argument indices need to have +1 added to them because XMRInstance or - * XMRSDTypeClObj is spliced in at arg 0. - */ + // Define location of all script-level arguments so script body can access them. + // The argument indices need to have +1 added to them because XMRInstance or + // XMRSDTypeClObj is spliced in at arg 0. TokenArgDecl argDecl = declFunc.argDecl; int nArgs = argDecl.vars.Length; for(int i = 0; i < nArgs; i++) @@ -1257,27 +1135,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine argVar.location = new CompValuArg(argVar.type, i + 1); } - /* - * Output code for the statements and clean up. - */ + // Output code for the statements and clean up. GenerateFuncBody(); } private void StartFunctionBody(TokenDeclVar declFunc) { - /* - * Start current function being processed. - * Set 'mightGetHere' as the code at the top is always executed. - */ + // Start current function being processed. + // Set 'mightGetHere' as the code at the top is always executed. instancePointer = null; mightGetHere = true; curBreakTarg = null; curContTarg = null; curDeclFunc = declFunc; - /* - * Start generating code. - */ + // Start generating code. ((ScriptObjWriter)ilGen).BegMethod(); } @@ -1287,9 +1159,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenDeclVar DefineNewobjFunc(TokenDeclVar ctorDeclFunc) { - /* - * Set up 'static classname $new(params-same-as-ctor) { }'. - */ + // Set up 'static classname $new(params-same-as-ctor) { }'. TokenDeclVar newobjDeclFunc = new TokenDeclVar(ctorDeclFunc, null, tokenScript); newobjDeclFunc.name = new TokenName(newobjDeclFunc, "$new"); newobjDeclFunc.retType = ctorDeclFunc.sdtClass.MakeRefToken(newobjDeclFunc); @@ -1297,10 +1167,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine newobjDeclFunc.sdtClass = ctorDeclFunc.sdtClass; newobjDeclFunc.sdtFlags = ScriptReduce.SDT_STATIC | ctorDeclFunc.sdtFlags; - /* - * Declare local variable named '$objptr' in a frame just under - * what the '$new(...)' function's arguments are declared in. - */ + // Declare local variable named '$objptr' in a frame just under + // what the '$new(...)' function's arguments are declared in. TokenDeclVar objptrVar = new TokenDeclVar(newobjDeclFunc, newobjDeclFunc, tokenScript); objptrVar.type = newobjDeclFunc.retType; objptrVar.name = new TokenName(newobjDeclFunc, "$objptr"); @@ -1308,20 +1176,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine newFrame.outerVarDict = ctorDeclFunc.argDecl.varDict; newFrame.AddEntry(objptrVar); - /* - * Set up '$objptr.$ctor' - */ + // Set up '$objptr.$ctor' TokenLValName objptrLValName = new TokenLValName(objptrVar.name, newFrame); + // ref a var by giving its name TokenLValIField objptrDotCtor = new TokenLValIField(newobjDeclFunc); // an instance member reference objptrDotCtor.baseRVal = objptrLValName; // '$objptr' objptrDotCtor.fieldName = ctorDeclFunc.name; // '.' '$ctor' - /* - * Set up '$objptr.$ctor(arglist)' call for use in the '$new(...)' body. - * Copy the arglist from the constructor declaration so triviality - * processing will pick the correct overloaded constructor. - */ + // Set up '$objptr.$ctor(arglist)' call for use in the '$new(...)' body. + // Copy the arglist from the constructor declaration so triviality + // processing will pick the correct overloaded constructor. TokenRValCall callCtorRVal = new TokenRValCall(newobjDeclFunc); // doing a call of some sort callCtorRVal.meth = objptrDotCtor; // calling $objptr.$ctor() TokenDeclVar[] argList = newobjDeclFunc.argDecl.vars; // get args $new() was declared with @@ -1335,32 +1200,26 @@ namespace OpenSim.Region.ScriptEngine.Yengine callCtorRVal.args = argLValName; } - /* - * Set up a funky call to the constructor for the code body. - * This will let code generator know there is some craziness. - * See GenerateStmtNewobj(). - * - * This is in essence: - * { - * classname $objptr = newobj (classname); - * $objptr.$ctor (...); - * return $objptr; - * } - */ + // Set up a funky call to the constructor for the code body. + // This will let code generator know there is some craziness. + // See GenerateStmtNewobj(). + // + // This is in essence: + // { + // classname $objptr = newobj (classname); + // $objptr.$ctor (...); + // return $objptr; + // } TokenStmtNewobj newobjStmtBody = new TokenStmtNewobj(ctorDeclFunc); newobjStmtBody.objptrVar = objptrVar; newobjStmtBody.rValCall = callCtorRVal; TokenStmtBlock newobjBody = new TokenStmtBlock(ctorDeclFunc); newobjBody.statements = newobjStmtBody; - /* - * Link that code as the body of the function. - */ + // Link that code as the body of the function. newobjDeclFunc.body = newobjBody; - /* - * Say the function calls '$objptr.$ctor(arglist)' so we will inherit ctor's triviality. - */ + // Say the function calls '$objptr.$ctor(arglist)' so we will inherit ctor's triviality. newobjDeclFunc.unknownTrivialityCalls.AddLast(callCtorRVal); return newobjDeclFunc; } @@ -1377,43 +1236,33 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void GenerateFuncBody() { - /* - * We want to know if the function's code is trivial, ie, - * if it doesn't have anything that might be an infinite - * loop and that is doesn't call anything that might have - * an infinite loop. If it is, we don't need any CheckRun() - * stuff or any of the frame save/restore stuff. - */ + // We want to know if the function's code is trivial, ie, + // if it doesn't have anything that might be an infinite + // loop and that is doesn't call anything that might have + // an infinite loop. If it is, we don't need any CheckRun() + // stuff or any of the frame save/restore stuff. bool isTrivial = curDeclFunc.IsFuncTrivial(this); - /* - * Clear list of all call labels. - * A call label is inserted just before every call that can possibly - * call CheckRun(), including any direct calls to CheckRun(). - * Then, when restoring stack, we can just switch to this label to - * resume at the correct spot. - */ + // Clear list of all call labels. + // A call label is inserted just before every call that can possibly + // call CheckRun(), including any direct calls to CheckRun(). + // Then, when restoring stack, we can just switch to this label to + // resume at the correct spot. actCallLabels.Clear(); allCallLabels.Clear(); openCallLabel = null; - /* - * Alloc stack space for local vars. - */ + // Alloc stack space for local vars. int stackframesize = AllocLocalVarStackSpace(); - /* - * Include argument variables in stack space for this frame. - */ + // Include argument variables in stack space for this frame. foreach(TokenType tokType in curDeclFunc.argDecl.types) { stackframesize += LocalVarStackSize(tokType); } - /* - * Any return statements inside function body jump to this label - * after putting return value in __retval. - */ + // Any return statements inside function body jump to this label + // after putting return value in __retval. retLabel = ilGen.DefineLabel("__retlbl"); retValue = null; if(!(curDeclFunc.retType is TokenTypeVoid)) @@ -1421,13 +1270,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine retValue = ilGen.DeclareLocal(curDeclFunc.retType.ToSysType(), "__retval"); } - /* - * Output: - * int __mainCallNo = -1; - * instance.m_StackLeft -= stackframesize; - * try { - * if (instance.callMode != CallMode_NORMAL) goto __cmRestore; - */ + // Output: + // int __mainCallNo = -1; + // instance.m_StackLeft -= stackframesize; + // try { + // if (instance.callMode != CallMode_NORMAL) goto __cmRestore; actCallNo = null; ScriptMyLabel cmRestore = null; if(!isTrivial) @@ -1448,18 +1295,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(curDeclFunc, OpCodes.Bne_Un, cmRestore); } - /* - * Splice in the code optimizer for the body of the function. - */ + // Splice in the code optimizer for the body of the function. ScriptCollector collector = new ScriptCollector((ScriptObjWriter)ilGen); _ilGen = collector; - /* - * If this is the default state_entry() handler, output code to set all global - * variables to their initial values. Note that every script must have a - * default state_entry() handler, we provide one if the script doesn't explicitly - * define one. - */ + // If this is the default state_entry() handler, output code to set all global + // variables to their initial values. Note that every script must have a + // default state_entry() handler, we provide one if the script doesn't explicitly + // define one. string methname = ilGen.methName; if(methname == "default state_entry") { @@ -1501,10 +1344,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.MarkLabel(skipGblInitLabel); } - /* - * If this is a script-defined type constructor, call the base constructor and call - * this class's $instfieldinit() method to initialize instance fields. - */ + // If this is a script-defined type constructor, call the base constructor and call + // this class's $instfieldinit() method to initialize instance fields. if((curDeclFunc.sdtClass != null) && curDeclFunc.funcNameSig.val.StartsWith("$ctor(")) { if(curDeclFunc.baseCtorCall != null) @@ -1521,22 +1362,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * See if time to suspend in case they are doing a loop with recursion. - */ + // See if time to suspend in case they are doing a loop with recursion. if(!isTrivial) EmitCallCheckRun(curDeclFunc, true); - /* - * Output code body. - */ + // Output code body. GenerateStmtBlock(curDeclFunc.body); - /* - * If code falls through to this point, means they are missing - * a return statement. And that is legal only if the function - * returns 'void'. - */ + // If code falls through to this point, means they are missing + // a return statement. And that is legal only if the function + // returns 'void'. if(mightGetHere) { if(!(curDeclFunc.retType is TokenTypeVoid)) @@ -1546,28 +1381,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(curDeclFunc, OpCodes.Leave, retLabel); } - /* - * End of the code to be optimized. - * Do optimizations then write it all out to object file. - * After this, all code gets written directly to object file. - * Optimization must be completed before we scan the allCallLabels - * list below to look for active locals and temps. - */ + // End of the code to be optimized. + // Do optimizations then write it all out to object file. + // After this, all code gets written directly to object file. + // Optimization must be completed before we scan the allCallLabels + // list below to look for active locals and temps. collector.Optimize(); _ilGen = collector.WriteOutAll(); collector = null; - /* - * Output code to restore stack frame from stream. - * It jumps back to the call labels within the function body. - */ + // Output code to restore stack frame from stream. + // It jumps back to the call labels within the function body. List activeTemps = null; if(!isTrivial) { - - /* - * Build list of locals and temps active at all the call labels. - */ + // Build list of locals and temps active at all the call labels. activeTemps = new List(); foreach(CallLabel cl in allCallLabels) { @@ -1580,24 +1408,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Output code to restore the args, locals and temps then jump to - * the call label that we were interrupted at. - */ + // Output code to restore the args, locals and temps then jump to + // the call label that we were interrupted at. ilGen.MarkLabel(cmRestore); GenerateFrameRestoreCode(activeTemps); } - /* - * Output epilog that saves stack frame state if CallMode_SAVE. - * - * finally { - * instance.m_StackLeft += stackframesize; - * if (instance.callMode != CallMode_SAVE) goto __endFin; - * GenerateFrameCaptureCode(); - * __endFin: - * } - */ + // Output epilog that saves stack frame state if CallMode_SAVE. + // + // finally { + // instance.m_StackLeft += stackframesize; + // if (instance.callMode != CallMode_SAVE) goto __endFin; + // GenerateFrameCaptureCode(); + // __endFin: + // } ScriptMyLabel endFin = null; if(!isTrivial) { @@ -1619,9 +1443,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.EndExceptionBlock(); } - /* - * Output the 'real' return opcode. - */ + // Output the 'real' return opcode. ilGen.MarkLabel(retLabel); if(!(curDeclFunc.retType is TokenTypeVoid)) { @@ -1631,15 +1453,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine retLabel = null; retValue = null; - /* - * No more instructions for this method. - */ + // No more instructions for this method. ((ScriptObjWriter)ilGen).EndMethod(); _ilGen = null; - /* - * Not generating function code any more. - */ + // Not generating function code any more. curBreakTarg = null; curContTarg = null; curDeclFunc = null; @@ -1655,21 +1473,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine int stackframesize = 64; // RIP, RBX, RBP, R12..R15, one extra foreach(TokenDeclVar localVar in curDeclFunc.localVars) { - - /* - * Skip all 'constant' vars as they were handled by the reducer. - */ + // Skip all 'constant' vars as they were handled by the reducer. if(localVar.constant) continue; - /* - * Get a stack location for the local variable. - */ + // Get a stack location for the local variable. localVar.location = new CompValuLocalVar(localVar.type, localVar.name.val, this); - /* - * Stack size for the local variable. - */ + // Stack size for the local variable. stackframesize += LocalVarStackSize(localVar.type); } return stackframesize; @@ -1692,17 +1503,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void GenerateFrameCaptureCode(List activeTemps) { - /* - * Compute total number of slots we need to save stuff. - * Assume we need to save all call arguments. - */ + // Compute total number of slots we need to save stuff. + // Assume we need to save all call arguments. int nSaves = curDeclFunc.argDecl.vars.Length + activeTemps.Count; - /* - * Output code to allocate a stack frame object with an object array. - * This also pushes the stack frame object on the instance.stackFrames list. - * It returns a pointer to the object array it allocated. - */ + // Output code to allocate a stack frame object with an object array. + // This also pushes the stack frame object on the instance.stackFrames list. + // It returns a pointer to the object array it allocated. PushXMRInst(); ilGen.Emit(curDeclFunc, OpCodes.Ldstr, ilGen.methName); GetCallNo(curDeclFunc, actCallNo); @@ -1718,9 +1525,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo); } - /* - * Copy arg values to object array, boxing as needed. - */ + // Copy arg values to object array, boxing as needed. int i = 0; foreach(TokenDeclVar argVar in curDeclFunc.argDecl.varDict) { @@ -1738,9 +1543,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine i++; } - /* - * Copy local and temp values to object array, boxing as needed. - */ + // Copy local and temp values to object array, boxing as needed. foreach(ScriptMyLocal lcl in activeTemps) { ilGen.Emit(curDeclFunc, OpCodes.Dup); @@ -1789,10 +1592,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine { ScriptMyLocal objArray = ilGen.DeclareLocal(typeof(object[]), "__restObjArray"); - /* - * Output code to pop stack frame from instance.stackFrames. - * It returns a pointer to the object array that contains values to be restored. - */ + // Output code to pop stack frame from instance.stackFrames. + // It returns a pointer to the object array that contains values to be restored. PushXMRInst(); ilGen.Emit(curDeclFunc, OpCodes.Ldstr, ilGen.methName); ilGen.Emit(curDeclFunc, OpCodes.Ldloca, actCallNo); // __mainCallNo @@ -1807,11 +1608,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(curDeclFunc, OpCodes.Call, consoleWriteMethodInfo); } - /* - * Restore argument values from object array, unboxing as needed. - * Although the caller has restored them to what it called us with, it's possible that this - * function has modified them since, so we need to do our own restore. - */ + // Restore argument values from object array, unboxing as needed. + // Although the caller has restored them to what it called us with, it's possible that this + // function has modified them since, so we need to do our own restore. int i = 0; foreach(TokenDeclVar argVar in curDeclFunc.argDecl.varDict) { @@ -1832,9 +1631,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine i++; } - /* - * Restore local and temp values from object array, unboxing as needed. - */ + // Restore local and temp values from object array, unboxing as needed. foreach(ScriptMyLocal lcl in activeTemps) { Type t = lcl.type; @@ -1952,10 +1749,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine this.index = scg.actCallLabels.Count; string name = "__call_" + index + "_" + scg.allCallLabels.Count; - /* - * Make sure eval stack is empty because the frame capture/restore - * code expects such (restore switch stmt has an empty stack). - */ + // Make sure eval stack is empty because the frame capture/restore + // code expects such (restore switch stmt has an empty stack). int depth = ((ScriptCollector)scg.ilGen).stackDepth.Count; if(depth > 0) { @@ -1963,9 +1758,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine throw new Exception("call label stack depth " + depth + " at " + errorAt.SrcLoc); } - /* - * Eval stack is empty so the restore code can handle it. - */ + // Eval stack is empty so the restore code can handle it. this.index = scg.actCallLabels.Count; scg.actCallLabels.AddLast(this); scg.allCallLabels.AddLast(this); @@ -2094,23 +1887,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!mightGetHere) return; - /* - * Push new current statement block pointer for anyone who cares. - */ + // Push new current statement block pointer for anyone who cares. TokenStmtBlock oldStmtBlock = curStmtBlock; curStmtBlock = stmtBlock; - /* - * Output the statements that make up the block. - */ + // Output the statements that make up the block. for(Token t = stmtBlock.statements; t != null; t = t.nextToken) { GenerateStmt((TokenStmt)t); } - /* - * Pop the current statement block. - */ + // Pop the current statement block. curStmtBlock = oldStmtBlock; } @@ -2122,23 +1909,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!mightGetHere) return; - /* - * Make sure we are in a breakable situation. - */ + // Make sure we are in a breakable situation. if(curBreakTarg == null) { ErrorMsg(breakStmt, "not in a breakable situation"); return; } - /* - * Tell anyone who cares that the break target was actually used. - */ + // Tell anyone who cares that the break target was actually used. curBreakTarg.used = true; - /* - * Output the instructions. - */ + // Output the instructions. EmitJumpCode(curBreakTarg.label, curBreakTarg.block, breakStmt); } @@ -2150,23 +1931,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!mightGetHere) return; - /* - * Make sure we are in a contable situation. - */ + // Make sure we are in a contable situation. if(curContTarg == null) { ErrorMsg(contStmt, "not in a continueable situation"); return; } - /* - * Tell anyone who cares that the continue target was actually used. - */ + // Tell anyone who cares that the continue target was actually used. curContTarg.used = true; - /* - * Output the instructions. - */ + // Output the instructions. EmitJumpCode(curContTarg.label, curContTarg.block, contStmt); } @@ -2199,29 +1974,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine CompValu testRVal = GenerateFromRVal(doStmt.testRVal); if(IsConstBoolExprTrue(testRVal)) { - - /* - * Unconditional looping, unconditional branch and - * say we never fall through to next statement. - */ + // Unconditional looping, unconditional branch and + // say we never fall through to next statement. ilGen.Emit(doStmt, OpCodes.Br, loopLabel); mightGetHere = false; } else { - - /* - * Conditional looping, test and brach back to top of loop. - */ + // Conditional looping, test and brach back to top of loop. testRVal.PushVal(this, doStmt.testRVal, tokenTypeBool); ilGen.Emit(doStmt, OpCodes.Brtrue, loopLabel); } } - /* - * If 'break' statement was used, output target label. - * And assume that since a 'break' statement was used, it's possible for the code to get here. - */ + // If 'break' statement was used, output target label. + // And assume that since a 'break' statement was used, it's possible for the code to get here. if(curBreakTarg.used) { ilGen.MarkLabel(curBreakTarg.label); @@ -2253,10 +2020,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } ilGen.MarkLabel(loopLabel); - /* - * See if we have a test expression that is other than a constant TRUE. - * If so, test it and conditionally branch to end if false. - */ + // See if we have a test expression that is other than a constant TRUE. + // If so, test it and conditionally branch to end if false. if(forStmt.testRVal != null) { CompValu testRVal = GenerateFromRVal(forStmt.testRVal); @@ -2268,14 +2033,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Output loop body. - */ + // Output loop body. GenerateStmt(forStmt.bodyStmt); - /* - * Here's where a 'continue' statement jumps to. - */ + // Here's where a 'continue' statement jumps to. if(curContTarg.used) { ilGen.MarkLabel(curContTarg.label); @@ -2284,27 +2045,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(mightGetHere) { - - /* - * After checking for excessive CPU time, output increment statement, if any. - */ + // After checking for excessive CPU time, output increment statement, if any. EmitCallCheckRun(forStmt, false); if(forStmt.incrRVal != null) { GenerateFromRVal(forStmt.incrRVal); } - /* - * Unconditional branch back to beginning of loop. - */ + // Unconditional branch back to beginning of loop. ilGen.Emit(forStmt, OpCodes.Br, loopLabel); } - /* - * If test needs label, output label for it to jump to. - * Otherwise, clear mightGetHere as we know loop never - * falls out the bottom. - */ + // If test needs label, output label for it to jump to. + // Otherwise, clear mightGetHere as we know loop never + // falls out the bottom. mightGetHere = curBreakTarg.used; if(mightGetHere) { @@ -2433,16 +2187,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine bool constVal; - /* - * Test condition and see if constant test expression. - */ + // Test condition and see if constant test expression. CompValu testRVal = GenerateFromRVal(ifStmt.testRVal); if(IsConstBoolExpr(testRVal, out constVal)) { - - /* - * Constant, output just either the true or else part. - */ + // Constant, output just either the true or else part. if(constVal) { GenerateStmt(ifStmt.trueStmt); @@ -2454,10 +2203,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } else if(ifStmt.elseStmt == null) { - - /* - * This is an 'if' statement without an 'else' clause. - */ + // This is an 'if' statement without an 'else' clause. testRVal.PushVal(this, ifStmt.testRVal, tokenTypeBool); ScriptMyLabel doneLabel = ilGen.DefineLabel("ifdone_" + ifStmt.Unique); ilGen.Emit(ifStmt, OpCodes.Brfalse, doneLabel); // brfalse doneLabel @@ -2467,10 +2213,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } else { - - /* - * This is an 'if' statement with an 'else' clause. - */ + // This is an 'if' statement with an 'else' clause. testRVal.PushVal(this, ifStmt.testRVal, tokenTypeBool); ScriptMyLabel elseLabel = ilGen.DefineLabel("ifelse_" + ifStmt.Unique); ilGen.Emit(ifStmt, OpCodes.Brfalse, elseLabel); // brfalse elseLabel @@ -2494,9 +2237,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!mightGetHere) return; - /* - * Make sure the target label is defined somewhere in the function. - */ + // Make sure the target label is defined somewhere in the function. TokenStmtLabel stmtLabel; if(!curDeclFunc.labels.TryGetValue(jumpStmt.label.val, out stmtLabel)) { @@ -2509,9 +2250,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine stmtLabel.labelTagged = true; } - /* - * Emit instructions to do the jump. - */ + // Emit instructions to do the jump. EmitJumpCode(stmtLabel.labelStruct, stmtLabel.block, jumpStmt); } @@ -2522,20 +2261,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void EmitJumpCode(ScriptMyLabel target, TokenStmtBlock targetsBlock, Token errorAt) { - /* - * Jumps never fall through. - */ + // Jumps never fall through. + mightGetHere = false; - /* - * Find which block the target label is in. Must be in this or an outer block, - * no laterals allowed. And if we exit a try/catch block, use Leave instead of Br. - * - * jump lateral; - * { - * @lateral; - * } - */ + // Find which block the target label is in. Must be in this or an outer block, + // no laterals allowed. And if we exit a try/catch block, use Leave instead of Br. + // + // jump lateral; + // { + // @lateral; + // } bool useLeave = false; TokenStmtBlock stmtBlock; Stack finallyBlocksCalled = new Stack(); @@ -2559,46 +2295,44 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If popping through more than one finally block, we have to break it down for the stack - * capture and restore code, one finally block at a time. - * - * try { - * try { - * try { - * jump exit; - * } finally { - * llOwnerSay ("exiting inner"); - * } - * } finally { - * llOwnerSay ("exiting middle"); - * } - * } finally { - * llOwnerSay ("exiting outer"); - * } - * @exit; - * - * try { - * try { - * try { - * jump intr2_exit; <<< gets its own tryNo call label so inner try knows where to restore to - * } finally { - * llOwnerSay ("exiting inner"); - * } - * jump outtry2; - * @intr2_exit; jump intr1_exit; <<< gets its own tryNo call label so middle try knows where to restore to - * @outtry2; - * } finally { - * llOwnerSay ("exiting middle"); - * } - * jump outtry1; - * @intr1_exit: jump exit; <<< gets its own tryNo call label so outer try knows where to restore to - * @outtry1; - * } finally { - * llOwnerSay ("exiting outer"); - * } - * @exit; - */ + // If popping through more than one finally block, we have to break it down for the stack + // capture and restore code, one finally block at a time. + // + // try { + // try { + // try { + // jump exit; + // } finally { + // llOwnerSay ("exiting inner"); + // } + // } finally { + // llOwnerSay ("exiting middle"); + // } + // } finally { + // llOwnerSay ("exiting outer"); + // } + // @exit; + // + // try { + // try { + // try { + // jump intr2_exit; <<< gets its own tryNo call label so inner try knows where to restore to + // } finally { + // llOwnerSay ("exiting inner"); + // } + // jump outtry2; + // @intr2_exit; jump intr1_exit; <<< gets its own tryNo call label so middle try knows where to restore to + // @outtry2; + // } finally { + // llOwnerSay ("exiting middle"); + // } + // jump outtry1; + // @intr1_exit: jump exit; <<< gets its own tryNo call label so outer try knows where to restore to + // @outtry1; + // } finally { + // llOwnerSay ("exiting outer"); + // } + // @exit; int level = 0; while(finallyBlocksCalled.Count > 1) { @@ -2615,12 +2349,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine target = iLeave.jumpIntoLabel; } - /* - * Finally output the branch/leave opcode. - * If using Leave, prefix with a call label in case the corresponding finally block - * calls CheckRun() and that CheckRun() captures the stack, it will have a point to - * restore to that will properly jump back into the finally block. - */ + // Finally output the branch/leave opcode. + // If using Leave, prefix with a call label in case the corresponding finally block + // calls CheckRun() and that CheckRun() captures the stack, it will have a point to + // restore to that will properly jump back into the finally block. if(useLeave) { new CallLabel(this, errorAt); @@ -2650,13 +2382,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine EmitCallCheckRun(labelStmt, false); } - /* - * We are going to say that the label falls through. - * It would be nice if we could analyze all referencing - * goto's to see if all of them are not used but we are - * going to assume that if the script writer put a label - * somewhere, it is probably going to be used. - */ + // We are going to say that the label falls through. + // It would be nice if we could analyze all referencing + // goto's to see if all of them are not used but we are + // going to assume that if the script writer put a label + // somewhere, it is probably going to be used. mightGetHere = true; } @@ -2670,34 +2400,26 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void GenerateStmtNewobj(TokenStmtNewobj newobjStmt) { - /* - * First off, malloc a new empty XMRSDTypeClObj object - * then call the XMRSDTypeClObj()-level constructor. - * Store the result in local var $objptr. - */ + // First off, malloc a new empty XMRSDTypeClObj object + // then call the XMRSDTypeClObj()-level constructor. + // Store the result in local var $objptr. newobjStmt.objptrVar.location.PopPre(this, newobjStmt); ilGen.Emit(newobjStmt, OpCodes.Ldarg_0); ilGen.Emit(newobjStmt, OpCodes.Ldc_I4, curDeclFunc.sdtClass.sdTypeIndex); ilGen.Emit(newobjStmt, OpCodes.Newobj, sdtClassConstructorInfo); newobjStmt.objptrVar.location.PopPost(this, newobjStmt); - /* - * Now call the script-level constructor. - * Pass the object pointer in $objptr as it's 'this' argument. - * The rest of the args are the script-visible args and are just copied from $new() call. - */ + // Now call the script-level constructor. + // Pass the object pointer in $objptr as it's 'this' argument. + // The rest of the args are the script-visible args and are just copied from $new() call. GenerateFromRValCall(newobjStmt.rValCall); - /* - * Put object pointer in retval so it gets returned to caller. - */ + // Put object pointer in retval so it gets returned to caller. newobjStmt.objptrVar.location.PushVal(this, newobjStmt); ilGen.Emit(newobjStmt, OpCodes.Stloc, retValue); - /* - * Exit the function like a return statement. - * And thus we don't fall through. - */ + // Exit the function like a return statement. + // And thus we don't fall through. ilGen.Emit(newobjStmt, OpCodes.Leave, retLabel); mightGetHere = false; } @@ -2740,10 +2462,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(retStmt, OpCodes.Stloc, retValue); } - /* - * Use a OpCodes.Leave instruction to break out of any try { } blocks. - * All Leave's inside script-defined try { } need call labels (see GenerateStmtTry()). - */ + // Use a OpCodes.Leave instruction to break out of any try { } blocks. + // All Leave's inside script-defined try { } need call labels (see GenerateStmtTry()). bool brokeOutOfTry = false; for(TokenStmtBlock stmtBlock = curStmtBlock; stmtBlock != null; stmtBlock = stmtBlock.outerStmtBlock) { @@ -2759,9 +2479,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(brokeOutOfTry) openCallLabel = null; - /* - * 'return' statements never fall through. - */ + // 'return' statements never fall through. mightGetHere = false; } @@ -2787,10 +2505,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine int index = 0; // 'default' state - /* - * Set new state value by throwing an exception. - * These exceptions aren't catchable by script-level try { } catch { }. - */ + // Set new state value by throwing an exception. + // These exceptions aren't catchable by script-level try { } catch { }. if((stateStmt.state != null) && !stateIndices.TryGetValue(stateStmt.state.val, out index)) { // The moron XEngine compiles scripts that reference undefined states. @@ -2808,9 +2524,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } ilGen.Emit(stateStmt, OpCodes.Throw); - /* - * 'state' statements never fall through. - */ + // 'state' statements never fall through. mightGetHere = false; } @@ -2822,22 +2536,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!mightGetHere) return; - /* - * Output code to calculate index. - */ + // Output code to calculate index. CompValu testRVal = GenerateFromRVal(switchStmt.testRVal); - /* - * Generate code based on string or integer index. - */ + // Generate code based on string or integer index. if((testRVal.type is TokenTypeKey) || (testRVal.type is TokenTypeStr)) - { GenerateStmtSwitchStr(testRVal, switchStmt); - } else - { GenerateStmtSwitchInt(testRVal, switchStmt); - } } private void GenerateStmtSwitchInt(CompValu testRVal, TokenStmtSwitch switchStmt) @@ -2851,17 +2557,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine curBreakTarg = new BreakContTarg(this, "switchbreak_" + switchStmt.Unique); - /* - * Build list of cases sorted by ascending values. - * There should not be any overlapping of values. - */ + // Build list of cases sorted by ascending values. + // There should not be any overlapping of values. for(TokenSwitchCase thisCase = switchStmt.cases; thisCase != null; thisCase = thisCase.nextCase) { thisCase.label = ilGen.DefineLabel("case_" + thisCase.Unique); - /* - * The default case if any, goes in its own separate slot. - */ + // The default case if any, goes in its own separate slot. if(thisCase.rVal1 == null) { if(defaultCase != null) @@ -2875,9 +2577,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Evaluate case operands, they must be compile-time integer constants. - */ + // Evaluate case operands, they must be compile-time integer constants. CompValu rVal = GenerateFromRVal(thisCase.rVal1); if(!IsConstIntExpr(rVal, out thisCase.val1)) { @@ -2900,10 +2600,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Insert into list, sorted by value. - * Note that both limits are inclusive. - */ + // Insert into list, sorted by value. + // Note that both limits are inclusive. TokenSwitchCase lastCase = null; TokenSwitchCase nextCase; for(nextCase = sortedCases; nextCase != null; nextCase = nextCase.nextSortedCase) @@ -2934,19 +2632,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine defaultLabel = ilGen.DefineLabel("default_" + switchStmt.Unique); } - /* - * Output code to jump to the case statement's labels based on integer index on stack. - * Note that each case still has the integer index on stack when jumped to. - */ + // Output code to jump to the case statement's labels based on integer index on stack. + // Note that each case still has the integer index on stack when jumped to. int offset = 0; for(TokenSwitchCase thisCase = sortedCases; thisCase != null;) { - - /* - * Scan through list of cases to find the maximum number of cases who's numvalues-to-case ratio - * is from 0.5 to 2.0. If such a group is found, use a CIL switch for them. If not, just use a - * compare-and-branch for the current case. - */ + // Scan through list of cases to find the maximum number of cases who's numvalues-to-case ratio + // is from 0.5 to 2.0. If such a group is found, use a CIL switch for them. If not, just use a + // compare-and-branch for the current case. int numCases = 0; int numFound = 0; int lowValue = thisCase.val1; @@ -2963,23 +2656,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine } if(numFound > 1) { - - /* - * There is a group of case's, starting with thisCase, that fall within our criteria, ie, - * that have a nice density of meaningful jumps. - * - * So first generate an array of jumps to the default label (explicit or implicit). - */ + // There is a group of case's, starting with thisCase, that fall within our criteria, ie, + // that have a nice density of meaningful jumps. + // + // So first generate an array of jumps to the default label (explicit or implicit). ScriptMyLabel[] labels = new ScriptMyLabel[numValues]; for(int i = 0; i < numValues; i++) { labels[i] = defaultLabel; } - /* - * Next, for each case in that group, fill in the corresponding array entries to jump to - * that case's label. - */ + // Next, for each case in that group, fill in the corresponding array entries to jump to + // that case's label. do { for(int i = thisCase.val1; i <= thisCase.val2; i++) @@ -2989,10 +2677,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine thisCase = thisCase.nextSortedCase; } while(--numFound > 0); - /* - * Subtract the low value and do the computed jump. - * The OpCodes.Switch falls through if out of range (unsigned compare). - */ + // Subtract the low value and do the computed jump. + // The OpCodes.Switch falls through if out of range (unsigned compare). if(offset != lowValue) { ilGen.Emit(switchStmt, OpCodes.Ldc_I4, lowValue - offset); @@ -3004,11 +2690,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } else { - - /* - * It's not economical to do with a computed jump, so output a subtract/compare/branch - * for thisCase. - */ + // It's not economical to do with a computed jump, so output a subtract/compare/branch + // for thisCase. if(lowValue == thisCase.val2) { ilGen.Emit(switchStmt, OpCodes.Dup); @@ -3032,15 +2715,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine } ilGen.Emit(switchStmt, OpCodes.Br, defaultLabel); - /* - * Output code for the cases themselves, in the order given by the programmer, - * so they fall through as programmer wants. This includes the default case, if any. - * - * Each label is jumped to with the index still on the stack. So pop it off in case - * the case body does a goto outside the switch or a return. If the case body might - * fall through to the next case or the bottom of the switch, push a zero so the stack - * matches in all cases. - */ + // Output code for the cases themselves, in the order given by the programmer, + // so they fall through as programmer wants. This includes the default case, if any. + // + // Each label is jumped to with the index still on the stack. So pop it off in case + // the case body does a goto outside the switch or a return. If the case body might + // fall through to the next case or the bottom of the switch, push a zero so the stack + // matches in all cases. for(TokenSwitchCase thisCase = switchStmt.cases; thisCase != null; thisCase = thisCase.nextCase) { ilGen.MarkLabel(thisCase.label); // the branch comes here @@ -3057,28 +2738,22 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If no explicit default case, output the default label here. - */ + // If no explicit default case, output the default label here. if(defaultCase == null) { ilGen.MarkLabel(defaultLabel); mightGetHere = true; } - /* - * If the last case of the switch falls through out the bottom, - * we have to pop the index still on the stack. - */ + // If the last case of the switch falls through out the bottom, + // we have to pop the index still on the stack. if(mightGetHere) { ilGen.Emit(switchStmt, OpCodes.Pop); } - /* - * Output the 'break' statement target label. - * Note that the integer index is not on the stack at this point. - */ + // Output the 'break' statement target label. + // Note that the integer index is not on the stack at this point. if(curBreakTarg.used) { ilGen.MarkLabel(curBreakTarg.label); @@ -3097,9 +2772,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine curBreakTarg = new BreakContTarg(this, "switchbreak_" + switchStmt.Unique); - /* - * Make sure value is in a temp so we don't compute it more than once. - */ + // Make sure value is in a temp so we don't compute it more than once. if(!(testRVal is CompValuTemp)) { CompValuTemp temp = new CompValuTemp(testRVal.type, this); @@ -3108,17 +2781,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine testRVal = temp; } - /* - * Build tree of cases. - * There should not be any overlapping of values. - */ + // Build tree of cases. + // There should not be any overlapping of values. for(TokenSwitchCase thisCase = switchStmt.cases; thisCase != null; thisCase = thisCase.nextCase) { thisCase.label = ilGen.DefineLabel("case"); - /* - * The default case if any, goes in its own separate slot. - */ + // The default case if any, goes in its own separate slot. if(thisCase.rVal1 == null) { if(defaultCase != null) @@ -3132,9 +2801,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Evaluate case operands, they must be compile-time string constants. - */ + // Evaluate case operands, they must be compile-time string constants. CompValu rVal = GenerateFromRVal(thisCase.rVal1); if(!IsConstStrExpr(rVal, out thisCase.str1)) { @@ -3157,31 +2824,23 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Insert into list, sorted by value. - * Note that both limits are inclusive. - */ + // Insert into list, sorted by value. + // Note that both limits are inclusive. caseTreeTop = InsertCaseInTree(caseTreeTop, thisCase); } - /* - * Balance tree so we end up generating code that does O(log2 n) comparisons. - */ + // Balance tree so we end up generating code that does O(log2 n) comparisons. caseTreeTop = BalanceTree(caseTreeTop); - /* - * Output compare and branch instructions in a tree-like fashion so we do O(log2 n) comparisons. - */ + // Output compare and branch instructions in a tree-like fashion so we do O(log2 n) comparisons. if(defaultLabel == null) { defaultLabel = ilGen.DefineLabel("default"); } OutputStrCase(testRVal, caseTreeTop, defaultLabel); - /* - * Output code for the cases themselves, in the order given by the programmer, - * so they fall through as programmer wants. This includes the default case, if any. - */ + // Output code for the cases themselves, in the order given by the programmer, + // so they fall through as programmer wants. This includes the default case, if any. for(TokenSwitchCase thisCase = switchStmt.cases; thisCase != null; thisCase = thisCase.nextCase) { ilGen.MarkLabel(thisCase.label); // the branch comes here @@ -3192,18 +2851,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If no explicit default case, output the default label here. - */ + // If no explicit default case, output the default label here. if(defaultCase == null) { ilGen.MarkLabel(defaultLabel); mightGetHere = true; } - /* - * Output the 'break' statement target label. - */ + // Output the 'break' statement target label. if(curBreakTarg.used) { ilGen.MarkLabel(curBreakTarg.label); @@ -3268,10 +2923,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine int hc = CountTree(r.higherCase); TokenSwitchCase n, x; - /* - * If lower side is heavy, move highest nodes from lower side to - * higher side until balanced. - */ + // If lower side is heavy, move highest nodes from lower side to + // higher side until balanced. while(lc > hc + 1) { x = ExtractHighest(r.lowerCase, out n); @@ -3283,10 +2936,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine hc++; } - /* - * If higher side is heavy, move lowest nodes from higher side to - * lower side until balanced. - */ + // If higher side is heavy, move lowest nodes from higher side to + // lower side until balanced. while(hc > lc + 1) { x = ExtractLowest(r.higherCase, out n); @@ -3298,9 +2949,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine hc--; } - /* - * Now balance each side because they can be lopsided individually. - */ + // Now balance each side because they can be lopsided individually. r.lowerCase = BalanceTree(r.lowerCase); r.higherCase = BalanceTree(r.higherCase); return r; @@ -3359,10 +3008,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void OutputStrCase(CompValu testRVal, TokenSwitchCase thisCase, ScriptMyLabel defaultLabel) { - /* - * If nothing lower on tree and there is a single case value, - * just do one compare for equality. - */ + // If nothing lower on tree and there is a single case value, + // just do one compare for equality. if((thisCase.lowerCase == null) && (thisCase.higherCase == null) && (thisCase.str1 == thisCase.str2)) { testRVal.PushVal(this, thisCase, tokenTypeStr); @@ -3374,28 +3021,22 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Determine where to jump if switch value is lower than lower case value. - */ + // Determine where to jump if switch value is lower than lower case value. ScriptMyLabel lowerLabel = defaultLabel; if(thisCase.lowerCase != null) { lowerLabel = ilGen.DefineLabel("lower"); } - /* - * If single case value, put comparison result in this temp. - */ + // If single case value, put comparison result in this temp. CompValuTemp cmpv1 = null; if(thisCase.str1 == thisCase.str2) { cmpv1 = new CompValuTemp(tokenTypeInt, this); } - /* - * If switch value .lt. lower case value, jump to lower label. - * Maybe save comparison result in a temp. - */ + // If switch value .lt. lower case value, jump to lower label. + // Maybe save comparison result in a temp. testRVal.PushVal(this, thisCase, tokenTypeStr); ilGen.Emit(thisCase, OpCodes.Ldstr, thisCase.str1); ilGen.Emit(thisCase, OpCodes.Ldc_I4, (int)StringComparison.Ordinal); @@ -3408,10 +3049,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(thisCase, OpCodes.Ldc_I4_0); ilGen.Emit(thisCase, OpCodes.Blt, lowerLabel); - /* - * If switch value .le. higher case value, jump to case code. - * Maybe get comparison from the temp. - */ + // If switch value .le. higher case value, jump to case code. + // Maybe get comparison from the temp. if(cmpv1 == null) { testRVal.PushVal(this, thisCase, tokenTypeStr); @@ -3426,9 +3065,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(thisCase, OpCodes.Ldc_I4_0); ilGen.Emit(thisCase, OpCodes.Ble, thisCase.label); - /* - * Output code for higher comparison if any. - */ + // Output code for higher comparison if any. if(thisCase.higherCase == null) { ilGen.Emit(thisCase, OpCodes.Br, defaultLabel); @@ -3438,9 +3075,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine OutputStrCase(testRVal, thisCase.higherCase, defaultLabel); } - /* - * Output code for lower comparison if any. - */ + // Output code for lower comparison if any. if(thisCase.lowerCase != null) { ilGen.MarkLabel(lowerLabel); @@ -3457,14 +3092,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!mightGetHere) return; - /* - * 'throw' statements never fall through. - */ + // 'throw' statements never fall through. mightGetHere = false; - /* - * Output code for either a throw or a rethrow. - */ + // Output code for either a throw or a rethrow. if(throwStmt.rVal == null) { for(TokenStmtBlock blk = curStmtBlock; blk != null; blk = blk.outerStmtBlock) @@ -3506,24 +3137,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine throw new Exception("can't have both catch and finally on same try"); } - /* - * Stack the call labels. - * Try blocks have their own series of call labels. - */ + // Stack the call labels. + // Try blocks have their own series of call labels. ScriptMyLocal saveCallNo = actCallNo; LinkedList saveCallLabels = actCallLabels; - /* - * Generate code for either try { } catch { } or try { } finally { }. - */ + // Generate code for either try { } catch { } or try { } finally { }. if(tryStmt.catchStmt != null) GenerateStmtTryCatch(tryStmt); if(tryStmt.finallyStmt != null) GenerateStmtTryFinally(tryStmt); - /* - * Restore call labels. - */ + // Restore call labels. actCallNo = saveCallNo; actCallLabels = saveCallLabels; } @@ -4017,10 +3642,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void GenerateDeclVar(TokenDeclVar declVar) { - /* - * Script gave us an initialization value, so just store init value in var like an assignment statement. - * If no init given, set it to its default value. - */ + // Script gave us an initialization value, so just store init value in var like an assignment statement. + // If no init given, set it to its default value. CompValu local = declVar.location; if(declVar.init != null) { @@ -4070,14 +3693,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine { CompValu subCompValu; - /* - * Compute location of array itself. - */ + // Compute location of array itself. CompValu baseCompValu = GenerateFromRVal(lVal.baseRVal); - /* - * Maybe it is a fixed array access. - */ + // Maybe it is a fixed array access. string basetypestring = baseCompValu.type.ToString(); if(basetypestring.EndsWith("]")) { @@ -4106,9 +3725,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuFixArEl(this, baseCompValu, subCompValus); } - /* - * Maybe it is accessing the $idxprop property of a script-defined class. - */ + // Maybe it is accessing the $idxprop property of a script-defined class. if(baseCompValu.type is TokenTypeSDTypeClass) { TokenName name = new TokenName(lVal, "$idxprop"); @@ -4133,9 +3750,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } - /* - * Maybe they are accessing $idxprop property of a script-defined interface. - */ + // Maybe they are accessing $idxprop property of a script-defined interface. if(baseCompValu.type is TokenTypeSDTypeInterface) { TokenName name = new TokenName(lVal, "$idxprop"); @@ -4152,27 +3767,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuIdxProp(idxProp, baseCompValu, argTypes, compValus); } - /* - * Maybe it is extracting a character from a string. - */ + // Maybe it is extracting a character from a string. if((baseCompValu.type is TokenTypeKey) || (baseCompValu.type is TokenTypeStr)) { subCompValu = GenerateFromRVal(lVal.subRVal); return new CompValuStrChr(new TokenTypeChar(lVal), baseCompValu, subCompValu); } - /* - * Maybe it is extracting an element from a list. - */ + // Maybe it is extracting an element from a list. if(baseCompValu.type is TokenTypeList) { subCompValu = GenerateFromRVal(lVal.subRVal); return new CompValuListEl(new TokenTypeObject(lVal), baseCompValu, subCompValu); } - /* - * Access should be to XMR_Array otherwise. - */ + // Access should be to XMR_Array otherwise. if(!(baseCompValu.type is TokenTypeArray)) { ErrorMsg(lVal, "taking subscript of non-array"); @@ -4286,9 +3895,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine CompValu baseRVal = GenerateFromRVal(lVal.baseRVal); string fieldName = lVal.fieldName.val + ArgSigString(argsig); - /* - * Maybe they are accessing an instance field, method or property of a script-defined class. - */ + // Maybe they are accessing an instance field, method or property of a script-defined class. if(baseRVal.type is TokenTypeSDTypeClass) { TokenTypeSDTypeClass sdtType = (TokenTypeSDTypeClass)baseRVal.type; @@ -4303,9 +3910,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuVoid(lVal.fieldName); } - /* - * Maybe they are accessing a method or property of a script-defined interface. - */ + // Maybe they are accessing a method or property of a script-defined interface. if(baseRVal.type is TokenTypeSDTypeInterface) { TokenTypeSDTypeInterface sdtType = (TokenTypeSDTypeInterface)baseRVal.type; @@ -4318,9 +3923,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuVoid(lVal.fieldName); } - /* - * Since we only have a few built-in types with fields, just pound them out. - */ + // Since we only have a few built-in types with fields, just pound them out. if(baseRVal.type is TokenTypeArray) { @@ -4392,9 +3995,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private CompValu GenerateFromLValName(TokenLValName lVal, TokenType[] argsig) { - /* - * Look in variable stack then look for built-in constants and functions. - */ + // Look in variable stack then look for built-in constants and functions. TokenDeclVar var = FindNamedVar(lVal, argsig); if(var == null) { @@ -4402,9 +4003,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuVoid(lVal); } - /* - * Maybe it has an implied 'this.' on the front. - */ + // Maybe it has an implied 'this.' on the front. if((var.sdtClass != null) && ((var.sdtFlags & ScriptReduce.SDT_STATIC) == 0)) { @@ -4414,33 +4013,31 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuVoid(lVal); } - /* - * Don't allow something such as: - * - * class A { - * integer I; - * class B { - * Print () - * { - * llOwnerSay ("I=" + (string)I); <- access to I not allowed inside class B. - * explicit reference required as we don't - * have a valid reference to class A. - * } - * } - * } - * - * But do allow something such as: - * - * class A { - * integer I; - * } - * class B : A { - * Print () - * { - * llOwnerSay ("I=" + (string)I); - * } - * } - */ + // Don't allow something such as: + // + // class A { + // integer I; + // class B { + // Print () + // { + // llOwnerSay ("I=" + (string)I); <- access to I not allowed inside class B. + // explicit reference required as we don't + // have a valid reference to class A. + // } + // } + // } + // + // But do allow something such as: + // + // class A { + // integer I; + // } + // class B : A { + // Print () + // { + // llOwnerSay ("I=" + (string)I); + // } + // } for(TokenDeclSDType c = curDeclFunc.sdtClass; c != var.sdtClass; c = c.extends) { if(c == null) @@ -4455,9 +4052,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return AccessInstanceMember(var, thisCompValu, lVal, false); } - /* - * It's a local variable, static field, global, constant, etc. - */ + // It's a local variable, static field, global, constant, etc. return var.location; } @@ -4487,9 +4082,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenType stType = lVal.baseType; string fieldName = lVal.fieldName.val + ArgSigString(argsig); - /* - * Maybe they are accessing a static member of a script-defined class. - */ + // Maybe they are accessing a static member of a script-defined class. if(stType is TokenTypeSDTypeClass) { TokenTypeSDTypeClass sdtType = (TokenTypeSDTypeClass)stType; @@ -4529,9 +4122,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { errorMessageToken = rVal; - /* - * Maybe the expression can be converted to a constant. - */ + // Maybe the expression can be converted to a constant. bool didOne; do { @@ -4539,9 +4130,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine rVal = rVal.TryComputeConstant(LookupBodyConstants, ref didOne); } while(didOne); - /* - * Generate code for the computation and return resulting type and location. - */ + // Generate code for the computation and return resulting type and location. CompValu cVal = null; if(rVal is TokenRValAsnPost) cVal = GenerateFromRValAsnPost((TokenRValAsnPost)rVal); @@ -4583,9 +4172,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(cVal == null) throw new Exception("bad rval class " + rVal.GetType().ToString()); - /* - * Sanity check. - */ + // Sanity check. if(!youveAnError) { if(cVal.type == null) @@ -4616,30 +4203,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine CompValu left, right; string opcodeIndex = token.opcode.ToString(); - /* - * Comma operators are special, as they say to compute the left-hand value and - * discard it, then compute the right-hand argument and that is the result. - */ + // Comma operators are special, as they say to compute the left-hand value and + // discard it, then compute the right-hand argument and that is the result. if(opcodeIndex == ",") { - - /* - * Compute left-hand operand but throw away result. - */ + // Compute left-hand operand but throw away result. GenerateFromRVal(token.rValLeft); - /* - * Compute right-hand operand and that is the value of the expression. - */ + // Compute right-hand operand and that is the value of the expression. return GenerateFromRVal(token.rValRight); } - /* - * Simple overwriting assignments are their own special case, - * as we want to cast the R-value to the type of the L-value. - * And in the case of delegates, we want to use the arg signature - * of the delegate to select which overloaded method to use. - */ + // Simple overwriting assignments are their own special case, + // as we want to cast the R-value to the type of the L-value. + // And in the case of delegates, we want to use the arg signature + // of the delegate to select which overloaded method to use. if(opcodeIndex == "=") { if(!(token.rValLeft is TokenLVal)) @@ -4655,26 +4233,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine return left; } - /* - * There are String.Concat() methods available for 2, 3 and 4 operands. - * So see if we have a string concat op and optimize if so. - */ + // There are String.Concat() methods available for 2, 3 and 4 operands. + // So see if we have a string concat op and optimize if so. if((opcodeIndex == "+") || ((opcodeIndex == "+=") && (token.rValLeft is TokenLVal) && (token.rValLeft.GetRValType(this, null) is TokenTypeStr))) { - /* - * We are adding something. Maybe it's a bunch of strings together. - */ + // We are adding something. Maybe it's a bunch of strings together. List scorvs = new List(); if(StringConcatOperands(token.rValLeft, token.rValRight, scorvs, token.opcode)) { - - /* - * Evaluate all the operands, right-to-left on purpose per LSL scripting. - */ + // Evaluate all the operands, right-to-left on purpose per LSL scripting. int i; int n = scorvs.Count; CompValu[] scocvs = new CompValu[n]; @@ -4700,10 +4271,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } retcv.PopPre(this, token); - /* - * Call the String.Concat() methods, passing operands in left-to-right order. - * Force a cast to string (retcv.type) for each operand. - */ + // Call the String.Concat() methods, passing operands in left-to-right order. + // Force a cast to string (retcv.type) for each operand. ++i; scocvs[i].PushVal(this, scorvs[i], retcv.type); while(i + 3 < n) @@ -4731,18 +4300,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(scorvs[i], OpCodes.Call, stringConcat2MethodInfo); } - /* - * Put the result where we want it and return where we put it. - */ + // Put the result where we want it and return where we put it. retcv.PopPost(this, token); return retcv; } } - /* - * If "&&&", it is a short-circuiting AND. - * Compute left-hand operand and if true, compute right-hand operand. - */ + // If "&&&", it is a short-circuiting AND. + // Compute left-hand operand and if true, compute right-hand operand. if(opcodeIndex == "&&&") { bool leftVal, rightVal; @@ -4791,10 +4356,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuInteger(new TokenTypeInt(token), rightVal ? 1 : 0); } - /* - * If "|||", it is a short-circuiting OR. - * Compute left-hand operand and if false, compute right-hand operand. - */ + // If "|||", it is a short-circuiting OR. + // Compute left-hand operand and if false, compute right-hand operand. if(opcodeIndex == "|||") { bool leftVal, rightVal; @@ -4843,17 +4406,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuInteger(new TokenTypeInt(token), rightVal ? 1 : 0); } - /* - * Computation of some sort, compute right-hand operand value then left-hand value - * because LSL is supposed to be right-to-left evaluation. - */ + // Computation of some sort, compute right-hand operand value then left-hand value + // because LSL is supposed to be right-to-left evaluation. right = Trivialize(GenerateFromRVal(token.rValRight), token.rValRight); - /* - * If left is a script-defined class and there is a method with the operator's name, - * convert this to a call to that method with the right value as its single parameter. - * Except don't if the right value is 'undef' so they can always compare to undef. - */ + // If left is a script-defined class and there is a method with the operator's name, + // convert this to a call to that method with the right value as its single parameter. + // Except don't if the right value is 'undef' so they can always compare to undef. TokenType leftType = token.rValLeft.GetRValType(this, null); if((leftType is TokenTypeSDTypeClass) && !(right.type is TokenTypeUndef)) { @@ -4872,28 +4431,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Formulate key string for binOpStrings = (lefttype)(operator)(righttype) - */ + // Formulate key string for binOpStrings = (lefttype)(operator)(righttype) string leftIndex = leftType.ToString(); string rightIndex = right.type.ToString(); string key = leftIndex + opcodeIndex + rightIndex; - /* - * If that key exists in table, then the operation is defined between those types - * ... and it produces an R-value of type as given in the table. - */ + // If that key exists in table, then the operation is defined between those types + // ... and it produces an R-value of type as given in the table. BinOpStr binOpStr; if(BinOpStr.defined.TryGetValue(key, out binOpStr)) { - - /* - * If table contained an explicit assignment type like +=, output the statement without - * casting the L-value, then return the L-value as the resultant value. - * - * Make sure we don't include comparisons (such as ==, >=, etc). - * Nothing like +=, -=, %=, etc, generate a boolean, only the comparisons. - */ + // If table contained an explicit assignment type like +=, output the statement without + // casting the L-value, then return the L-value as the resultant value. + // + // Make sure we don't include comparisons (such as ==, >=, etc). + // Nothing like +=, -=, %=, etc, generate a boolean, only the comparisons. if((binOpStr.outtype != typeof(bool)) && opcodeIndex.EndsWith("=") && (opcodeIndex != "!=")) { if(!(token.rValLeft is TokenLVal)) @@ -4906,21 +4458,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine return left; } - /* - * It's of the form left binop right. - * Compute left, perform operation then put result in a temp. - */ + // It's of the form left binop right. + // Compute left, perform operation then put result in a temp. left = GenerateFromRVal(token.rValLeft); CompValu retRVal = new CompValuTemp(TokenType.FromSysType(token.opcode, binOpStr.outtype), this); binOpStr.emitBO(this, token, left, right, retRVal); return retRVal; } - /* - * Nothing in the table, check for comparing object pointers because of the myriad of types possible. - * This will compare list pointers, null pointers, script-defined type pointers, array pointers, etc. - * It will show equal iff the memory addresses are equal and that is good enough. - */ + // Nothing in the table, check for comparing object pointers because of the myriad of types possible. + // This will compare list pointers, null pointers, script-defined type pointers, array pointers, etc. + // It will show equal iff the memory addresses are equal and that is good enough. if(!leftType.ToSysType().IsValueType && !right.type.ToSysType().IsValueType && ((opcodeIndex == "==") || (opcodeIndex == "!="))) { CompValuTemp retRVal = new CompValuTemp(new TokenTypeInt(token), this); @@ -4937,12 +4485,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine return retRVal; } - /* - * If the opcode ends with "=", it may be something like "+=". - * So look up the key as if we didn't have the "=" to tell us if the operation is legal. - * Also, the binary operation's output type must be the same as the L-value type. - * Likewise, integer += float not allowed because result is float, but float += integer is ok. - */ + // If the opcode ends with "=", it may be something like "+=". + // So look up the key as if we didn't have the "=" to tell us if the operation is legal. + // Also, the binary operation's output type must be the same as the L-value type. + // Likewise, integer += float not allowed because result is float, but float += integer is ok. if(opcodeIndex.EndsWith("=")) { key = leftIndex + opcodeIndex.Substring(0, opcodeIndex.Length - 1) + rightIndex; @@ -4959,9 +4505,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuVoid(token); } - /* - * Now we know for something like %= that left%right is legal for the types given. - */ + // Now we know for something like %= that left%right is legal for the types given. left = GenerateFromLVal((TokenLVal)token.rValLeft); if(binOpStr.outtype == leftType.ToSysType()) { @@ -4979,9 +4523,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Can't find it, oh well. - */ + // Can't find it, oh well. ErrorMsg(token, "op not defined: " + leftIndex + " " + opcodeIndex + " " + rightIndex); return new CompValuVoid(token); } @@ -5007,26 +4549,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!(leftType is TokenTypeStr) && !(rightType is TokenTypeStr)) return false; - /* - * Also, list+string => list so reject that too. - * Also, string+list => list so reject that too. - */ + // Also, list+string => list so reject that too. + // Also, string+list => list so reject that too. if(leftType is TokenTypeList) return false; if(rightType is TokenTypeList) return false; - /* - * Append values to the end of the list in left-to-right order. - * If value is formed from a something+something => string, - * push them as separate values, otherwise push as one value. - */ + // Append values to the end of the list in left-to-right order. + // If value is formed from a something+something => string, + // push them as separate values, otherwise push as one value. StringConcatOperand(leftType, leftRVal, scos); StringConcatOperand(rightType, rightRVal, scos); - /* - * Maybe constant strings can be concatted. - */ + // Maybe constant strings can be concatted. try { int len; @@ -5044,9 +4580,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { } - /* - * We pushed some string stuff. - */ + // We pushed some string stuff. return true; } @@ -5090,9 +4624,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { CompValu inRVal = GenerateFromRVal(token.rVal); - /* - * Script-defined types can define their own methods to handle unary operators. - */ + // Script-defined types can define their own methods to handle unary operators. if(inRVal.type is TokenTypeSDTypeClass) { TokenTypeSDTypeClass sdtType = (TokenTypeSDTypeClass)inRVal.type; @@ -5107,9 +4639,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Otherwise use the default. - */ + // Otherwise use the default. return UnOpGenerate(inRVal, token.opcode); } @@ -5120,26 +4650,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine { CompValu lVal = GenerateFromLVal(asnPost.lVal); - /* - * Make up a temp to save original value in. - */ + // Make up a temp to save original value in. CompValuTemp result = new CompValuTemp(lVal.type, this); - /* - * Prepare to pop incremented value back into variable being incremented. - */ + // Prepare to pop incremented value back into variable being incremented. lVal.PopPre(this, asnPost.lVal); - /* - * Copy original value to temp and leave value on stack. - */ + // Copy original value to temp and leave value on stack. lVal.PushVal(this, asnPost.lVal); ilGen.Emit(asnPost.lVal, OpCodes.Dup); result.Pop(this, asnPost.lVal); - /* - * Perform the ++/--. - */ + // Perform the ++/--. if((lVal.type is TokenTypeChar) || (lVal.type is TokenTypeInt)) { ilGen.Emit(asnPost, OpCodes.Ldc_I4_1); @@ -5170,9 +4692,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine throw new Exception("unknown asnPost op"); } - /* - * Store new value in original variable. - */ + // Store new value in original variable. lVal.PopPost(this, asnPost.lVal); return result; @@ -5185,24 +4705,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine { CompValu lVal = GenerateFromLVal(asnPre.lVal); - /* - * Make up a temp to put result in. - */ + // Make up a temp to put result in. CompValuTemp result = new CompValuTemp(lVal.type, this); - /* - * Prepare to pop incremented value back into variable being incremented. - */ + // Prepare to pop incremented value back into variable being incremented. lVal.PopPre(this, asnPre.lVal); - /* - * Push original value. - */ + // Push original value. lVal.PushVal(this, asnPre.lVal); - /* - * Perform the ++/--. - */ + // Perform the ++/--. if((lVal.type is TokenTypeChar) || (lVal.type is TokenTypeInt)) { ilGen.Emit(asnPre, OpCodes.Ldc_I4_1); @@ -5233,15 +4745,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine throw new Exception("unknown asnPre op"); } - /* - * Store new value in temp variable, keeping new value on stack. - */ + // Store new value in temp variable, keeping new value on stack. ilGen.Emit(asnPre.lVal, OpCodes.Dup); result.Pop(this, asnPre.lVal); - /* - * Store new value in original variable. - */ + // Store new value in original variable. lVal.PopPost(this, asnPre.lVal); return result; @@ -5259,11 +4767,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenRVal arg; TokenType[] argTypes; - /* - * Compute the values of all the function's call arguments. - * Save where the computation results are in the argRVals[] array. - * Might as well build the argument signature from the argument types, too. - */ + // Compute the values of all the function's call arguments. + // Save where the computation results are in the argRVals[] array. + // Might as well build the argument signature from the argument types, too. nargs = call.nArgs; argRVals = new CompValu[nargs]; argTypes = new TokenType[nargs]; @@ -5278,9 +4784,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Get function/method's entrypoint that matches the call argument types. - */ + // Get function/method's entrypoint that matches the call argument types. method = GenerateFromRVal(call.meth, argTypes); if(method == null) return null; @@ -5302,9 +4806,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenType retType; TokenType[] argTypes; - /* - * Must be some kind of callable. - */ + // Must be some kind of callable. retType = method.GetRetType(); // TokenTypeVoid if void; null means a variable if(retType == null) { @@ -5312,9 +4814,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuVoid(call); } - /* - * Get a location for return value. - */ + // Get a location for return value. if(retType is TokenTypeVoid) { result = new CompValuVoid(call); @@ -5324,10 +4824,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine result = new CompValuTemp(retType, this); } - /* - * Make sure all arguments are trivial, ie, don't involve their own call labels. - * For any that aren't, output code to calculate the arg and put in a temporary. - */ + // Make sure all arguments are trivial, ie, don't involve their own call labels. + // For any that aren't, output code to calculate the arg and put in a temporary. nArgs = argRVals.Length; for(i = 0; i < nArgs; i++) { @@ -5337,9 +4835,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Inline functions know how to generate their own call. - */ + // Inline functions know how to generate their own call. if(method is CompValuInline) { CompValuInline inline = (CompValuInline)method; @@ -5347,14 +4843,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine return result; } - /* - * Push whatever the function/method needs as a this argument, if anything. - */ + // Push whatever the function/method needs as a this argument, if anything. method.CallPre(this, call); - /* - * Push the script-visible args, left-to-right. - */ + // Push the script-visible args, left-to-right. argTypes = method.GetArgTypes(); for(i = 0; i < nArgs; i++) { @@ -5368,14 +4860,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Now output call instruction. - */ + // Now output call instruction. method.CallPost(this, call); - /* - * Deal with the return value (if any), by putting it in 'result'. - */ + // Deal with the return value (if any), by putting it in 'result'. result.Pop(this, call, retType); return result; } @@ -5402,13 +4890,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private CompValu GenerateFromRValCast(TokenRValCast cast) { - /* - * If casting to a delegate type, use the argment signature - * of the delegate to help select the function/method, eg, - * '(delegate string(integer))ToString' - * will select 'string ToString(integer x)' - * instaead of 'string ToString(float x)' or anything else - */ + // If casting to a delegate type, use the argment signature + // of the delegate to help select the function/method, eg, + // '(delegate string(integer))ToString' + // will select 'string ToString(integer x)' + // instaead of 'string ToString(float x)' or anything else TokenType[] argsig = null; TokenType outType = cast.castTo; if(outType is TokenTypeSDTypeDelegate) @@ -5416,17 +4902,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine argsig = ((TokenTypeSDTypeDelegate)outType).decl.GetArgTypes(); } - /* - * Generate the value that is being cast. - * If the value is already the requested type, just use it as is. - */ + // Generate the value that is being cast. + // If the value is already the requested type, just use it as is. CompValu inRVal = GenerateFromRVal(cast.rVal, argsig); if(inRVal.type == outType) return inRVal; - /* - * Different type, generate casting code, putting the result in a temp of the output type. - */ + // Different type, generate casting code, putting the result in a temp of the output type. CompValu outRVal = new CompValuTemp(outType, this); outRVal.PopPre(this, cast); inRVal.PushVal(this, cast, outType, true); @@ -5511,10 +4993,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private CompValu GenerateFromRValList(TokenRValList rValList) { - /* - * Compute all element values and remember where we put them. - * Do it right-to-left as customary for LSL scripts. - */ + // Compute all element values and remember where we put them. + // Do it right-to-left as customary for LSL scripts. int i = 0; TokenRVal lastRVal = null; for(TokenRVal val = rValList.rVal; val != null; val = (TokenRVal)val.nextToken) @@ -5529,43 +5009,31 @@ namespace OpenSim.Region.ScriptEngine.Yengine vals[--i] = GenerateFromRVal(val); } - /* - * This is the temp that will hold the created list. - */ + // This is the temp that will hold the created list. CompValuTemp newList = new CompValuTemp(new TokenTypeList(rValList.rVal), this); - /* - * Create a temp object[] array to hold all the initial values. - */ + // Create a temp object[] array to hold all the initial values. ilGen.Emit(rValList, OpCodes.Ldc_I4, rValList.nItems); ilGen.Emit(rValList, OpCodes.Newarr, typeof(object)); - /* - * Populate the array. - */ + // Populate the array. i = 0; for(TokenRVal val = rValList.rVal; val != null; val = (TokenRVal)val.nextToken) { - /* - * Get pointer to temp array object. - */ + // Get pointer to temp array object. ilGen.Emit(rValList, OpCodes.Dup); - /* - * Get index in that array. - */ + // Get index in that array. ilGen.Emit(rValList, OpCodes.Ldc_I4, i); - /* - * Store initialization value in array location. - * However, floats and ints need to be converted to LSL_Float and LSL_Integer, - * or things like llSetPayPrice() will puque when they try to cast the elements - * to LSL_Float or LSL_Integer. Likewise with string/LSL_String. - * - * Maybe it's already LSL-boxed so we don't do anything with it except make sure - * it is an object, not a struct. - */ + // Store initialization value in array location. + // However, floats and ints need to be converted to LSL_Float and LSL_Integer, + // or things like llSetPayPrice() will puque when they try to cast the elements + // to LSL_Float or LSL_Integer. Likewise with string/LSL_String. + // + // Maybe it's already LSL-boxed so we don't do anything with it except make sure + // it is an object, not a struct. CompValu eRVal = vals[i++]; eRVal.PushVal(this, val); if(eRVal.type.ToLSLWrapType() == null) @@ -5599,9 +5067,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(val, OpCodes.Stelem, typeof(object)); } - /* - * Create new list object from temp initial value array (whose ref is still on the stack). - */ + // Create new list object from temp initial value array (whose ref is still on the stack). ilGen.Emit(rValList, OpCodes.Newobj, lslListConstructorInfo); newList.Pop(this, rValList); return newList; @@ -5717,44 +5183,31 @@ namespace OpenSim.Region.ScriptEngine.Yengine { CompValu initValue = null; - /* - * If it is a sublist, process it. - * If we don't have enough subscripts yet, hopefully that sublist will have enough. - * If we already have enough subscripts, then that sublist can be for an element of this supposedly jagged array. - */ + // If it is a sublist, process it. + // If we don't have enough subscripts yet, hopefully that sublist will have enough. + // If we already have enough subscripts, then that sublist can be for an element of this supposedly jagged array. if(val is TokenList) { TokenList sublist = (TokenList)val; if(dimNo + 1 < rank) { - - /* - * We don't have enough subscripts yet, hopefully the sublist has the rest. - */ + // We don't have enough subscripts yet, hopefully the sublist has the rest. FillInInitVals(array, setMeth, subscripts, dimNo + 1, rank, sublist, eleType); } else if((eleType is TokenTypeSDTypeClass) && (((TokenTypeSDTypeClass)eleType).decl.arrayOfType == null)) { - - /* - * If we aren't a jagged array either, we can't do anything with the sublist. - */ + // If we aren't a jagged array either, we can't do anything with the sublist. ErrorMsg(val, "too many brace levels"); } else { - - /* - * We are a jagged array, so malloc a subarray and initialize it with the sublist. - * Then we can use that subarray to fill this array's element. - */ + // We are a jagged array, so malloc a subarray and initialize it with the sublist. + // Then we can use that subarray to fill this array's element. initValue = MallocAndInitArray(eleType, sublist); } } - /* - * If it is a value expression, then output code to compute the value. - */ + // If it is a value expression, then output code to compute the value. if(val is TokenRVal) { if(dimNo + 1 < rank) @@ -5767,9 +5220,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If there is an initValue, output "array.Set (subscript[0], subscript[1], ..., initValue)" - */ + // If there is an initValue, output "array.Set (subscript[0], subscript[1], ..., initValue)" if(initValue != null) { array.PushVal(this, val); @@ -5781,9 +5232,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine ilGen.Emit(val, OpCodes.Call, setMeth.ilGen); } - /* - * That subscript is processed one way or another, on to the next. - */ + // That subscript is processed one way or another, on to the next. subscripts[dimNo]++; } } @@ -5894,19 +5343,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new CompValuVoid(type); } - /* - * Default for 'object' type is 'undef'. - * Likewise for script-defined classes and interfaces. - */ + // Default for 'object' type is 'undef'. + // Likewise for script-defined classes and interfaces. if((type is TokenTypeObject) || (type is TokenTypeSDTypeClass) || (type is TokenTypeSDTypeDelegate) || (type is TokenTypeSDTypeInterface) || (type is TokenTypeExc)) { return new CompValuNull(type); } - /* - * array and list - */ + // array and list CompValuTemp temp = new CompValuTemp(type, this); PushDefaultValue(type); temp.Pop(this, rValInitDef, type); @@ -5918,14 +5363,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private CompValu GenerateFromRValIsType(TokenRValIsType rValIsType) { - /* - * Expression we want to know the type of. - */ + // Expression we want to know the type of. CompValu val = GenerateFromRVal(rValIsType.rValExp); - /* - * Pass it in to top-level type expression decoder. - */ + // Pass it in to top-level type expression decoder. return GenerateFromTypeExp(val, rValIsType.typeExp); } @@ -6062,28 +5503,22 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Default for 'object' type is 'undef'. - * Likewise for script-defined classes and interfaces. - */ + // Default for 'object' type is 'undef'. + // Likewise for script-defined classes and interfaces. if((type is TokenTypeObject) || (type is TokenTypeSDTypeClass) || (type is TokenTypeSDTypeInterface) || (type is TokenTypeExc)) { ilGen.Emit(type, OpCodes.Ldnull); return; } - /* - * Void is pushed as the default return value of a void function. - * So just push nothing as expected of void functions. - */ + // Void is pushed as the default return value of a void function. + // So just push nothing as expected of void functions. if(type is TokenTypeVoid) { return; } - /* - * Default for 'delegate' type is 'undef'. - */ + // Default for 'delegate' type is 'undef'. if(type is TokenTypeSDTypeDelegate) { ilGen.Emit(type, OpCodes.Ldnull); @@ -6186,16 +5621,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private static VarDict CreateLegalEventHandlers() { - /* - * Get handler prototypes with full argument lists. - */ + // Get handler prototypes with full argument lists. VarDict leh = new InternalFuncDict(typeof(IEventHandlers), false); - /* - * We want the scripts to be able to declare their handlers with - * fewer arguments than the full argument lists. So define additional - * prototypes with fewer arguments. - */ + // We want the scripts to be able to declare their handlers with + // fewer arguments than the full argument lists. So define additional + // prototypes with fewer arguments. TokenDeclVar[] fullArgProtos = new TokenDeclVar[leh.Count]; int i = 0; foreach(TokenDeclVar fap in leh) @@ -6283,9 +5714,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private CompValu UnOpGenerate(CompValu inRVal, Token opcode) { - /* - * - Negate - */ + // - Negate if(opcode is TokenKwSub) { if(inRVal.type is TokenTypeFloat) @@ -6324,9 +5753,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return inRVal; } - /* - * ~ Complement (bitwise integer) - */ + // ~ Complement (bitwise integer) if(opcode is TokenKwTilde) { if(inRVal.type is TokenTypeInt) @@ -6341,13 +5768,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine return inRVal; } - /* - * ! Not (boolean) - * - * We stuff the 0/1 result in an int because I've seen x+!y in scripts - * and we don't want to have to create tables to handle int+bool and - * everything like that. - */ + // ! Not (boolean) + // + // We stuff the 0/1 result in an int because I've seen x+!y in scripts + // and we don't want to have to create tables to handle int+bool and + // everything like that. if(opcode is TokenKwExclam) { CompValuTemp outRVal = new CompValuTemp(new TokenTypeInt(opcode), this); @@ -6367,9 +5792,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenRVal LookupInitConstants(TokenRVal rVal, ref bool didOne) { - /* - * If it is a static field of a script-defined type, look it up and hopefully we find a constant there. - */ + // If it is a static field of a script-defined type, look it up and hopefully we find a constant there. TokenDeclVar gblVar; if(rVal is TokenLValSField) { @@ -6390,17 +5813,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return rVal; } - /* - * Only other thing we handle is stand-alone names. - */ + // Only other thing we handle is stand-alone names. if(!(rVal is TokenLValName)) return rVal; string name = ((TokenLValName)rVal).name.val; - /* - * If we are doing the initializations for a script-defined type, - * look for the constant among the fields for that type. - */ + // If we are doing the initializations for a script-defined type, + // look for the constant among the fields for that type. if(currentSDTClass != null) { gblVar = currentSDTClass.members.FindExact(name, null); @@ -6415,11 +5834,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Look it up as a script-defined global variable. - * Then if the variable is defined as a constant and has a constant value, - * we are successful. If it is defined as something else, return failure. - */ + // Look it up as a script-defined global variable. + // Then if the variable is defined as a constant and has a constant value, + // we are successful. If it is defined as something else, return failure. gblVar = tokenScript.variablesStack.FindExact(name, null); if(gblVar != null) { @@ -6431,9 +5848,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return rVal; } - /* - * Maybe it is a built-in symbolic constant. - */ + // Maybe it is a built-in symbolic constant. ScriptConst scriptConst = ScriptConst.Lookup(name); if(scriptConst != null) { @@ -6445,9 +5860,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Don't know what it is, return failure. - */ + // Don't know what it is, return failure. return rVal; } @@ -6457,9 +5870,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenRVal LookupBodyConstants(TokenRVal rVal, ref bool didOne) { - /* - * If it is a static field of a script-defined type, look it up and hopefully we find a constant there. - */ + // If it is a static field of a script-defined type, look it up and hopefully we find a constant there. TokenDeclVar gblVar; if(rVal is TokenLValSField) { @@ -6477,17 +5888,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return rVal; } - /* - * Only other thing we handle is stand-alone names. - */ + // Only other thing we handle is stand-alone names. if(!(rVal is TokenLValName)) return rVal; string name = ((TokenLValName)rVal).name.val; - /* - * Scan through the variable stack and hopefully we find a constant there. - * But we stop as soon as we get a match because that's what the script is referring to. - */ + // Scan through the variable stack and hopefully we find a constant there. + // But we stop as soon as we get a match because that's what the script is referring to. CompValu val; for(VarDict vars = ((TokenLValName)rVal).stack; vars != null; vars = vars.outerVarDict) { @@ -6513,9 +5920,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Maybe it is a built-in symbolic constant. - */ + // Maybe it is a built-in symbolic constant. ScriptConst scriptConst = ScriptConst.Lookup(name); if(scriptConst != null) { @@ -6523,15 +5928,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine goto foundit; } - /* - * Don't know what it is, return failure. - */ + // Don't know what it is, return failure. return rVal; - /* - * Found a CompValu. If it's a simple constant, then use it. - * Otherwise tell caller we failed to simplify. - */ + // Found a CompValu. If it's a simple constant, then use it. + // Otherwise tell caller we failed to simplify. foundit: rVal = CompValuConst2RValConst(val, rVal); if(rVal is TokenRValConst) @@ -6586,9 +5987,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public TokenDeclVar FindNamedVar(TokenLValName lValName, TokenType[] argsig) { - /* - * Look in variable stack for the given name. - */ + // Look in variable stack for the given name. for(VarDict vars = lValName.stack; vars != null; vars = vars.outerVarDict) { @@ -6627,9 +6026,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If not found, try one of the built-in constants or functions. - */ + // If not found, try one of the built-in constants or functions. if(argsig == null) { ScriptConst scriptConst = ScriptConst.Lookup(lValName.name.val); @@ -6670,31 +6067,28 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenDeclVar declVar = sdtDecl.FindIFaceMember(this, name, argsig, out impl); if((declVar != null) && (impl != sdtDecl)) { - - /* - * Accessing a method or propterty of another interface that the primary interface says it implements. - * In this case, we have to cast from the primary interface to that secondary interface. - * - * interface IEnumerable { - * IEnumerator GetEnumerator (); - * } - * interface ICountable : IEnumerable { - * integer GetCount (); - * } - * class List : ICountable { - * public GetCount () : ICountable { ... } - * public GetEnumerator () : IEnumerable { ... } - * } - * - * ICountable aList = new List (); - * IEnumerator anEnumer = aList.GetEnumerator (); << we are here - * << baseRVal = aList - * << sdtDecl = ICountable - * << impl = IEnumerable - * << name = GetEnumerator - * << argsig = () - * So we have to cast aList from ICountable to IEnumerable. - */ + // Accessing a method or propterty of another interface that the primary interface says it implements. + // In this case, we have to cast from the primary interface to that secondary interface. + // + // interface IEnumerable { + // IEnumerator GetEnumerator (); + // } + // interface ICountable : IEnumerable { + // integer GetCount (); + // } + // class List : ICountable { + // public GetCount () : ICountable { ... } + // public GetEnumerator () : IEnumerable { ... } + // } + // + // ICountable aList = new List (); + // IEnumerator anEnumer = aList.GetEnumerator (); << we are here + // << baseRVal = aList + // << sdtDecl = ICountable + // << impl = IEnumerable + // << name = GetEnumerator + // << argsig = () + // So we have to cast aList from ICountable to IEnumerable. // make type token for the secondary interface type TokenType subIntfType = impl.MakeRefToken(name); @@ -6799,19 +6193,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenDeclSDType definedBy = var.sdtClass; TokenDeclSDType accessedBy = curDeclFunc.sdtClass; - /*******************************\ - * Check member-level access * - \*******************************/ + //******************************* + // Check member-level access + //******************************* - /* - * Note that if accessedBy is null, ie, accessing from global function (or event handlers), - * anything tagged as SDT_PRIVATE or SDT_PROTECTED will fail. - */ + // Note that if accessedBy is null, ie, accessing from global function (or event handlers), + // anything tagged as SDT_PRIVATE or SDT_PROTECTED will fail. - /* - * Private means accessed by the class that defined the member or accessed by a nested class - * of the class that defined the member. - */ + // Private means accessed by the class that defined the member or accessed by a nested class + // of the class that defined the member. if((var.sdtFlags & ScriptReduce.SDT_PRIVATE) != 0) { for(nested = accessedBy; nested != null; nested = nested.outerSDType) @@ -6823,12 +6213,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Protected means: - * If being accessed by an inner class, the inner class has access to it if the inner class derives - * from the declaring class. It also has access to it if an outer class derives from the declaring - * class. - */ + // Protected means: + // If being accessed by an inner class, the inner class has access to it if the inner class derives + // from the declaring class. It also has access to it if an outer class derives from the declaring + // class. if((var.sdtFlags & ScriptReduce.SDT_PROTECTED) != 0) { for(nested = accessedBy; nested != null; nested = nested.outerSDType) @@ -6844,26 +6232,24 @@ namespace OpenSim.Region.ScriptEngine.Yengine } acc1ok: - /******************************\ - * Check class-level access * - \******************************/ + //****************************** + // Check class-level access + //****************************** - /* - * If being accessed by same or inner class than where defined, it is ok. - * - * class DefiningClass { - * varBeingAccessed; - * . - * . - * . - * class AccessingClass { - * functionDoingAccess() { } - * } - * . - * . - * . - * } - */ + // If being accessed by same or inner class than where defined, it is ok. + // + // class DefiningClass { + // varBeingAccessed; + // . + // . + // . + // class AccessingClass { + // functionDoingAccess() { } + // } + // . + // . + // . + // } nested = accessedBy; while(true) { @@ -6874,46 +6260,39 @@ namespace OpenSim.Region.ScriptEngine.Yengine nested = (TokenDeclSDTypeClass)nested.outerSDType; } - /* - * It is being accessed by an outer class than where defined, - * check for a 'private' or 'protected' class tag that blocks. - */ + // It is being accessed by an outer class than where defined, + // check for a 'private' or 'protected' class tag that blocks. do { - - /* - * If the field's class is defined directly inside the accessing class, - * access is allowed regardless of class-level private or protected tags. - * - * class AccessingClass { - * functionDoingAccess() { } - * class DefiningClass { - * varBeingAccessed; - * } - * } - */ + // If the field's class is defined directly inside the accessing class, + // access is allowed regardless of class-level private or protected tags. + // + // class AccessingClass { + // functionDoingAccess() { } + // class DefiningClass { + // varBeingAccessed; + // } + // } if(definedBy.outerSDType == accessedBy) return; - /* - * If the field's class is defined two or more levels inside the accessing class, - * access is denied if the defining class is tagged private. - * - * class AccessingClass { - * functionDoingAccess() { } - * . - * . - * . - * class IntermediateClass { - * private class DefiningClass { - * varBeingAccessed; - * } - * } - * . - * . - * . - * } - */ + // If the field's class is defined two or more levels inside the accessing class, + // access is denied if the defining class is tagged private. + // + // class AccessingClass { + // functionDoingAccess() { } + // . + // . + // . + // class IntermediateClass { + // private class DefiningClass { + // varBeingAccessed; + // } + // } + // . + // . + // . + // } if((definedBy.accessLevel & ScriptReduce.SDT_PRIVATE) != 0) { ErrorMsg(errorAt, "member " + var.fullName + " cannot be accessed by " + curDeclFunc.fullName + @@ -6921,10 +6300,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Likewise, if DefiningClass is tagged protected, the AccessingClass must derive from the - * IntermediateClass or access is denied. - */ + // Likewise, if DefiningClass is tagged protected, the AccessingClass must derive from the + // IntermediateClass or access is denied. if((definedBy.accessLevel & ScriptReduce.SDT_PROTECTED) != 0) { for(TokenDeclSDType extends = accessedBy; extends != definedBy.outerSDType; extends = extends.extends) @@ -6938,9 +6315,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Check next outer level. - */ + // Check next outer level. definedBy = definedBy.outerSDType; } while(definedBy != null); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCollector.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCollector.cs index 4a57823bca..88cd6c13c9 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCollector.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCollector.cs @@ -511,20 +511,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine } public override bool MoveNext() { - /* - * First off, return any targets the instruction can come up with. - */ + // First off, return any targets the instruction can come up with. if(realEnumerator.MoveNext()) { nn = realEnumerator.Current; return true; } - /* - * Then if this instruction is in a try section, say this instruction - * can potentially branch to the beginning of the corresponding - * catch/finally. - */ + // Then if this instruction is in a try section, say this instruction + // can potentially branch to the beginning of the corresponding + // catch/finally. if((index == 0) && (gn.tryBlock != null)) { index++; @@ -532,9 +528,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return true; } - /* - * That's all we can do. - */ + // That's all we can do. nn = null; return false; } @@ -1875,9 +1869,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } public override bool MoveNext() { - /* - * Return next from list of switch case labels. - */ + // Return next from list of switch case labels. while(index < gn.myLabels.Length) { nn = gn.myLabels[index++].whereAmI; @@ -1885,9 +1877,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return true; } - /* - * If all ran out, the switch instruction falls through. - */ + // If all ran out, the switch instruction falls through. if(index == gn.myLabels.Length) { index++; @@ -1895,9 +1885,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return true; } - /* - * Even ran out of that, say there's nothing more. - */ + // Even ran out of that, say there's nothing more. nn = null; return false; } @@ -2527,10 +2515,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(curExcBlock != null) throw new Exception("exception block still open"); - /* - * If an instruction says it doesn't fall through, remove all instructions to - * the end of the block. - */ + // If an instruction says it doesn't fall through, remove all instructions to + // the end of the block. for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if(!gn.CanFallThrough()) @@ -2547,12 +2533,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Scan for OpCodes.Leave instructions. - * For each found, its target for flow analysis purposes is the beginning of the corresponding - * finally block. And the end of the finally block gets a conditional branch target of the - * leave instruction's target. A leave instruction can unwind zero or more finally blocks. - */ + // Scan for OpCodes.Leave instructions. + // For each found, its target for flow analysis purposes is the beginning of the corresponding + // finally block. And the end of the finally block gets a conditional branch target of the + // leave instruction's target. A leave instruction can unwind zero or more finally blocks. for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if(gn is GraphNodeEmitLabelLeave) @@ -2562,12 +2546,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine GraphNodeBeginExceptionBlock leaveTargetsTryBlock = // try block directly enclosing leave target (leaveTarget == null) ? null : leaveTarget.tryBlock; // ...it must not be unwound - /* - * Step through try { }s from the leave instruction towards its target looking for try { }s with finally { }s. - * The leave instruction unconditionally branches to the beginning of the innermost one found. - * The end of the last one found conditionally branches to the leave instruction's target. - * If none found, the leave is a simple unconditional branch to its target. - */ + // Step through try { }s from the leave instruction towards its target looking for try { }s with finally { }s. + // The leave instruction unconditionally branches to the beginning of the innermost one found. + // The end of the last one found conditionally branches to the leave instruction's target. + // If none found, the leave is a simple unconditional branch to its target. GraphNodeBeginFinallyBlock innerFinallyBlock = null; for(GraphNodeBeginExceptionBlock tryBlock = leaveInstr.tryBlock; tryBlock != leaveTargetsTryBlock; @@ -2586,10 +2568,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * The end of the outermost finally being unwound can conditionally jump to the target of the leave instruction. - * In the case of no finallies being unwound, the leave is just a simple unconditional branch. - */ + // The end of the outermost finally being unwound can conditionally jump to the target of the leave instruction. + // In the case of no finallies being unwound, the leave is just a simple unconditional branch. if(innerFinallyBlock == null) { leaveInstr.unwindTo = leaveTarget; @@ -2601,10 +2581,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * See which variables a particular block reads before writing. - * This just considers the block itself and nothing that it branches to or fallsthru to. - */ + // See which variables a particular block reads before writing. + // This just considers the block itself and nothing that it branches to or fallsthru to. GraphNodeBlock currentBlock = null; for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { @@ -2626,13 +2604,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * For every block we branch to, add that blocks readables to our list of readables, - * because we need to have those values valid on entry to our block. But if we write the - * variable before we can possibly branch to that block, then we don't need to have it valid - * on entry to our block. So basically it looks like the branch instruction is reading - * everything required by any blocks it can branch to. - */ + // For every block we branch to, add that blocks readables to our list of readables, + // because we need to have those values valid on entry to our block. But if we write the + // variable before we can possibly branch to that block, then we don't need to have it valid + // on entry to our block. So basically it looks like the branch instruction is reading + // everything required by any blocks it can branch to. do { this.resolvedSomething = false; @@ -2640,17 +2616,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine this.ResolveBlock((GraphNodeBlock)firstLin); } while(this.resolvedSomething); - /* - * Repeat the cutting loops as long as we keep finding stuff. - */ + // Repeat the cutting loops as long as we keep finding stuff. bool didSomething; do { didSomething = false; - /* - * Strip out ldc.i4.1/xor/ldc.i4.1/xor - */ + // Strip out ldc.i4.1/xor/ldc.i4.1/xor for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if(!(gn is GraphNodeEmit)) @@ -2678,9 +2650,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine didSomething = true; } - /* - * Replace c{cond}/ldc.i4.1/xor/br{false,true} -> c{cond}/br{true,false} - */ + // Replace c{cond}/ldc.i4.1/xor/br{false,true} -> c{cond}/br{true,false} for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if(!(gn is GraphNodeEmit)) @@ -2711,9 +2681,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine didSomething = true; } - /* - * Replace c{cond}/br{false,true} -> b{!,}{cond} - */ + // Replace c{cond}/br{false,true} -> b{!,}{cond} for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if(!(gn is GraphNodeEmit)) @@ -2746,9 +2714,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine didSomething = true; } - /* - * Replace ld{c.i4.0,null}/br{ne.un,eq} -> br{true,false} - */ + // Replace ld{c.i4.0,null}/br{ne.un,eq} -> br{true,false} for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if(!(gn is GraphNodeEmit)) @@ -2767,17 +2733,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine didSomething = true; } - /* - * Replace: - * ldloc v1 - * stloc v2 - * ld except ld v2 - * ldloc v2 - * ...v2 unreferenced hereafter - * With: - * ld except ld v2 - * ldloc v1 - */ + // Replace: + // ldloc v1 + // stloc v2 + // ld except ld v2 + // ldloc v2 + // ...v2 unreferenced hereafter + // With: + // ld except ld v2 + // ldloc v1 for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { @@ -2833,11 +2797,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine didSomething = true; } - /* - * Remove all the stloc/ldloc that are back-to-back without the local - * being needed afterwards. If it is needed afterwards, replace the - * stloc/ldloc with dup/stloc. - */ + // Remove all the stloc/ldloc that are back-to-back without the local + // being needed afterwards. If it is needed afterwards, replace the + // stloc/ldloc with dup/stloc. for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if((gn is GraphNodeEmitLocal) && @@ -2871,10 +2833,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Remove all write-only local variables, ie, those with no ldloc[a] references. - * Replace any stloc instructions with pops. - */ + // Remove all write-only local variables, ie, those with no ldloc[a] references. + // Replace any stloc instructions with pops. for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { ScriptMyLocal rdlcl = gn.ReadsLocal(); @@ -2900,9 +2860,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Remove any Ld/Dup,Pop. - */ + // Remove any Ld/Dup,Pop. for(GraphNode gn = firstLin; gn != null; gn = gn.nextLin) { if((gn is GraphNodeEmit) && @@ -2921,9 +2879,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } while(didSomething); - /* - * Dump out the results. - */ + // Dump out the results. if(DEBUG) { Console.WriteLine(""); @@ -2982,55 +2938,39 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(currentBlock.hasBeenResolved == this.resolveSequence) return; - /* - * So we don't recurse forever on a backward branch. - */ + // So we don't recurse forever on a backward branch. currentBlock.hasBeenResolved = this.resolveSequence; - /* - * Assume we haven't written any locals yet. - */ + // Assume we haven't written any locals yet. List localsWrittenSoFar = new List(); - /* - * Scan through the instructions in this block. - */ + // Scan through the instructions in this block. for(GraphNode gn = currentBlock; gn != null;) { - /* - * See if the instruction writes a local we don't know about yet. - */ + // See if the instruction writes a local we don't know about yet. ScriptMyLocal wrlcl = gn.WritesLocal(); if((wrlcl != null) && !localsWrittenSoFar.Contains(wrlcl)) { localsWrittenSoFar.Add(wrlcl); } - /* - * Scan through all the possible next instructions after this. - * Note that if we are in the first part of a try/catch/finally block, - * every instruction conditionally branches to the beginning of the - * second part (the catch/finally block). - */ + // Scan through all the possible next instructions after this. + // Note that if we are in the first part of a try/catch/finally block, + // every instruction conditionally branches to the beginning of the + // second part (the catch/finally block). GraphNode nextFallthruNode = null; foreach(GraphNode nn in gn.NextNodes) { if(nn is GraphNodeBlock) { - - /* - * Start of a block, go through all locals needed by that block on entry. - */ + // Start of a block, go through all locals needed by that block on entry. GraphNodeBlock nextBlock = (GraphNodeBlock)nn; ResolveBlock(nextBlock); foreach(ScriptMyLocal readByNextBlock in nextBlock.localsReadBeforeWritten) { - - /* - * If this block hasn't written it by now and this block doesn't already - * require it on entry, say this block requires it on entry. - */ + // If this block hasn't written it by now and this block doesn't already + // require it on entry, say this block requires it on entry. if(!localsWrittenSoFar.Contains(readByNextBlock) && !currentBlock.localsReadBeforeWritten.Contains(readByNextBlock)) { @@ -3041,19 +2981,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine } else { - - /* - * Not start of a block, should be normal fallthru instruction. - */ + // Not start of a block, should be normal fallthru instruction. if(nextFallthruNode != null) throw new Exception("more than one fallthru from " + gn.ToString()); nextFallthruNode = nn; } } - /* - * Process next instruction if it isn't the start of a block. - */ + // Process next instruction if it isn't the start of a block. if(nextFallthruNode == gn) throw new Exception("can't fallthru to self"); gn = nextFallthruNode; diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompValu.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompValu.cs index 17bc3eccdb..675ab9ae25 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompValu.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptCompValu.cs @@ -107,8 +107,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine return (type.ToLSLWrapType() != null) ? type.ToLSLWrapType() : type.ToSysType(); } - // if a field of an XMRInstArrays array cannot be directly written, - // get the method that can write it + /* + * if a field of an XMRInstArrays array cannot be directly written, + * get the method that can write it + */ private static MethodInfo ArrVarPopMeth(FieldInfo fi) { if(fi.Name == "iarLists") @@ -120,7 +122,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine return null; } - // emit code to push value onto stack + /* + * emit code to push value onto stack + */ public void PushVal(ScriptCodeGen scg, Token errorAt, TokenType stackType) { this.PushVal(scg, errorAt, stackType, false); @@ -133,7 +137,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine public abstract void PushVal(ScriptCodeGen scg, Token errorAt); public abstract void PushRef(ScriptCodeGen scg, Token errorAt); - // emit code to pop value from stack + /* + * emit code to pop value from stack + */ public void PopPost(ScriptCodeGen scg, Token errorAt, TokenType stackType) { TypeCast.CastTopOfStack(scg, errorAt, stackType, this.type, false); @@ -141,11 +147,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine } public virtual void PopPre(ScriptCodeGen scg, Token errorAt) { - } // call this before pushing value to be popped + } + + /* + * call this before pushing value to be popped + */ public abstract void PopPost(ScriptCodeGen scg, Token errorAt); // call this after pushing value to be popped - // return true: doing a PushVal() does not involve CheckRun() - // false: otherwise + + /* + * return true: doing a PushVal() does not involve CheckRun() + * false: otherwise + */ public virtual bool IsReadTrivial(ScriptCodeGen scg, Token readAt) { return true; @@ -173,12 +186,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine return ((TokenTypeSDTypeDelegate)type).decl.GetArgSig(); } - // These are used only if type is a delegate too - // - but it is a real delegate pointer in a global or local variable or a field, etc - // ie, PushVal() pushes a delegate pointer - // - so we must have CallPre() push the delegate pointer as a 'this' for this.Invoke(...) - // - and CallPost() call the delegate's Invoke() method - // - we assume the target function is non-trivial so we always use a call label + /* + * These are used only if type is a delegate too + * - but it is a real delegate pointer in a global or local variable or a field, etc + * - ie, PushVal() pushes a delegate pointer + * - so we must have CallPre() push the delegate pointer as a 'this' for this.Invoke(...) + * - and CallPost() call the delegate's Invoke() method + * - we assume the target function is non-trivial so we always use a call label + */ public virtual void CallPre(ScriptCodeGen scg, Token errorAt) // call this before pushing arguments { new ScriptCodeGen.CallLabel(scg, errorAt); diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs index 63a6ee93b2..b44c4e2dee 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptConsts.cs @@ -64,9 +64,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { Dictionary sc = new Dictionary(); - /* - * For every event code, define XMREVENTCODE_ and XMREVENTMASKn_ symbols. - */ + // For every event code, define XMREVENTCODE_ and XMREVENTMASKn_ symbols. for(int i = 0; i < 64; i++) { try @@ -87,9 +85,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine catch { } } - /* - * Also get all the constants from XMRInstAbstract and ScriptBaseClass etc as well. - */ + // Also get all the constants from XMRInstAbstract and ScriptBaseClass etc as well. for(Type t = typeof(XMRInstAbstract); t != typeof(object); t = t.BaseType) { AddInterfaceConstants(sc, t.GetFields()); @@ -132,10 +128,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine Type fieldType = constField.FieldType; CompValu cv; - /* - * The location of a simple number is the number itself. - * Access to the value gets compiled as an ldc instruction. - */ + // The location of a simple number is the number itself. + // Access to the value gets compiled as an ldc instruction. if(fieldType == typeof(double)) { cv = new CompValuFloat(new TokenTypeFloat(null), @@ -152,10 +146,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine ((LSL_Integer)constField.GetValue(null)).value); } - /* - * The location of a string is the string itself. - * Access to the value gets compiled as an ldstr instruction. - */ + // The location of a string is the string itself. + // Access to the value gets compiled as an ldstr instruction. else if(fieldType == typeof(string)) { cv = new CompValuString(new TokenTypeStr(null), @@ -167,18 +159,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine (string)(LSL_String)constField.GetValue(null)); } - /* - * The location of everything else (objects) is the static field in the interface definition. - * Access to the value gets compiled as an ldsfld instruction. - */ + // The location of everything else (objects) is the static field in the interface definition. + // Access to the value gets compiled as an ldsfld instruction. else { cv = new CompValuSField(TokenType.FromSysType(null, fieldType), constField); } - /* - * Add to dictionary. - */ + // Add to dictionary. new ScriptConst(sc, constField.Name, cv); } } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs index d5b08f078f..24d7c3d232 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjCode.cs @@ -87,9 +87,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public ScriptObjCode(BinaryReader objFileReader, TextWriter asmFileWriter, TextWriter srcFileWriter) { - /* - * Check version number to make sure we know how to process file contents. - */ + // Check version number to make sure we know how to process file contents. char[] ocm = objFileReader.ReadChars(ScriptCodeGen.OBJECT_CODE_MAGIC.Length); if(new String(ocm) != ScriptCodeGen.OBJECT_CODE_MAGIC) throw new Exception("not an XMR object file (bad magic)"); @@ -206,14 +204,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public void EndMethod(DynamicMethod method, Dictionary srcLocs) { - /* - * Save method object code pointer. - */ + // Save method object code pointer. dynamicMethods.Add(method.Name, method); - /* - * Build and sort iloffset -> source code location array. - */ + // Build and sort iloffset -> source code location array. int n = srcLocs.Count; KeyValuePair[] srcLocArray = new KeyValuePair[n]; n = 0; @@ -221,9 +215,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine srcLocArray[n++] = kvp; Array.Sort(srcLocArray, endMethodWrapper); - /* - * Save sorted array. - */ + // Save sorted array. scriptSrcLocss.Add(method.Name, srcLocArray); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs index b87bc7276c..6ab0bb5763 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptObjWriter.cs @@ -121,9 +121,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine this.argTypes = argTypes; this.objFileWriter = objFileWriter; - /* - * Build list that translates system-defined types to script defined types. - */ + // Build list that translates system-defined types to script defined types. foreach(TokenDeclSDType sdt in tokenScript.sdSrcTypesValues) { Type sys = sdt.GetSysType(); @@ -131,11 +129,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine sdTypesRev[sys] = sdt.longName.val; } - /* - * This tells the reader to call 'new DynamicMethod()' to create - * the function header. Then any forward reference calls to this - * method will have a MethodInfo struct to call. - */ + // This tells the reader to call 'new DynamicMethod()' to create + // the function header. Then any forward reference calls to this + // method will have a MethodInfo struct to call. objFileWriter.Write((byte)ScriptObjWriterCode.DclMethod); objFileWriter.Write(methName); objFileWriter.Write(GetStrFromType(retType)); @@ -154,10 +150,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public void BegMethod() { - /* - * This tells the reader to call methodInfo.GetILGenerator() - * so it can start writing CIL code for the method. - */ + // This tells the reader to call methodInfo.GetILGenerator() + // so it can start writing CIL code for the method. objFileWriter.Write((byte)ScriptObjWriterCode.BegMethod); objFileWriter.Write(methName); } @@ -167,11 +161,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public void EndMethod() { - /* - * This tells the reader that all code for the method has - * been written and so it will typically call CreateDelegate() - * to finalize the method and create an entrypoint. - */ + // This tells the reader that all code for the method has + // been written and so it will typically call CreateDelegate() + // to finalize the method and create an entrypoint. objFileWriter.Write((byte)ScriptObjWriterCode.EndMethod); objFileWriter = null; @@ -404,431 +396,385 @@ namespace OpenSim.Region.ScriptEngine.Yengine while(true) { - - /* - * Get IL instruction offset at beginning of instruction. - */ + // Get IL instruction offset at beginning of instruction. offset = 0; if((ilGen != null) && (monoGetCurrentOffset != null)) { offset = (int)monoGetCurrentOffset.Invoke(null, ilGenArg); } - /* - * Read and decode next internal format code from input file (.xmrobj file). - */ + // Read and decode next internal format code from input file (.xmrobj file). ScriptObjWriterCode code = (ScriptObjWriterCode)objReader.ReadByte(); switch(code) { - - /* - * Reached end-of-file so we are all done. - */ + // Reached end-of-file so we are all done. case ScriptObjWriterCode.TheEnd: - { - return; - } + return; - /* - * Beginning of method's contents. - * Method must have already been declared via DclMethod - * so all we need is its name to retrieve from methods[]. - */ + // Beginning of method's contents. + // Method must have already been declared via DclMethod + // so all we need is its name to retrieve from methods[]. case ScriptObjWriterCode.BegMethod: - { - string methName = objReader.ReadString(); + { + string methName = objReader.ReadString(); - method = methods[methName]; - ilGen = method.GetILGenerator(); - ilGenArg[0] = ilGen; + method = methods[methName]; + ilGen = method.GetILGenerator(); + ilGenArg[0] = ilGen; - labels.Clear(); - locals.Clear(); - labelNames.Clear(); - localNames.Clear(); + labels.Clear(); + locals.Clear(); + labelNames.Clear(); + localNames.Clear(); - srcLocs = new Dictionary(); - if(objectTokens != null) - objectTokens.BegMethod(method); - break; - } + srcLocs = new Dictionary(); + if(objectTokens != null) + objectTokens.BegMethod(method); + break; + } - /* - * End of method's contents (ie, an OpCodes.Ret was probably just output). - * Call the callback to tell it the method is complete, and it can do whatever - * it wants with the method. - */ + // End of method's contents (ie, an OpCodes.Ret was probably just output). + // Call the callback to tell it the method is complete, and it can do whatever + // it wants with the method. case ScriptObjWriterCode.EndMethod: - { - ilGen = null; - ilGenArg[0] = null; - scriptObjCode.EndMethod(method, srcLocs); - srcLocs = null; - if(objectTokens != null) - objectTokens.EndMethod(); - break; - } + { + ilGen = null; + ilGenArg[0] = null; + scriptObjCode.EndMethod(method, srcLocs); + srcLocs = null; + if(objectTokens != null) + objectTokens.EndMethod(); + break; + } - /* - * Declare a label for branching to. - */ + // Declare a label for branching to. case ScriptObjWriterCode.DclLabel: - { - int number = objReader.ReadInt32(); - string name = objReader.ReadString(); + { + int number = objReader.ReadInt32(); + string name = objReader.ReadString(); - labels.Add(number, ilGen.DefineLabel()); - labelNames.Add(number, name + "_" + number.ToString()); - if(objectTokens != null) - objectTokens.DefineLabel(number, name); - break; - } + labels.Add(number, ilGen.DefineLabel()); + labelNames.Add(number, name + "_" + number.ToString()); + if(objectTokens != null) + objectTokens.DefineLabel(number, name); + break; + } - /* - * Declare a local variable to store into. - */ + // Declare a local variable to store into. case ScriptObjWriterCode.DclLocal: - { - int number = objReader.ReadInt32(); - string name = objReader.ReadString(); - string type = objReader.ReadString(); - Type syType = GetTypeFromStr(sdTypes, type); + { + int number = objReader.ReadInt32(); + string name = objReader.ReadString(); + string type = objReader.ReadString(); + Type syType = GetTypeFromStr(sdTypes, type); - locals.Add(number, ilGen.DeclareLocal(syType)); - localNames.Add(number, name + "_" + number.ToString()); - if(objectTokens != null) - objectTokens.DefineLocal(number, name, type, syType); - break; - } + locals.Add(number, ilGen.DeclareLocal(syType)); + localNames.Add(number, name + "_" + number.ToString()); + if(objectTokens != null) + objectTokens.DefineLocal(number, name, type, syType); + break; + } - /* - * Declare a method that will subsequently be defined. - * We create the DynamicMethod object at this point in case there - * are forward references from other method bodies. - */ + // Declare a method that will subsequently be defined. + // We create the DynamicMethod object at this point in case there + // are forward references from other method bodies. case ScriptObjWriterCode.DclMethod: + { + string methName = objReader.ReadString(); + Type retType = GetTypeFromStr(sdTypes, objReader.ReadString()); + int nArgs = objReader.ReadInt32(); + + Type[] argTypes = new Type[nArgs]; + string[] argNames = new string[nArgs]; + for(int i = 0; i < nArgs; i++) { - string methName = objReader.ReadString(); - Type retType = GetTypeFromStr(sdTypes, objReader.ReadString()); - int nArgs = objReader.ReadInt32(); - - Type[] argTypes = new Type[nArgs]; - string[] argNames = new string[nArgs]; - for(int i = 0; i < nArgs; i++) - { - argTypes[i] = GetTypeFromStr(sdTypes, objReader.ReadString()); - argNames[i] = objReader.ReadString(); - } - methods.Add(methName, new DynamicMethod(methName, retType, argTypes)); - if(objectTokens != null) - objectTokens.DefineMethod(methName, retType, argTypes, argNames); - break; + argTypes[i] = GetTypeFromStr(sdTypes, objReader.ReadString()); + argNames[i] = objReader.ReadString(); } + methods.Add(methName, new DynamicMethod(methName, retType, argTypes)); + if(objectTokens != null) + objectTokens.DefineMethod(methName, retType, argTypes, argNames); + break; + } - /* - * Mark a previously declared label at this spot. - */ + // Mark a previously declared label at this spot. case ScriptObjWriterCode.MarkLabel: - { - int number = objReader.ReadInt32(); + { + int number = objReader.ReadInt32(); - ilGen.MarkLabel(labels[number]); + ilGen.MarkLabel(labels[number]); - if(objectTokens != null) - objectTokens.MarkLabel(offset, number); - break; - } + if(objectTokens != null) + objectTokens.MarkLabel(offset, number); + break; + } - /* - * Try/Catch blocks. - */ + // Try/Catch blocks. case ScriptObjWriterCode.BegExcBlk: - { - ilGen.BeginExceptionBlock(); - if(objectTokens != null) - objectTokens.BegExcBlk(offset); - break; - } + { + ilGen.BeginExceptionBlock(); + if(objectTokens != null) + objectTokens.BegExcBlk(offset); + break; + } case ScriptObjWriterCode.BegCatBlk: - { - Type excType = GetTypeFromStr(sdTypes, objReader.ReadString()); - ilGen.BeginCatchBlock(excType); - if(objectTokens != null) - objectTokens.BegCatBlk(offset, excType); - break; - } + { + Type excType = GetTypeFromStr(sdTypes, objReader.ReadString()); + ilGen.BeginCatchBlock(excType); + if(objectTokens != null) + objectTokens.BegCatBlk(offset, excType); + break; + } case ScriptObjWriterCode.BegFinBlk: - { - ilGen.BeginFinallyBlock(); - if(objectTokens != null) - objectTokens.BegFinBlk(offset); - break; - } + { + ilGen.BeginFinallyBlock(); + if(objectTokens != null) + objectTokens.BegFinBlk(offset); + break; + } case ScriptObjWriterCode.EndExcBlk: - { - ilGen.EndExceptionBlock(); - if(objectTokens != null) - objectTokens.EndExcBlk(offset); - break; - } + { + ilGen.EndExceptionBlock(); + if(objectTokens != null) + objectTokens.EndExcBlk(offset); + break; + } - /* - * Emit an opcode with no operand. - */ + // Emit an opcode with no operand. case ScriptObjWriterCode.EmitNull: - { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode); - if(objectTokens != null) - objectTokens.EmitNull(offset, opCode); - break; - } + if(objectTokens != null) + objectTokens.EmitNull(offset, opCode); + break; + } - /* - * Emit an opcode with a FieldInfo operand. - */ + // Emit an opcode with a FieldInfo operand. case ScriptObjWriterCode.EmitField: - { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - Type reflectedType = GetTypeFromStr(sdTypes, objReader.ReadString()); - string fieldName = objReader.ReadString(); + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + Type reflectedType = GetTypeFromStr(sdTypes, objReader.ReadString()); + string fieldName = objReader.ReadString(); - FieldInfo field = reflectedType.GetField(fieldName); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, field); + FieldInfo field = reflectedType.GetField(fieldName); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, field); - if(objectTokens != null) - objectTokens.EmitField(offset, opCode, field); - break; - } + if(objectTokens != null) + objectTokens.EmitField(offset, opCode, field); + break; + } - /* - * Emit an opcode with a LocalBuilder operand. - */ + // Emit an opcode with a LocalBuilder operand. case ScriptObjWriterCode.EmitLocal: - { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - int number = objReader.ReadInt32(); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, locals[number]); + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + int number = objReader.ReadInt32(); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, locals[number]); - if(objectTokens != null) - objectTokens.EmitLocal(offset, opCode, number); - break; - } + if(objectTokens != null) + objectTokens.EmitLocal(offset, opCode, number); + break; + } - /* - * Emit an opcode with a Type operand. - */ + // Emit an opcode with a Type operand. case ScriptObjWriterCode.EmitType: - { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - string name = objReader.ReadString(); - Type type = GetTypeFromStr(sdTypes, name); + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + string name = objReader.ReadString(); + Type type = GetTypeFromStr(sdTypes, name); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, type); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, type); - if(objectTokens != null) - objectTokens.EmitType(offset, opCode, type); - break; - } + if(objectTokens != null) + objectTokens.EmitType(offset, opCode, type); + break; + } - /* - * Emit an opcode with a Label operand. - */ + // Emit an opcode with a Label operand. case ScriptObjWriterCode.EmitLabel: - { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - int number = objReader.ReadInt32(); + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + int number = objReader.ReadInt32(); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, labels[number]); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, labels[number]); - if(objectTokens != null) - objectTokens.EmitLabel(offset, opCode, number); - break; - } + if(objectTokens != null) + objectTokens.EmitLabel(offset, opCode, number); + break; + } - /* - * Emit an opcode with a Label array operand. - */ + // Emit an opcode with a Label array operand. case ScriptObjWriterCode.EmitLabels: + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + int nLabels = objReader.ReadInt32(); + Label[] lbls = new Label[nLabels]; + int[] nums = new int[nLabels]; + for(int i = 0; i < nLabels; i++) { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - int nLabels = objReader.ReadInt32(); - Label[] lbls = new Label[nLabels]; - int[] nums = new int[nLabels]; - for(int i = 0; i < nLabels; i++) - { - nums[i] = objReader.ReadInt32(); - lbls[i] = labels[nums[i]]; - } - - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, lbls); - - if(objectTokens != null) - objectTokens.EmitLabels(offset, opCode, nums); - break; + nums[i] = objReader.ReadInt32(); + lbls[i] = labels[nums[i]]; } - /* - * Emit an opcode with a MethodInfo operand (such as a call) of an external function. - */ + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, lbls); + + if(objectTokens != null) + objectTokens.EmitLabels(offset, opCode, nums); + break; + } + + // Emit an opcode with a MethodInfo operand (such as a call) of an external function. case ScriptObjWriterCode.EmitMethodExt: + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + string methName = objReader.ReadString(); + Type methType = GetTypeFromStr(sdTypes, objReader.ReadString()); + int nArgs = objReader.ReadInt32(); + + Type[] argTypes = new Type[nArgs]; + for(int i = 0; i < nArgs; i++) { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - string methName = objReader.ReadString(); - Type methType = GetTypeFromStr(sdTypes, objReader.ReadString()); - int nArgs = objReader.ReadInt32(); - - Type[] argTypes = new Type[nArgs]; - for(int i = 0; i < nArgs; i++) - { - argTypes[i] = GetTypeFromStr(sdTypes, objReader.ReadString()); - } - MethodInfo methInfo = methType.GetMethod(methName, argTypes); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, methInfo); - - if(objectTokens != null) - objectTokens.EmitMethod(offset, opCode, methInfo); - break; + argTypes[i] = GetTypeFromStr(sdTypes, objReader.ReadString()); } + MethodInfo methInfo = methType.GetMethod(methName, argTypes); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, methInfo); - /* - * Emit an opcode with a MethodInfo operand of an internal function - * (previously declared via DclMethod). - */ + if(objectTokens != null) + objectTokens.EmitMethod(offset, opCode, methInfo); + break; + } + + // Emit an opcode with a MethodInfo operand of an internal function + // (previously declared via DclMethod). case ScriptObjWriterCode.EmitMethodInt: - { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - string methName = objReader.ReadString(); + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + string methName = objReader.ReadString(); - MethodInfo methInfo = methods[methName]; - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, methInfo); + MethodInfo methInfo = methods[methName]; + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, methInfo); - if(objectTokens != null) - objectTokens.EmitMethod(offset, opCode, methInfo); - break; - } + if(objectTokens != null) + objectTokens.EmitMethod(offset, opCode, methInfo); + break; + } - /* - * Emit an opcode with a ConstructorInfo operand. - */ + // Emit an opcode with a ConstructorInfo operand. case ScriptObjWriterCode.EmitCtor: + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + Type ctorType = GetTypeFromStr(sdTypes, objReader.ReadString()); + int nArgs = objReader.ReadInt32(); + Type[] argTypes = new Type[nArgs]; + for(int i = 0; i < nArgs; i++) { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - Type ctorType = GetTypeFromStr(sdTypes, objReader.ReadString()); - int nArgs = objReader.ReadInt32(); - Type[] argTypes = new Type[nArgs]; - for(int i = 0; i < nArgs; i++) - { - argTypes[i] = GetTypeFromStr(sdTypes, objReader.ReadString()); - } - - ConstructorInfo ctorInfo = ctorType.GetConstructor(argTypes); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, ctorInfo); - - if(objectTokens != null) - objectTokens.EmitCtor(offset, opCode, ctorInfo); - break; + argTypes[i] = GetTypeFromStr(sdTypes, objReader.ReadString()); } - /* - * Emit an opcode with a constant operand of various types. - */ + ConstructorInfo ctorInfo = ctorType.GetConstructor(argTypes); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, ctorInfo); + + if(objectTokens != null) + objectTokens.EmitCtor(offset, opCode, ctorInfo); + break; + } + + // Emit an opcode with a constant operand of various types. case ScriptObjWriterCode.EmitDouble: + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + double value = objReader.ReadDouble(); + + if(opCode != OpCodes.Ldc_R8) { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - double value = objReader.ReadDouble(); - - if(opCode != OpCodes.Ldc_R8) - { - throw new Exception("bad opcode " + opCode.ToString()); - } - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, value); - - if(objectTokens != null) - objectTokens.EmitDouble(offset, opCode, value); - break; + throw new Exception("bad opcode " + opCode.ToString()); } + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, value); + + if(objectTokens != null) + objectTokens.EmitDouble(offset, opCode, value); + break; + } case ScriptObjWriterCode.EmitFloat: + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + float value = objReader.ReadSingle(); + + if(opCode != OpCodes.Ldc_R4) { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - float value = objReader.ReadSingle(); - - if(opCode != OpCodes.Ldc_R4) - { - throw new Exception("bad opcode " + opCode.ToString()); - } - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, value); - - if(objectTokens != null) - objectTokens.EmitFloat(offset, opCode, value); - break; + throw new Exception("bad opcode " + opCode.ToString()); } + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, value); + + if(objectTokens != null) + objectTokens.EmitFloat(offset, opCode, value); + break; + } case ScriptObjWriterCode.EmitInteger: + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + int value = objReader.ReadInt32(); + + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + + if(opCode == OpCodes.Ldc_I4) { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - int value = objReader.ReadInt32(); - - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - - if(opCode == OpCodes.Ldc_I4) + if((value >= -1) && (value <= 8)) { - if((value >= -1) && (value <= 8)) - { - opCode = opCodesLdcI4M1P8[value + 1]; - ilGen.Emit(opCode); - if(objectTokens != null) - objectTokens.EmitNull(offset, opCode); - break; - } - if((value >= 0) && (value <= 127)) - { - opCode = OpCodes.Ldc_I4_S; - ilGen.Emit(OpCodes.Ldc_I4_S, (sbyte)value); - goto pemitint; - } + opCode = opCodesLdcI4M1P8[value + 1]; + ilGen.Emit(opCode); + if(objectTokens != null) + objectTokens.EmitNull(offset, opCode); + break; + } + if((value >= 0) && (value <= 127)) + { + opCode = OpCodes.Ldc_I4_S; + ilGen.Emit(OpCodes.Ldc_I4_S, (sbyte)value); + goto pemitint; } - - ilGen.Emit(opCode, value); - pemitint: - if(objectTokens != null) - objectTokens.EmitInteger(offset, opCode, value); - break; } + ilGen.Emit(opCode, value); + pemitint: + if(objectTokens != null) + objectTokens.EmitInteger(offset, opCode, value); + break; + } + case ScriptObjWriterCode.EmitString: - { - OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); - string value = objReader.ReadString(); + { + OpCode opCode = ReadOpCode(objReader, ref srcFile, ref srcLine, ref srcPosn); + string value = objReader.ReadString(); - SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); - ilGen.Emit(opCode, value); + SaveSrcLoc(srcLocs, offset, srcFile, srcLine, srcPosn); + ilGen.Emit(opCode, value); - if(objectTokens != null) - objectTokens.EmitString(offset, opCode, value); - break; - } + if(objectTokens != null) + objectTokens.EmitString(offset, opCode, value); + break; + } - /* - * Who knows what? - */ + // Who knows what? default: throw new Exception("bad ScriptObjWriterCode " + ((byte)code).ToString()); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs index b0653f7514..85bc9aa260 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs @@ -58,7 +58,6 @@ using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; namespace OpenSim.Region.ScriptEngine.Yengine { - public class ScriptReduce { public const uint SDT_PRIVATE = 1; @@ -177,25 +176,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private ScriptReduce(TokenBegin tokenBegin) { - /* - * Create a place to put the top-level script components, - * eg, state bodies, functions, global variables. - */ + // Create a place to put the top-level script components, + // eg, state bodies, functions, global variables. tokenScript = new TokenScript(tokenBegin.nextToken); - /* - * 'class', 'delegate', 'instance' all define types. - * So we pre-scan the source tokens for those keywords - * to build a script-defined type table and substitute - * type tokens for those names in the source. This is - * done as a separate scan so they can cross-reference - * each other. Also does likewise for fixed array types. - * - * Also, all 'typedef's are processed here. Their definitions - * remain in the source token stream after this, but they can - * be skipped over, because their bodies have been substituted - * in the source for any references. - */ + // 'class', 'delegate', 'instance' all define types. + // So we pre-scan the source tokens for those keywords + // to build a script-defined type table and substitute + // type tokens for those names in the source. This is + // done as a separate scan so they can cross-reference + // each other. Also does likewise for fixed array types. + // + // Also, all 'typedef's are processed here. Their definitions + // remain in the source token stream after this, but they can + // be skipped over, because their bodies have been substituted + // in the source for any references. ParseSDTypePreScanPassOne(tokenBegin); // catalog definitions ParseSDTypePreScanPassTwo(tokenBegin); // substitute references @@ -226,10 +221,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } */ - /* - * Create a function $globalvarinit to hold all explicit - * global variable initializations. - */ + // Create a function $globalvarinit to hold all explicit + // global variable initializations. TokenDeclVar gviFunc = new TokenDeclVar(tokenBegin, null, tokenScript); gviFunc.name = new TokenName(gviFunc, "$globalvarinit"); gviFunc.retType = new TokenTypeVoid(gviFunc); @@ -240,9 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokenScript.globalVarInit = gviFunc; tokenScript.AddVarEntry(gviFunc); - /* - * Scan through the tokens until we reach the end. - */ + // Scan through the tokens until we reach the end. for(Token token = tokenBegin.nextToken; !(token is TokenEnd);) { if(token is TokenKwSemi) @@ -251,25 +242,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Script-defined type declarations. - */ + // Script-defined type declarations. if(ParseDeclSDTypes(ref token, null, SDT_PUBLIC)) continue; - /* - * constant = ; - */ + // constant = ; if(token is TokenKwConst) { ParseDeclVar(ref token, null); continue; } - /* - * ; - * = ; - */ + // ; + // = ; if((token is TokenType) && (token.nextToken is TokenName) && ((token.nextToken.nextToken is TokenKwSemi) || @@ -285,9 +270,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * { [ get { } ] [ set { } ] } - */ + // { [ get { } ] [ set { } ] } if((token is TokenType) && (token.nextToken is TokenName) && (token.nextToken.nextToken is TokenKwBrcOpen)) @@ -296,10 +279,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * - * global function returning specified type - */ + // + // global function returning specified type if(token is TokenType) { TokenType tokenType = (TokenType)token; @@ -330,10 +311,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * - * global function returning void - */ + // + // global function returning void if(token is TokenName) { TokenName tokenName = (TokenName)token; @@ -355,9 +334,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * default - */ + // default if(token is TokenKwDefault) { TokenDeclState tokenDeclState = new TokenDeclState(token); @@ -374,9 +351,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * state - */ + // state if(token is TokenKwState) { TokenDeclState tokenDeclState = new TokenDeclState(token); @@ -401,25 +376,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Doesn't fit any of those forms, output message and skip to next statement. - */ + // Doesn't fit any of those forms, output message and skip to next statement. ErrorMsg(token, "looking for var name, type, state or default, script-defined type declaration"); token = SkipPastSemi(token); continue; } - /* - * Must have a default state to start in. - */ + // Must have a default state to start in. if(!errors && (tokenScript.defaultState == null)) { ErrorMsg(tokenScript, "no default state defined"); } - /* - * If any error messages were written out, set return value to null. - */ + // If any error messages were written out, set return value to null. if(errors) tokenScript = null; } @@ -444,10 +413,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine for(Token t = tokenBegin; !((t = t.nextToken) is TokenEnd);) { - /* - * Keep track of nested definitions so we can link them up. - * We also need to detect the end of class and interface definitions. - */ + // Keep track of nested definitions so we can link them up. + // We also need to detect the end of class and interface definitions. if(t is TokenKwBrcOpen) { openBraceLevel++; @@ -468,11 +435,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for 'class' or 'interface'. - * They always define a new class or interface. - * They can contain nested script-defined type definitions. - */ + // Check for 'class' or 'interface'. + // They always define a new class or interface. + // They can contain nested script-defined type definitions. if((t is TokenKwClass) || (t is TokenKwInterface)) { Token kw = t; @@ -486,9 +451,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenName name = (TokenName)t; t = t.nextToken; - /* - * Malloc the script-defined type object. - */ + // Malloc the script-defined type object. TokenDeclSDType decl; if(kw is TokenKwClass) decl = new TokenDeclSDTypeClass(name, kw.prevToken is TokenKwPartial); @@ -496,56 +459,43 @@ namespace OpenSim.Region.ScriptEngine.Yengine decl = new TokenDeclSDTypeInterface(name); decl.outerSDType = outerLevels.Peek(); - /* - * Check for generic parameter list. - */ + // Check for generic parameter list. if(!ParseGenProtoParamList(ref t, decl)) continue; - /* - * Splice in a TokenDeclSDType token that replaces the keyword and the name tokens - * and any generic parameters including the '<', ','s and '>'. - * kw = points to 'class' or 'interface' keyword. - * t = points to just past last part of class name parsed, hopefully a ':' or '{'. - */ + // Splice in a TokenDeclSDType token that replaces the keyword and the name tokens + // and any generic parameters including the '<', ','s and '>'. + // kw = points to 'class' or 'interface' keyword. + // t = points to just past last part of class name parsed, hopefully a ':' or '{'. decl.prevToken = decl.isPartial ? kw.prevToken.prevToken : kw.prevToken; decl.nextToken = t; decl.prevToken.nextToken = decl; decl.nextToken.prevToken = decl; - /* - * Enter it in name lists so it can be seen by others. - */ + // Enter it in name lists so it can be seen by others. Token partialNewBody = CatalogSDTypeDecl(decl); - /* - * Start inner type definitions. - */ + // Start inner type definitions. braceLevels.Push(openBraceLevel); outerLevels.Push(decl); - /* - * Scan the body starting on for before the '{'. - * - * If this body had an old partial merged into it, - * resume scanning at the beginning of the new body, - * ie, what used to be the first token after the '{' - * before the old body was spliced in. - */ + // Scan the body starting on for before the '{'. + // + // If this body had an old partial merged into it, + // resume scanning at the beginning of the new body, + // ie, what used to be the first token after the '{' + // before the old body was spliced in. if(partialNewBody != null) { - - /* - * We have a partial that has had old partial body merged - * into new partial body. So resume scanning at the beginning - * of the new partial body so we don't get any duplicate scanning - * of the old partial body. - * - * ... { } - * ^- resume scanning here - * but inc openBraceLevel because - * we skipped scanning the '{' - */ + // We have a partial that has had old partial body merged + // into new partial body. So resume scanning at the beginning + // of the new partial body so we don't get any duplicate scanning + // of the old partial body. + // + // ... { } + // ^- resume scanning here + // but inc openBraceLevel because + // we skipped scanning the '{' openBraceLevel++; t = partialNewBody; } @@ -553,23 +503,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for 'delegate'. - * It always defines a new delegate. - * Delegates never define nested types. - */ + // Check for 'delegate'. + // It always defines a new delegate. + // Delegates never define nested types. if(t is TokenKwDelegate) { Token kw = t; t = t.nextToken; - /* - * Next thing might be an explicit return type or the delegate's name. - * If it's a type token, then it's the return type, simple enough. - * But if it's a name token, it might be the name of some other script-defined type. - * The way to tell is that the delegate name is followed by a '(', whereas an - * explicit return type is followed by the delegate name. - */ + // Next thing might be an explicit return type or the delegate's name. + // If it's a type token, then it's the return type, simple enough. + // But if it's a name token, it might be the name of some other script-defined type. + // The way to tell is that the delegate name is followed by a '(', whereas an + // explicit return type is followed by the delegate name. Token retType = t; TokenName delName = null; Token u; @@ -602,29 +548,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(retType == delName) retType = null; - /* - * Malloc the script-defined type object. - */ + // Malloc the script-defined type object. TokenDeclSDTypeDelegate decl = new TokenDeclSDTypeDelegate(delName); decl.outerSDType = outerLevels.Peek(); - /* - * Check for generic parameter list. - */ + // Check for generic parameter list. t = delName.nextToken; if(!ParseGenProtoParamList(ref t, decl)) continue; - /* - * Enter it in name lists so it can be seen by others. - */ + // Enter it in name lists so it can be seen by others. CatalogSDTypeDecl(decl); - /* - * Splice in the token that replaces the 'delegate' keyword and the whole name - * (including the '<' name ... '>' parts). The return type token(s), if any, - * follow the splice token and come before the '('. - */ + // Splice in the token that replaces the 'delegate' keyword and the whole name + // (including the '<' name ... '>' parts). The return type token(s), if any, + // follow the splice token and come before the '('. decl.prevToken = kw.prevToken; kw.prevToken.nextToken = decl; @@ -641,10 +579,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine t.prevToken = retType; } - /* - * Scan for terminating ';'. - * There cannot be an intervening class, delegate, interfate, typedef, { or }. - */ + // Scan for terminating ';'. + // There cannot be an intervening class, delegate, interfate, typedef, { or }. for(t = decl; !(t is TokenKwSemi); t = u) { u = t.nextToken; @@ -664,11 +600,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for 'typedef'. - * It always defines a new macro. - * Typedefs never define nested types. - */ + // Check for 'typedef'. + // It always defines a new macro. + // Typedefs never define nested types. if(t is TokenKwTypedef) { Token kw = t; @@ -683,37 +617,27 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenName tdName = (TokenName)t; t = t.nextToken; - /* - * Malloc the script-defined type object. - */ + // Malloc the script-defined type object. TokenDeclSDTypeTypedef decl = new TokenDeclSDTypeTypedef(tdName); decl.outerSDType = outerLevels.Peek(); - /* - * Check for generic parameter list. - */ + // Check for generic parameter list. if(!ParseGenProtoParamList(ref t, decl)) continue; - /* - * Enter it in name lists so it can be seen by others. - */ + // Enter it in name lists so it can be seen by others. CatalogSDTypeDecl(decl); numTypedefs++; - /* - * Splice in the token that replaces the 'typedef' keyword and the whole name - * (including the '<' name ... '>' parts). - */ + // Splice in the token that replaces the 'typedef' keyword and the whole name + // (including the '<' name ... '>' parts). decl.prevToken = kw.prevToken; kw.prevToken.nextToken = decl; decl.nextToken = t; t.prevToken = decl; - /* - * Scan for terminating ';'. - * There cannot be an intervening class, delegate, interfate, typedef, { or }. - */ + // Scan for terminating ';'. + // There cannot be an intervening class, delegate, interfate, typedef, { or }. Token u; for(t = decl; !(t is TokenKwSemi); t = u) { @@ -747,16 +671,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private bool ParseGenProtoParamList(ref Token t, TokenDeclSDType decl) { - /* - * Maybe there aren't any generic parameters. - * If so, leave decl.genParams = null. - */ + // Maybe there aren't any generic parameters. + // If so, leave decl.genParams = null. if(!(t is TokenKwCmpLT)) return true; - /* - * Build list of generic parameter names. - */ + // Build list of generic parameter names. Dictionary parms = new Dictionary(); do { @@ -813,17 +733,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(!GenericParametersMatch(decl, dupDecl)) ErrorMsg(decl, "all partial class generic parameters must match"); - /* - * Have new declaration be the cataloged one because body is going to get - * snipped out of old declaration and pasted into new declaration. - */ + // Have new declaration be the cataloged one because body is going to get + // snipped out of old declaration and pasted into new declaration. tokenScript.sdSrcTypesRep(longName, decl); if(decl.outerSDType != null) decl.outerSDType.innerSDTypes[decl.shortName.val] = decl; - /* - * Find old partial definition's opening brace. - */ + // Find old partial definition's opening brace. Token dupBrcOpen; for(dupBrcOpen = dupDecl; !(dupBrcOpen is TokenKwBrcOpen); dupBrcOpen = dupBrcOpen.nextToken) { @@ -834,9 +750,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Find new partial definition's opening brace. - */ + // Find new partial definition's opening brace. Token brcOpen; for(brcOpen = decl; !(brcOpen is TokenKwBrcOpen); brcOpen = brcOpen.nextToken) { @@ -848,25 +762,23 @@ namespace OpenSim.Region.ScriptEngine.Yengine } Token body = brcOpen.nextToken; - /* - * Stick old partial definition's extends/implementeds list just - * in front of new partial definition's extends/implementeds list. - * - * class oldextimp { oldbody } ... - * dupDecl dupBrcOpen dupDecl.endToken - * - * class newextimp { newbody } ... - * decl brcOpen body decl.endToken - * - * becomes - * - * class ... - * dupDecl - * dupDecl.endToken - * - * class oldextimp newextimp { oldbody newbody } ... - * decl brcOpen body decl.endToken - */ + // Stick old partial definition's extends/implementeds list just + // in front of new partial definition's extends/implementeds list. + // + // class oldextimp { oldbody } ... + // dupDecl dupBrcOpen dupDecl.endToken + // + // class newextimp { newbody } ... + // decl brcOpen body decl.endToken + // + // becomes + // + // class ... + // dupDecl + // dupDecl.endToken + // + // class oldextimp newextimp { oldbody newbody } ... + // decl brcOpen body decl.endToken if(dupBrcOpen != dupDecl.nextToken) { dupBrcOpen.prevToken.nextToken = decl.nextToken; @@ -875,10 +787,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine decl.nextToken = dupDecl.nextToken; } - /* - * Stick old partial definition's body just - * in front of new partial definition's body. - */ + // Stick old partial definition's body just + // in front of new partial definition's body. if(dupBrcOpen.nextToken != dupDecl.endToken) { dupBrcOpen.nextToken.prevToken = brcOpen; @@ -887,10 +797,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine brcOpen.nextToken = dupBrcOpen.nextToken; } - /* - * Null out old definition's extends/implementeds list and body - * by having the declaration token be the only thing left. - */ + // Null out old definition's extends/implementeds list and body + // by having the declaration token be the only thing left. dupDecl.nextToken = dupDecl.endToken.nextToken; dupDecl.nextToken.prevToken = dupDecl; dupDecl.endToken = dupDecl; @@ -946,41 +854,34 @@ namespace OpenSim.Region.ScriptEngine.Yengine for(Token t = tokenBegin; !((t = t.nextToken) is TokenEnd);) { - - /* - * Maybe it's time to pop out of an outer class definition. - */ + // Maybe it's time to pop out of an outer class definition. if((outerSDType != null) && (outerSDType.endToken == t)) { outerSDType = outerSDType.outerSDType; continue; } - /* - * Skip completely over any script-defined generic prototypes. - * We only need to process their instantiations which are non- - * generic versions of the generics. - */ + // Skip completely over any script-defined generic prototypes. + // We only need to process their instantiations which are non- + // generic versions of the generics. if((t is TokenDeclSDType) && (((TokenDeclSDType)t).genParams != null)) { t = ((TokenDeclSDType)t).endToken; continue; } - /* - * Check for beginning of non-generic script-defined type definitions. - * They can have nested definitions in their innerSDTypes[] that match - * name tokens, so add them to the stack. - * - * But just ignore any preliminary partial definitions as they have had - * their entire contents spliced out and spliced into a subsequent partial - * definition. So if we originally had: - * partial class Abc { public intenger one; } - * partial class Abc { public intenger two; } - * We now have: - * partial_class_Abc <== if we are here, just ignore the partial_class_Abc token - * partial_class_Abc { public intenger one; public intenger two; } - */ + // Check for beginning of non-generic script-defined type definitions. + // They can have nested definitions in their innerSDTypes[] that match + // name tokens, so add them to the stack. + // + // But just ignore any preliminary partial definitions as they have had + // their entire contents spliced out and spliced into a subsequent partial + // definition. So if we originally had: + // partial class Abc { public intenger one; } + // partial class Abc { public intenger two; } + // We now have: + // partial_class_Abc <== if we are here, just ignore the partial_class_Abc token + // partial_class_Abc { public intenger one; public intenger two; } if(t is TokenDeclSDType) { if(((TokenDeclSDType)t).endToken != t) @@ -989,22 +890,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * For names not preceded by a '.', scan the script-defined type definition - * stack for that name. Splice the name out and replace with equivalent token. - */ + // For names not preceded by a '.', scan the script-defined type definition + // stack for that name. Splice the name out and replace with equivalent token. if((t is TokenName) && !(t.prevToken is TokenKwDot)) t = TrySpliceTypeRef(t, outerSDType, ref repeat, noTypes); - /* - * This handles types such as integer[,][], List[], etc. - * They are an instantiation of an internally generated type of the same name, brackets and all. - * Note that to malloc an array, use something like 'new float[,][](3,5)', not 'new float[3,5][]'. - * - * Note that we must not get confused by $idxprop property declarations such as: - * float [string kee] { get { ... } } - * ... and try to convert 'float' '[' to an array type. - */ + // This handles types such as integer[,][], List[], etc. + // They are an instantiation of an internally generated type of the same name, brackets and all. + // Note that to malloc an array, use something like 'new float[,][](3,5)', not 'new float[3,5][]'. + // + // Note that we must not get confused by $idxprop property declarations such as: + // float [string kee] { get { ... } } + // ... and try to convert 'float' '[' to an array type. if((t is TokenType) && (t.nextToken is TokenKwBrkOpen)) { if((t.nextToken.nextToken is TokenKwBrkClose) || @@ -1015,19 +912,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If we instantiated a generic, loop back to process its contents - * just as if the source code had the instantiated code to begin with. - * Also repeat if we found a non-type inside the <> of a generic reference - * provided we have made at least one name->type substitution. - */ + // If we instantiated a generic, loop back to process its contents + // just as if the source code had the instantiated code to begin with. + // Also repeat if we found a non-type inside the <> of a generic reference + // provided we have made at least one name->type substitution. } while(((repeat & REPEAT_INSTGEN) != 0) || ((repeat & (REPEAT_NOTYPE | REPEAT_SUBST)) == (REPEAT_NOTYPE | REPEAT_SUBST))); - /* - * These are places where we required a type be present, - * eg, a generic type argument or the body of a typedef. - */ + // These are places where we required a type be present, + // eg, a generic type argument or the body of a typedef. foreach(Token t in noTypes) ErrorMsg(t, "looking for type"); } @@ -1048,11 +941,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine Token start = t; string tnamestr = ((TokenName)t).val; - /* - * Look for the name as a type declared by outerSDType or anything - * even farther out than that. If not found, simply return - * without updating t, meaning that t isn't the name of a type. - */ + // Look for the name as a type declared by outerSDType or anything + // even farther out than that. If not found, simply return + // without updating t, meaning that t isn't the name of a type. TokenDeclSDType decl = null; while(outerSDType != null) { @@ -1066,10 +957,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine TokenDeclSDType instdecl; while(true) { - - /* - * If it is a generic type, it must be followed by instantiation arguments. - */ + // If it is a generic type, it must be followed by instantiation arguments. instdecl = decl; if(decl.genParams != null) { @@ -1134,12 +1022,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokenScript.sdSrcTypesTryGetValue(tnamestr, out instdecl); } - /* - * Couldn't find 'List' but found 'List' and we have genArgs = 'string'. - * Instantiate the generic to create 'List'. This splices the definition - * of 'List' into the source token stream just as if it had been there all - * along. We have to then repeat the scan to process the instance's contents. - */ + // Couldn't find 'List' but found 'List' and we have genArgs = 'string'. + // Instantiate the generic to create 'List'. This splices the definition + // of 'List' into the source token stream just as if it had been there all + // along. We have to then repeat the scan to process the instance's contents. if(instdecl == null) { instdecl = decl.InstantiateGeneric(tnamestr, genArgs, this); @@ -1148,9 +1034,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Maybe caller wants a subtype by putting a '.' following all that. - */ + // Maybe caller wants a subtype by putting a '.' following all that. if(!(t.nextToken is TokenKwDot)) break; if(!(t.nextToken.nextToken is TokenName)) @@ -1162,14 +1046,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine outerSDType = instdecl; } - /* - * Create a reference in the source to the definition - * that encapsulates the long dotted type name given in - * the source, and replace the long dotted type name in - * the source with the reference token, eg, replace - * 'Dictionary' '<' 'string' ',' 'integer' '>' '.' 'ValueList' - * with 'Dictionary.ValueList'. - */ + // Create a reference in the source to the definition + // that encapsulates the long dotted type name given in + // the source, and replace the long dotted type name in + // the source with the reference token, eg, replace + // 'Dictionary' '<' 'string' ',' 'integer' '>' '.' 'ValueList' + // with 'Dictionary.ValueList'. TokenType refer = instdecl.MakeRefToken(start); if(refer == null) { @@ -1203,11 +1085,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine Stack ranks = new Stack(); - /* - * When script specifies 'float[,][]' it means a two-dimensional matrix - * that points to one-dimensional vectors of floats. So we would push - * a 2 then a 1 in this parsing code... - */ + // When script specifies 'float[,][]' it means a two-dimensional matrix + // that points to one-dimensional vectors of floats. So we would push + // a 2 then a 1 in this parsing code... do { t = t.nextToken; // point at '[' @@ -1225,14 +1105,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine ranks.Push(rank); } while(t.nextToken is TokenKwBrkOpen); - /* - * Now we build the types in reverse order. For the example above we will: - * first, create a type that is a one-dimensional vector of floats, float[] - * second, create a type that is a two-dimensional matrix of that. - * This keeps declaration and referencing similar, eg, - * float[,][] jag = new float[,][] (3,4); - * jag[i,j][k] ... is used to access the elements - */ + // Now we build the types in reverse order. For the example above we will: + // first, create a type that is a one-dimensional vector of floats, float[] + // second, create a type that is a two-dimensional matrix of that. + // This keeps declaration and referencing similar, eg, + // float[,][] jag = new float[,][] (3,4); + // jag[i,j][k] ... is used to access the elements do { int rank = ranks.Pop(); @@ -1240,17 +1118,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine ofType = decl.MakeRefToken(ofType); } while(ranks.Count > 0); - /* - * Finally splice in the resultant array type to replace the original tokens. - */ + // Finally splice in the resultant array type to replace the original tokens. ofType.prevToken = start.prevToken; ofType.nextToken = t.nextToken; ofType.prevToken.nextToken = ofType; ofType.nextToken.prevToken = ofType; - /* - * Resume parsing just after the spliced-in array type token. - */ + // Resume parsing just after the spliced-in array type token. return ofType; } @@ -1262,13 +1136,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenDeclSDType InstantiateFixedArray(int rank, TokenType ofType, Token tokenBegin, ref uint repeat) { - /* - * Create the array type's name. - * If starting with a non-array type, just append the rank to it, eg, float + rank=1 -> float[] - * If starting with an array type, slip this rank in front of existing array, eg, float[] + rank=2 -> float[,][]. - * This makes it consistent with what the script-writer sees for both a type specification and when - * referencing elements in a jagged array. - */ + // Create the array type's name. + // If starting with a non-array type, just append the rank to it, eg, float + rank=1 -> float[] + // If starting with an array type, slip this rank in front of existing array, eg, float[] + rank=2 -> float[,][]. + // This makes it consistent with what the script-writer sees for both a type specification and when + // referencing elements in a jagged array. string name = ofType.ToString(); StringBuilder sb = new StringBuilder(name); int ix = name.IndexOf('['); @@ -1293,12 +1165,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(ofType is TokenTypeInt) suffix = 'I'; - /* - * Don't already have one, create a new skeleton struct. - * Splice in a definition for the class at beginning of source file. - * - * class { - */ + // Don't already have one, create a new skeleton struct. + // Splice in a definition for the class at beginning of source file. + // + // class { fa = new TokenDeclSDTypeClass(new TokenName(tokenScript, name), false); CatalogSDTypeDecl(fa); repeat |= REPEAT_INSTGEN; @@ -1308,12 +1178,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine Token t = SpliceAfter(tokenBegin, fa); t = SpliceAfter(t, new TokenKwBrcOpen(t)); - /* - * public integer len0; - * public integer len1; - * ... - * public object obj; - */ + // public integer len0; + // public integer len1; + // ... + // public object obj; for(int i = 0; i < rank; i++) { t = SpliceAfter(t, new TokenKwPublic(t)); @@ -1327,14 +1195,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine t = SpliceAfter(t, new TokenName(t, "obj")); t = SpliceAfter(t, new TokenKwSemi(t)); - /* - * public constructor (integer len0, integer len1, ...) { - * this.len0 = len0; - * this.len1 = len1; - * ... - * this.obj = xmrFixedArrayAlloc (len0 * len1 * ...); - * } - */ + // public constructor (integer len0, integer len1, ...) { + // this.len0 = len0; + // this.len1 = len1; + // ... + // this.obj = xmrFixedArrayAlloc (len0 * len1 * ...); + // } t = SpliceAfter(t, new TokenKwPublic(t)); t = SpliceAfter(t, new TokenKwConstructor(t)); t = SpliceAfter(t, new TokenKwParOpen(t)); @@ -1374,11 +1240,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine t = SpliceAfter(t, new TokenKwSemi(t)); t = SpliceAfter(t, new TokenKwBrcClose(t)); - /* - * public integer Length { get { - * return this.len0 * this.len1 * ... ; - * } } - */ + // public integer Length { get { + // return this.len0 * this.len1 * ... ; + // } } t = SpliceAfter(t, new TokenKwPublic(t)); t = SpliceAfter(t, new TokenTypeInt(t)); t = SpliceAfter(t, new TokenName(t, "Length")); @@ -1400,16 +1264,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine t = SpliceAfter(t, new TokenKwBrcClose(t)); t = SpliceAfter(t, new TokenKwBrcClose(t)); - /* - * public integer Length (integer dim) { - * switch (dim) { - * case 0: return this.len0; - * case 1: return this.len1; - * ... - * } - * return 0; - * } - */ + // public integer Length (integer dim) { + // switch (dim) { + // case 0: return this.len0; + // case 1: return this.len1; + // ... + // } + // return 0; + // } t = SpliceAfter(t, new TokenKwPublic(t)); t = SpliceAfter(t, new TokenTypeInt(t)); t = SpliceAfter(t, new TokenName(t, "Length")); @@ -1443,15 +1305,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine t = SpliceAfter(t, new TokenKwSemi(t)); t = SpliceAfter(t, new TokenKwBrcClose(t)); - /* - * public integer Index (integer idx0, integet idx1, ...) { - * integer idx = idx0; - * idx *= this.len1; idx += idx1; - * idx *= this.len2; idx += idx2; - * ... - * return idx; - * } - */ + // public integer Index (integer idx0, integet idx1, ...) { + // integer idx = idx0; + // idx *= this.len1; idx += idx1; + // idx *= this.len2; idx += idx2; + // ... + // return idx; + // } t = SpliceAfter(t, new TokenKwPublic(t)); t = SpliceAfter(t, new TokenTypeInt(t)); t = SpliceAfter(t, new TokenName(t, "Index")); @@ -1491,15 +1351,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine t = SpliceAfter(t, new TokenKwSemi(t)); t = SpliceAfter(t, new TokenKwBrcClose(t)); - /* - * public Get (integer idx0, integet idx1, ...) { - * integer idx = idx0; - * idx *= this.len1; idx += idx1; - * idx *= this.len2; idx += idx2; - * ... - * return () xmrFixedArrayGet (this.obj, idx); - * } - */ + // public Get (integer idx0, integet idx1, ...) { + // integer idx = idx0; + // idx *= this.len1; idx += idx1; + // idx *= this.len2; idx += idx2; + // ... + // return () xmrFixedArrayGet (this.obj, idx); + // } t = SpliceAfter(t, new TokenKwPublic(t)); t = SpliceAfter(t, ofType.CopyToken(t)); t = SpliceAfter(t, new TokenName(t, "Get")); @@ -1552,15 +1410,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine t = SpliceAfter(t, new TokenKwSemi(t)); t = SpliceAfter(t, new TokenKwBrcClose(t)); - /* - * public void Set (integer idx0, integer idx1, ..., val) { - * integer idx = idx0; - * idx *= this.len1; idx += idx1; - * idx *= this.len2; idx += idx2; - * ... - * xmrFixedArraySet (this.obj, idx, val); - * } - */ + // public void Set (integer idx0, integer idx1, ..., val) { + // integer idx = idx0; + // idx *= this.len1; idx += idx1; + // idx *= this.len2; idx += idx2; + // ... + // xmrFixedArraySet (this.obj, idx, val); + // } t = SpliceAfter(t, new TokenKwPublic(t)); t = SpliceAfter(t, new TokenTypeVoid(t)); t = SpliceAfter(t, new TokenName(t, "Set")); @@ -1764,10 +1620,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokdeclcl.members.thisClass = tokdeclcl; tokenScript.PushVarFrame(tokdeclcl.members); - /* - * Create a function $instfieldnit to hold all explicit - * instance field initializations. - */ + // Create a function $instfieldnit to hold all explicit + // instance field initializations. TokenDeclVar ifiFunc = new TokenDeclVar(tokdeclcl, null, tokenScript); ifiFunc.name = new TokenName(ifiFunc, "$instfieldinit"); ifiFunc.retType = new TokenTypeVoid(ifiFunc); @@ -1780,10 +1634,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokdeclcl.instFieldInit = ifiFunc; tokenScript.AddVarEntry(ifiFunc); - /* - * Create a function $staticfieldnit to hold all explicit - * static field initializations. - */ + // Create a function $staticfieldnit to hold all explicit + // static field initializations. TokenDeclVar sfiFunc = new TokenDeclVar(tokdeclcl, null, tokenScript); sfiFunc.name = new TokenName(sfiFunc, "$staticfieldinit"); sfiFunc.retType = new TokenTypeVoid(sfiFunc); @@ -1805,25 +1657,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for all qualifiers. - * typedef has an implied 'public' qualifier. - */ + // Check for all qualifiers. + // typedef has an implied 'public' qualifier. flags = SDT_PUBLIC; if(!(token is TokenDeclSDTypeTypedef)) { flags = ParseQualifierFlags(ref token); } - /* - * Parse nested script-defined type definitions. - */ + // Parse nested script-defined type definitions. if(ParseDeclSDTypes(ref token, tokdeclcl, flags)) continue; - /* - * constant = ; - */ + // constant = ; if(token is TokenKwConst) { if((flags & (SDT_ABSTRACT | SDT_NEW | SDT_OVERRIDE | SDT_VIRTUAL)) != 0) @@ -1839,10 +1685,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * ; - * = ; - */ + // ; + // = ; if((token is TokenType) && (token.nextToken is TokenName) && ((token.nextToken.nextToken is TokenKwSemi) || @@ -1877,10 +1721,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * [ : ] { [ get { } ] [ set { } ] } - * '[' ... ']' [ : ] { [ get { } ] [ set { } ] } - */ + // [ : ] { [ get { } ] [ set { } ] } + // '[' ... ']' [ : ] { [ get { } ] [ set { } ] } bool prop = (token is TokenType) && (token.nextToken is TokenName) && (token.nextToken.nextToken is TokenKwBrcOpen || @@ -1907,9 +1749,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * 'constructor' '(' arglist ')' [ ':' [ 'base' ] '(' baseconstructorcall ')' ] '{' body '}' - */ + // 'constructor' '(' arglist ')' [ ':' [ 'base' ] '(' baseconstructorcall ')' ] '{' body '}' if(token is TokenKwConstructor) { ParseSDTClassCtorDecl(ref token, flags, tokdeclcl); @@ -1917,36 +1757,28 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * - * method with explicit return type - */ + // + // method with explicit return type if(token is TokenType) { ParseSDTClassMethodDecl(ref token, flags, tokdeclcl); continue; } - /* - * - * method returning void - */ + // + // method returning void if((token is TokenName) || ((token is TokenKw) && ((TokenKw)token).sdtClassOp)) { ParseSDTClassMethodDecl(ref token, flags, tokdeclcl); continue; } - /* - * That's all we support in a class declaration. - */ + // That's all we support in a class declaration. ErrorMsg(token, "expecting field or method declaration"); token = SkipPastSemi(token); } - /* - * If script didn't specify any constructor, create a default no-argument one. - */ + // If script didn't specify any constructor, create a default no-argument one. if(!haveExplicitConstructor) { TokenDeclVar tokenDeclFunc = new TokenDeclVar(token, null, tokenScript); @@ -1971,9 +1803,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokenScript.AddVarEntry(tokenDeclFunc); } - /* - * Skip over the closing brace and pop corresponding var frame. - */ + // Skip over the closing brace and pop corresponding var frame. token = token.nextToken; tokenScript.PopVarFrame(); ret: @@ -2079,10 +1909,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenDeclVar ParseProperty(ref Token token, bool abs, bool imp) { - /* - * Parse out the property's type and name. - * - */ + // Parse out the property's type and name. + // TokenType type = (TokenType)token; TokenName name; TokenArgDecl args; @@ -2101,10 +1929,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine args = new TokenArgDecl(token); } - /* - * Maybe it claims to implement some interface properties. - * [ ':' [.] ',' ... ] - */ + // Maybe it claims to implement some interface properties. + // [ ':' [.] ',' ... ] TokenIntfImpl implements = null; if(token is TokenKwColon) { @@ -2117,9 +1943,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Should have an opening brace. - */ + // Should have an opening brace. if(!(token is TokenKwBrcOpen)) { ErrorMsg(token, "expect { to open property definition"); @@ -2128,19 +1952,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine } token = token.nextToken; - /* - * Parse out the getter and/or setter. - * 'get' { | ';' } - * 'set' { | ';' } - */ + // Parse out the getter and/or setter. + // 'get' { | ';' } + // 'set' { | ';' } TokenDeclVar getFunc = null; TokenDeclVar setFunc = null; while(!(token is TokenKwBrcClose)) { - - /* - * Maybe create a getter function. - */ + // Maybe create a getter function. if(token is TokenKwGet) { getFunc = new TokenDeclVar(token, null, tokenScript); @@ -2161,9 +1980,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Maybe create a setter function. - */ + // Maybe create a setter function. if(token is TokenKwSet) { TokenArgDecl argDecl = args; @@ -2204,18 +2021,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine return null; } - /* - * Set up a variable for the property. - */ + // Set up a variable for the property. TokenDeclVar tokenDeclVar = new TokenDeclVar(name, null, tokenScript); tokenDeclVar.type = type; tokenDeclVar.name = name; tokenDeclVar.getProp = getFunc; tokenDeclVar.setProp = setFunc; - /* - * Can't be same name already in block. - */ + // Can't be same name already in block. if(!tokenScript.AddVarEntry(tokenDeclVar)) { ErrorMsg(tokenDeclVar, "duplicate member " + name.val); @@ -2279,17 +2092,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokenScript.PushVarFrame(tokenDeclFunc.argDecl.varDict); try { - /* - * Set up reference to base constructor. - */ + // Set up reference to base constructor. TokenLValBaseField baseCtor = new TokenLValBaseField(token, new TokenName(token, "$ctor"), tokdeclcl); - /* - * Parse any base constructor call as if it were the first statement of the - * constructor itself. - */ + // Parse any base constructor call as if it were the first statement of the + // constructor itself. if(token is TokenKwColon) { token = token.nextToken; @@ -2318,17 +2127,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine } else if(tokdeclcl.extends != null) { - - /* - * Caller didn't specify a constructor but we are extending, so we will - * call the extended class's default constructor. - */ + // Caller didn't specify a constructor but we are extending, so we will + // call the extended class's default constructor. SetUpDefaultBaseCtorCall(tokenDeclFunc); } - /* - * Parse the constructor body. - */ + // Parse the constructor body. tokenDeclFunc.body = ParseStmtBlock(ref token); if(tokenDeclFunc.body == null) return; @@ -2341,10 +2145,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine currentDeclFunc = saveDeclFunc; } - /* - * Add to list of methods defined by this class. - * It has the name "$ctor(argsig)". - */ + // Add to list of methods defined by this class. + // It has the name "$ctor(argsig)". if(!tokenScript.AddVarEntry(tokenDeclFunc)) { ErrorMsg(tokenDeclFunc, "duplicate constructor definition"); @@ -2443,7 +2245,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine } else { - // other times should have ',' if(!(u is TokenKwComma)) { @@ -2550,16 +2351,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Parse nested script-defined type definitions. - */ + // Parse nested script-defined type definitions. if(ParseDeclSDTypes(ref token, tokdeclin, SDT_PUBLIC)) continue; - /* - * ; - * abstract method with explicit return type - */ + // ; + // abstract method with explicit return type if((token is TokenType) && (token.nextToken is TokenName) && (token.nextToken.nextToken is TokenKwParOpen)) @@ -2576,10 +2373,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * ; - * abstract method returning void - */ + // ; + // abstract method returning void if((token is TokenName) && (token.nextToken is TokenKwParOpen)) { @@ -2594,11 +2389,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * { [ get ; ] [ set ; ] } - * '[' ... ']' { [ get ; ] [ set ; ] } - * abstract property - */ + // { [ get ; ] [ set ; ] } + // '[' ... ']' { [ get ; ] [ set ; ] } + // abstract property bool prop = (token is TokenType) && (token.nextToken is TokenName) && (token.nextToken.nextToken is TokenKwBrcOpen || @@ -2610,16 +2403,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * That's all we support in an interface declaration. - */ + // That's all we support in an interface declaration. ErrorMsg(token, "expecting method or property prototype"); token = SkipPastSemi(token); } - /* - * Skip over the closing brace and pop the corresponding var frame. - */ + // Skip over the closing brace and pop the corresponding var frame. token = token.nextToken; tokenScript.PopVarFrame(); } @@ -2807,29 +2596,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine return true; } - /* - * Declare this function as being the one currently being processed - * for anything that cares. We also start a variable frame that - * includes all the declared parameters. - */ + // Declare this function as being the one currently being processed + // for anything that cares. We also start a variable frame that + // includes all the declared parameters. TokenDeclVar saveDeclFunc = currentDeclFunc; currentDeclFunc = tokenDeclFunc; tokenScript.PushVarFrame(tokenDeclFunc.argDecl.varDict); - /* - * Now parse the function statement block. - */ + // Now parse the function statement block. tokenDeclFunc.body = ParseStmtBlock(ref token); - /* - * Pop the var frame that contains the arguments. - */ + // Pop the var frame that contains the arguments. tokenScript.PopVarFrame(); currentDeclFunc = saveDeclFunc; - /* - * Check final errors. - */ + // Check final errors. if(tokenDeclFunc.body == null) return false; if(abs) @@ -2851,9 +2632,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenStmt ParseStmt(ref Token token) { - /* - * Statements that begin with a specific keyword. - */ + // Statements that begin with a specific keyword. if(token is TokenKwAt) return ParseStmtLabel(ref token); if(token is TokenKwBrcOpen) @@ -2887,10 +2666,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(token is TokenKwWhile) return ParseStmtWhile(ref token); - /* - * Try to parse anything else as an expression, possibly calling - * something and/or writing to a variable. - */ + // Try to parse anything else as an expression, possibly calling + // something and/or writing to a variable. TokenRVal tokenRVal = ParseRVal(ref token, semiOnly); if(tokenRVal != null) { @@ -2899,9 +2676,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return tokenStmtRVal; } - /* - * Who knows what it is... - */ + // Who knows what it is... ErrorMsg(token, "unknown statement"); token = SkipPastSemi(token); return null; @@ -3053,9 +2828,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { currentDeclFunc.triviality = Triviality.complex; - /* - * Create encapsulating token and skip past 'for (' - */ + // Create encapsulating token and skip past 'for (' TokenStmtFor tokenStmtFor = new TokenStmtFor(token); token = token.nextToken; if(!(token is TokenKwParOpen)) @@ -3065,9 +2838,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } token = token.nextToken; - /* - * If a plain for, ie, not declaring a variable, it's straightforward. - */ + // If a plain for, ie, not declaring a variable, it's straightforward. if(!(token is TokenType)) { tokenStmtFor.initStmt = ParseStmt(ref token); @@ -3076,10 +2847,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine return ParseStmtFor2(tokenStmtFor, ref token) ? tokenStmtFor : null; } - /* - * Initialization declares a variable, so encapsulate it in a block so - * variable has scope only in the for statement, including its body. - */ + // Initialization declares a variable, so encapsulate it in a block so + // variable has scope only in the for statement, including its body. TokenStmtBlock forStmtBlock = new TokenStmtBlock(tokenStmtFor); forStmtBlock.outerStmtBlock = currentStmtBlock; forStmtBlock.function = currentDeclFunc; @@ -3148,9 +2917,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { currentDeclFunc.triviality = Triviality.complex; - /* - * Create encapsulating token and skip past 'foreach (' - */ + // Create encapsulating token and skip past 'foreach (' TokenStmtForEach tokenStmtForEach = new TokenStmtForEach(token); token = token.nextToken; if(!(token is TokenKwParOpen)) @@ -3222,9 +2989,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine private TokenStmtJump ParseStmtJump(ref Token token) { - /* - * Create jump statement token to encapsulate the whole statement. - */ + // Create jump statement token to encapsulate the whole statement. TokenStmtJump tokenStmtJump = new TokenStmtJump(token); token = token.nextToken; if(!(token is TokenName) || !(token.nextToken is TokenKwSemi)) @@ -3236,11 +3001,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokenStmtJump.label = (TokenName)token; token = token.nextToken.nextToken; - /* - * If label is already defined, it means this is a backward (looping) - * jump, so remember the label has backward jump references. - * We also then assume the function is complex, ie, it has a loop. - */ + // If label is already defined, it means this is a backward (looping) + // jump, so remember the label has backward jump references. + // We also then assume the function is complex, ie, it has a loop. if(currentDeclFunc.labels.ContainsKey(tokenStmtJump.label.val)) { currentDeclFunc.labels[tokenStmtJump.label.val].hasBkwdRefs = true; @@ -3450,9 +3213,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenStmtTry ParseStmtTry(ref Token token) { - /* - * Parse out the 'try { ... }' part - */ + // Parse out the 'try { ... }' part Token tryKw = token; token = token.nextToken; TokenStmt body = ParseStmtBlock(ref token); @@ -3585,14 +3346,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine { TokenDeclVar tokenDeclVar = new TokenDeclVar(token.nextToken, currentDeclFunc, tokenScript); - /* - * Handle constant declaration. - * It ends up in the declared variables list for the statement block just like - * any other variable, except it has .constant = true. - * The code generator will test that the initialization expression is constant. - * - * constant = ; - */ + // Handle constant declaration. + // It ends up in the declared variables list for the statement block just like + // any other variable, except it has .constant = true. + // The code generator will test that the initialization expression is constant. + // + // constant = ; if(token is TokenKwConst) { token = token.nextToken; @@ -3618,14 +3377,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokenDeclVar.constant = true; } - /* - * Otherwise, normal variable declaration with optional initialization value. - */ + // Otherwise, normal variable declaration with optional initialization value. else { - /* - * Build basic encapsulating token with type and name. - */ + // Build basic encapsulating token with type and name. tokenDeclVar.type = (TokenType)token; token = token.nextToken; if(!(token is TokenName)) @@ -3637,10 +3392,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine tokenDeclVar.name = (TokenName)token; token = token.nextToken; - /* - * If just a ;, there is no explicit initialization value. - * Otherwise, look for an =RVal; expression that has init value. - */ + // If just a ;, there is no explicit initialization value. + // Otherwise, look for an =RVal; expression that has init value. if(token is TokenKwSemi) { token = token.nextToken; @@ -3673,18 +3426,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If doing local vars, each var goes in its own var frame, - * to make sure no code before this point can reference it. - */ + // If doing local vars, each var goes in its own var frame, + // to make sure no code before this point can reference it. if(currentStmtBlock != null) { tokenScript.PushVarFrame(true); } - /* - * Can't be same name already in block. - */ + // Can't be same name already in block. if(!tokenScript.AddVarEntry(tokenDeclVar)) { ErrorMsg(tokenDeclVar, "duplicate variable " + tokenDeclVar.name.val); @@ -3702,9 +3451,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void DoVarInit(TokenDeclVar initFunc, TokenLVal left, TokenRVal init) { - /* - * Make a statement that assigns the initialization value to the variable. - */ + // Make a statement that assigns the initialization value to the variable. TokenStmt stmt; if(init == null) { @@ -3720,11 +3467,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine stmt = tsrv; } - /* - * Add statement to end of initialization function. - * Be sure to execute them in same order as in source - * as some doofus scripts depend on it. - */ + // Add statement to end of initialization function. + // Be sure to execute them in same order as in source + // as some doofus scripts depend on it. Token lastStmt = initFunc.body.statements; if(lastStmt == null) { @@ -3805,17 +3550,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public TokenRVal ParseRVal(ref Token token, Type[] termTokenTypes) { - /* - * Start with pushing the first operand on operand stack. - */ + // Start with pushing the first operand on operand stack. BinOp binOps = null; TokenRVal operands = GetOperand(ref token); if(operands == null) return null; - /* - * Keep scanning until we hit the termination token. - */ + // Keep scanning until we hit the termination token. while(true) { Type tokType = token.GetType(); @@ -3825,59 +3566,47 @@ namespace OpenSim.Region.ScriptEngine.Yengine goto done; } - /* - * Special form: - * is - */ + // Special form: + // is if(token is TokenKwIs) { TokenRValIsType tokenRValIsType = new TokenRValIsType(token); token = token.nextToken; - /* - * Parse the . - */ + // Parse the . tokenRValIsType.typeExp = ParseTypeExp(ref token); if(tokenRValIsType.typeExp == null) return null; - /* - * Replace top operand with result of is - */ + // Replace top operand with result of is tokenRValIsType.rValExp = operands; tokenRValIsType.nextToken = operands.nextToken; operands = tokenRValIsType; - /* - * token points just past so see if it is another operator. - */ + // token points just past so see if it is another operator. continue; } - /* - * Peek at next operator. - */ + // Peek at next operator. BinOp binOp = GetOperator(ref token); if(binOp == null) return null; - /* - * If there are stacked operators of higher or same precedence than new one, - * perform their computation then push result back on operand stack. - * - * higher or same = left-to-right application of operators - * eg, a - b - c becomes (a - b) - c - * - * higher precedence = right-to-left application of operators - * eg, a - b - c becomes a - (b - c) - * - * Now of course, there is some ugliness necessary: - * we want: a - b - c => (a - b) - c so we do 'higher or same' - * but we want: a += b = c => a += (b = c) so we do 'higher only' - * - * binOps is the first operator (or null if only one) - * binOp is the second operator (or first if only one) - */ + // If there are stacked operators of higher or same precedence than new one, + // perform their computation then push result back on operand stack. + // + // higher or same = left-to-right application of operators + // eg, a - b - c becomes (a - b) - c + // + // higher precedence = right-to-left application of operators + // eg, a - b - c becomes a - (b - c) + // + // Now of course, there is some ugliness necessary: + // we want: a - b - c => (a - b) - c so we do 'higher or same' + // but we want: a += b = c => a += (b = c) so we do 'higher only' + // + // binOps is the first operator (or null if only one) + // binOp is the second operator (or first if only one) while(binOps != null) { if(binOps.preced < binOp.preced) @@ -3894,10 +3623,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine binOps = binOps.pop; } - /* - * Handle conditional expression as a special form: - * ? : - */ + // Handle conditional expression as a special form: + // ? : if(binOp.token is TokenKwQMark) { TokenRValCondExpr condExpr = new TokenRValCondExpr(binOp.token); @@ -3910,15 +3637,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine goto done; } - /* - * Push new operator on its stack. - */ + // Push new operator on its stack. binOp.pop = binOps; binOps = binOp; - /* - * Push next operand on its stack. - */ + // Push next operand on its stack. TokenRVal operand = GetOperand(ref token); if(operand == null) return null; @@ -3927,9 +3650,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } done: - /* - * At end of expression, perform any stacked computations. - */ + // At end of expression, perform any stacked computations. while(binOps != null) { TokenRVal result = PerformBinOp((TokenRVal)operands.prevToken, binOps, (TokenRVal)operands); @@ -3938,15 +3659,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine binOps = binOps.pop; } - /* - * There should be exactly one remaining operand on the stack which is our final result. - */ + // There should be exactly one remaining operand on the stack which is our final result. if(operands.prevToken != null) throw new Exception("too many operands"); - /* - * If only one terminator type possible, advance past the terminator. - */ + // If only one terminator type possible, advance past the terminator. if(termTokenTypes.Length == 1) token = token.nextToken; @@ -4028,9 +3745,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenRVal GetOperand(ref Token token) { - /* - * Prefix unary operators (eg ++, --) requiring an L-value. - */ + // Prefix unary operators (eg ++, --) requiring an L-value. if((token is TokenKwIncr) || (token is TokenKwDecr)) { TokenRValAsnPre asnPre = new TokenRValAsnPre(token); @@ -4048,17 +3763,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return asnPre; } - /* - * Get the bulk of the operand, ie, without any of the below suffixes. - */ + // Get the bulk of the operand, ie, without any of the below suffixes. TokenRVal operand = GetOperandNoMods(ref token); if(operand == null) return null; modifiers: - /* - * If followed by '++' or '--', it is post-{in,de}cremented. - */ + // If followed by '++' or '--', it is post-{in,de}cremented. if((token is TokenKwIncr) || (token is TokenKwDecr)) { TokenRValAsnPost asnPost = new TokenRValAsnPost(token); @@ -4073,9 +3784,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return asnPost; } - /* - * If followed by a '.', it is an instance field or instance method reference. - */ + // If followed by a '.', it is an instance field or instance method reference. if(token is TokenKwDot) { token = token.nextToken; @@ -4092,17 +3801,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine goto modifiers; } - /* - * If followed by a '[', it is an array subscript. - */ + // If followed by a '[', it is an array subscript. if(token is TokenKwBrkOpen) { TokenLValArEle tokenLValArEle = new TokenLValArEle(token); token = token.nextToken; - /* - * Parse subscript(s) expression. - */ + // Parse subscript(s) expression. tokenLValArEle.subRVal = ParseRVal(ref token, brkCloseOnly); if(tokenLValArEle.subRVal == null) { @@ -4110,44 +3815,33 @@ namespace OpenSim.Region.ScriptEngine.Yengine return null; } - /* - * See if comma-separated list of values. - */ + // See if comma-separated list of values. TokenRVal subscriptRVals; int numSubscripts = SplitCommaRVals(tokenLValArEle.subRVal, out subscriptRVals); if(numSubscripts > 1) { - - /* - * If so, put the values in an LSL_List object. - */ + // If so, put the values in an LSL_List object. TokenRValList rValList = new TokenRValList(tokenLValArEle); rValList.rVal = subscriptRVals; rValList.nItems = numSubscripts; tokenLValArEle.subRVal = rValList; } - /* - * Either way, save array variable name - * and substitute whole reference for L-value - */ + // Either way, save array variable name + // and substitute whole reference for L-value tokenLValArEle.baseRVal = operand; operand = tokenLValArEle; goto modifiers; } - /* - * If followed by a '(', it is a function/method call. - */ + // If followed by a '(', it is a function/method call. if(token is TokenKwParOpen) { operand = ParseRValCall(ref token, operand); goto modifiers; } - /* - * If 'new' arraytipe '{', it is an array initializer. - */ + // If 'new' arraytipe '{', it is an array initializer. if((token is TokenKwBrcOpen) && (operand is TokenLValSField) && (((TokenLValSField)operand).fieldName.val == "$new") && ((TokenLValSField)operand).baseType.ToString().EndsWith("]")) @@ -4165,9 +3859,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenRVal GetOperandNoMods(ref Token token) { - /* - * Simple unary operators. - */ + // Simple unary operators. if((token is TokenKwSub) || (token is TokenKwTilde) || (token is TokenKwExclam)) @@ -4180,9 +3872,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return PerformUnOp(uop, rVal); } - /* - * Type casting. - */ + // Type casting. if((token is TokenKwParOpen) && (token.nextToken is TokenType) && (token.nextToken.nextToken is TokenKwParClose)) @@ -4195,17 +3885,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new TokenRValCast(type, rVal); } - /* - * Parenthesized expression. - */ + // Parenthesized expression. if(token is TokenKwParOpen) { return ParseRValParen(ref token); } - /* - * Constants. - */ + // Constants. if(token is TokenChar) { TokenRValConst rValConst = new TokenRValConst(token, ((TokenChar)token).val); @@ -4237,9 +3923,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return rValUndef; } - /* - * '<'value,...'>', ie, rotation or vector - */ + // '<'value,...'>', ie, rotation or vector if(token is TokenKwCmpLT) { Token openBkt = token; @@ -4277,9 +3961,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * '['value,...']', ie, list - */ + // '['value,...']', ie, list if(token is TokenKwBrkOpen) { TokenRValList rValList = new TokenRValList(token); @@ -4298,9 +3980,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return rValList; } - /* - * Maybe we have . referencing a static field or method of some type. - */ + // Maybe we have . referencing a static field or method of some type. if((token is TokenType) && (token.nextToken is TokenKwDot) && (token.nextToken.nextToken is TokenName)) { TokenLValSField field = new TokenLValSField(token.nextToken.nextToken); @@ -4310,9 +3990,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return field; } - /* - * Maybe we have 'this' referring to the object of the instance method. - */ + // Maybe we have 'this' referring to the object of the instance method. if(token is TokenKwThis) { if((currentDeclSDType == null) || !(currentDeclSDType is TokenDeclSDTypeClass)) @@ -4326,9 +4004,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return zhis; } - /* - * Maybe we have 'base' referring to a field/method of the extended class. - */ + // Maybe we have 'base' referring to a field/method of the extended class. if(token is TokenKwBase) { if((currentDeclFunc == null) || (currentDeclFunc.sdtClass == null) || !(currentDeclFunc.sdtClass is TokenDeclSDTypeClass)) @@ -4351,11 +4027,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine return baseField; } - /* - * Maybe we have 'new ' saying to create an object instance. - * This ends up generating a call to static function .$new(...) - * whose CIL code is generated by GenerateNewobjBody(). - */ + // Maybe we have 'new ' saying to create an object instance. + // This ends up generating a call to static function .$new(...) + // whose CIL code is generated by GenerateNewobjBody(). if(token is TokenKwNew) { if(!(token.nextToken is TokenType)) @@ -4371,9 +4045,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return field; } - /* - * All we got left is , eg, arg, function, global or local variable reference - */ + // All we got left is , eg, arg, function, global or local variable reference if(token is TokenName) { TokenLValName name = new TokenLValName((TokenName)token, tokenScript.variablesStack); @@ -4381,9 +4053,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return name; } - /* - * Who knows what it is supposed to be? - */ + // Who knows what it is supposed to be? ErrorMsg(token, "invalid operand token"); token = SkipPastSemi(token); return null; @@ -4398,15 +4068,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private TokenRValCall ParseRValCall(ref Token token, TokenRVal meth) { - /* - * Set up basic function call struct with function name. - */ + // Set up basic function call struct with function name. TokenRValCall rValCall = new TokenRValCall(token); rValCall.meth = meth; - /* - * Parse the call parameters, if any. - */ + // Parse the call parameters, if any. token = token.nextToken; if(token is TokenKwParClose) { @@ -4747,24 +4413,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public TokenDeclSDType InstantiateGeneric(string name, TokenType[] genArgs, ScriptReduce reduce) { - /* - * Malloc the struct and give it a name. - */ + // Malloc the struct and give it a name. TokenDeclSDType instdecl = this.MakeBlank(new TokenName(this, name)); - /* - * If the original had an outer type, then so does the new one. - * The outer type will never be a generic prototype, eg, if this - * is 'ValueList' it will always be inside 'Dictionary' - * not 'Dictionary' at this point. - */ + // If the original had an outer type, then so does the new one. + // The outer type will never be a generic prototype, eg, if this + // is 'ValueList' it will always be inside 'Dictionary' + // not 'Dictionary' at this point. if((this.outerSDType != null) && (this.outerSDType.genParams != null)) throw new Exception(); instdecl.outerSDType = this.outerSDType; - /* - * The generic prototype may have stuff like 'public' just before it and we need to copy that too. - */ + // The generic prototype may have stuff like 'public' just before it and we need to copy that too. Token prefix; for(prefix = this; (prefix = prefix.prevToken) != null;) { @@ -4773,108 +4433,78 @@ namespace OpenSim.Region.ScriptEngine.Yengine } this.begToken = prefix.nextToken; - /* - * Splice in a copy of the prefix tokens, just before the beginning token of prototype (this.begToken). - */ + // Splice in a copy of the prefix tokens, just before the beginning token of prototype (this.begToken). while((prefix = prefix.nextToken) != this) { SpliceSourceToken(prefix.CopyToken(prefix)); } - /* - * Splice instantiation (instdecl) in just before the beginning token of prototype (this.begToken). - */ + // Splice instantiation (instdecl) in just before the beginning token of prototype (this.begToken). SpliceSourceToken(instdecl); - /* - * Now for the fun part... Copy the rest of the prototype body to the - * instantiated body, replacing all generic parameter type tokens with - * the corresponding generic argument types. Note that the parameters - * are numbered starting with the outermost so we need the full genArgs - * array. Eg if we are doing 'Converter' from - * 'Dictionary.Converter', any V's are - * numbered [2]. Any [0]s or [1]s should be gone by now but it doesn't - * matter. - */ + // Now for the fun part... Copy the rest of the prototype body to the + // instantiated body, replacing all generic parameter type tokens with + // the corresponding generic argument types. Note that the parameters + // are numbered starting with the outermost so we need the full genArgs + // array. Eg if we are doing 'Converter' from + // 'Dictionary.Converter', any V's are + // numbered [2]. Any [0]s or [1]s should be gone by now but it doesn't + // matter. int index; Token it, pt; TokenDeclSDType innerProto = this; TokenDeclSDType innerInst = instdecl; for(pt = this; (pt = pt.nextToken) != this.endToken;) { - - /* - * Coming across a sub-type's declaration involves a deep copy of the - * declaration token. Fortunately we are early on in parsing, so there - * really isn't much to copy: - * 1) short name is the same, eg, doing List of Dictionary.List is same short name as Dictionary.List - * if generic, eg doing Converter of Dictionary.Converter, we have to manually copy the W as well. - * 2) outerSDType is transformed from Dictionary to Dictionary. - * 3) innerSDTypes is rebuilt when/if we find classes that are inner to this one. - */ + // Coming across a sub-type's declaration involves a deep copy of the + // declaration token. Fortunately we are early on in parsing, so there + // really isn't much to copy: + // 1) short name is the same, eg, doing List of Dictionary.List is same short name as Dictionary.List + // if generic, eg doing Converter of Dictionary.Converter, we have to manually copy the W as well. + // 2) outerSDType is transformed from Dictionary to Dictionary. + // 3) innerSDTypes is rebuilt when/if we find classes that are inner to this one. if(pt is TokenDeclSDType) { - - /* - * Make a new TokenDeclSDType{Class,Delegate,Interface}. - */ + // Make a new TokenDeclSDType{Class,Delegate,Interface}. TokenDeclSDType ptSDType = (TokenDeclSDType)pt; TokenDeclSDType itSDType = ptSDType.MakeBlank(new TokenName(ptSDType.shortName, ptSDType.shortName.val)); - /* - * Set up the transformed outerSDType. - * Eg, if we are creating Enumerator of Dictionary.Enumerator, - * innerProto = Dictionary and innerInst = Dictionary. - */ + // Set up the transformed outerSDType. + // Eg, if we are creating Enumerator of Dictionary.Enumerator, + // innerProto = Dictionary and innerInst = Dictionary. itSDType.outerSDType = innerInst; - /* - * This clone is an inner type of its next outer level. - */ + // This clone is an inner type of its next outer level. reduce.CatalogSDTypeDecl(itSDType); - /* - * We need to manually copy any generic parameters of the class declaration being cloned. - * eg, if we are cloning Converter, this is where the W gets copied. - * Since it is an immutable array of strings, just copy the array pointer, if any. - */ + // We need to manually copy any generic parameters of the class declaration being cloned. + // eg, if we are cloning Converter, this is where the W gets copied. + // Since it is an immutable array of strings, just copy the array pointer, if any. itSDType.genParams = ptSDType.genParams; - /* - * We are now processing tokens for this cloned type declaration. - */ + // We are now processing tokens for this cloned type declaration. innerProto = ptSDType; innerInst = itSDType; - /* - * Splice this clone token in. - */ + // Splice this clone token in. it = itSDType; } - /* - * Check for an generic parameter to substitute out. - */ + // Check for an generic parameter to substitute out. else if((pt is TokenName) && this.genParams.TryGetValue(((TokenName)pt).val, out index)) { it = genArgs[index].CopyToken(pt); } - /* - * Everything else is a simple copy. - */ + // Everything else is a simple copy. else it = pt.CopyToken(pt); - /* - * Whatever we came up with, splice it into the source token stream. - */ + // Whatever we came up with, splice it into the source token stream. SpliceSourceToken(it); - /* - * Maybe we just finished copying an inner type definition. - * If so, remember where it ends and pop it from the stack. - */ + // Maybe we just finished copying an inner type definition. + // If so, remember where it ends and pop it from the stack. if(innerProto.endToken == pt) { innerInst.endToken = it; @@ -4883,9 +4513,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Clone and insert the terminator, either '}' or ';' - */ + // Clone and insert the terminator, either '}' or ';' it = pt.CopyToken(pt); SpliceSourceToken(it); instdecl.endToken = it; @@ -5225,16 +4853,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine if((numVirtFuncs > 0) && (stackedMethods != null)) { - - /* - * Allocate arrays big enough for mine plus type we are extending. - */ + // Allocate arrays big enough for mine plus type we are extending. vDynMeths = new DynamicMethod[numVirtFuncs]; vMethTypes = new Type[numVirtFuncs]; - /* - * Fill in low parts from type we are extending. - */ + // Fill in low parts from type we are extending. if(extends != null) { int n = extends.numVirtFuncs; @@ -5245,10 +4868,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Fill in high parts with my own methods. - * Might also overwrite lower ones with 'override' methods. - */ + // Fill in high parts with my own methods. + // Might also overwrite lower ones with 'override' methods. foreach(StackedMethod sm in stackedMethods) { int i = sm.methVTI; @@ -5294,16 +4915,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine public override void DebString(StringBuilder sb) { - /* - * Don't output if array of some type. - * They will be re-instantiated as referenced by rest of script. - */ + // Don't output if array of some type. + // They will be re-instantiated as referenced by rest of script. if(arrayOfType != null) return; - /* - * This class name and extended/implemented type declaration. - */ + // This class name and extended/implemented type declaration. sb.Append("class "); sb.Append(shortName.val); bool first = true; @@ -5321,17 +4938,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine } sb.Append(" {"); - /* - * Inner type definitions. - */ + // Inner type definitions. foreach(TokenDeclSDType subs in innerSDTypes.Values) { subs.DebString(sb); } - /* - * Members (fields, methods, properties). - */ + // Members (fields, methods, properties). foreach(TokenDeclVar memb in members) { if((memb == instFieldInit) || (memb == staticFieldInit)) @@ -5511,12 +5124,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine { int nArgs; - /* - * This happens when the node was restored via ReadFromFile(). - * It leaves the types in retStr/argStrs for resolution after - * all definitions have been read from the object file in case - * there are forward references. - */ + // This happens when the node was restored via ReadFromFile(). + // It leaves the types in retStr/argStrs for resolution after + // all definitions have been read from the object file in case + // there are forward references. if(retType == null) { retType = MakeTypeToken(retStr); @@ -5531,10 +5142,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Fill in system types from token types. - * Might as well build the signature strings too from token types. - */ + // Fill in system types from token types. + // Might as well build the signature strings too from token types. retSysType = retType.ToSysType(); nArgs = argTypes.Length; @@ -5552,11 +5161,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine argSig = sb.ToString(); wholeSig = retType.ToString() + argSig; - /* - * Now we can create a system delegate type from the given - * return and argument types. Give it an unique name using - * the whole signature string. - */ + // Now we can create a system delegate type from the given + // return and argument types. Give it an unique name using + // the whole signature string. sysType = DelegateCommon.GetType(retSysType, argSysTypes, wholeSig); } @@ -5570,9 +5177,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { TokenDeclSDTypeDelegate decldel; - /* - * Name it after the whole signature string. - */ + // Name it after the whole signature string. StringBuilder sb = new StringBuilder("$inline"); sb.Append(retType.ToString()); sb.Append("("); @@ -5588,10 +5193,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine string inlname = sb.ToString(); if(!inlines.TryGetValue(inlname, out decldel)) { - - /* - * Create the corresponding declaration and link to it - */ + // Create the corresponding declaration and link to it TokenName name = new TokenName(null, inlname); decldel = new TokenDeclSDTypeDelegate(name); decldel.retType = retType; @@ -5860,9 +5462,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { TokenDeclSDTypeDelegate decldel; - /* - * See if we already have a matching declared one cataloged. - */ + // See if we already have a matching declared one cataloged. int nArgs = argTypes.Length; foreach(TokenDeclSDType decl in tokenScript.sdSrcTypesValues) { @@ -5886,9 +5486,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine ; } - /* - * No such luck, create a new anonymous declaration. - */ + // No such luck, create a new anonymous declaration. StringBuilder sb = new StringBuilder("$anondel$"); sb.Append(retType.ToString()); sb.Append("("); @@ -6309,50 +5907,36 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public bool IsFuncTrivial(ScriptCodeGen scg) { - /* - * If not really a function, assume it's a delegate. - * And since we don't really know what functions it can point to, - * assume it can point to a non-trivial one. - */ + // If not really a function, assume it's a delegate. + // And since we don't really know what functions it can point to, + // assume it can point to a non-trivial one. if(retType == null) return false; - /* - * All virtual functions are non-trivial because although a particular - * one might be trivial, it might be overidden with a non-trivial one. - */ + // All virtual functions are non-trivial because although a particular + // one might be trivial, it might be overidden with a non-trivial one. if((sdtFlags & (ScriptReduce.SDT_ABSTRACT | ScriptReduce.SDT_OVERRIDE | ScriptReduce.SDT_VIRTUAL)) != 0) { return false; } - /* - * Check the triviality status of the function. - */ + // Check the triviality status of the function. switch(triviality) { - - /* - * Don't yet know if it is trivial. - * We know at this point it doesn't have any direct looping. - * But if it calls something that has loops, it isn't trivial. - * Otherwise it is trivial. - */ + // Don't yet know if it is trivial. + // We know at this point it doesn't have any direct looping. + // But if it calls something that has loops, it isn't trivial. + // Otherwise it is trivial. case Triviality.unknown: { - - /* - * Mark that we are analyzing this function now. So if there are - * any recursive call loops, that will show that the function is - * non-trivial and the analysis will terminate at that point. - */ + // Mark that we are analyzing this function now. So if there are + // any recursive call loops, that will show that the function is + // non-trivial and the analysis will terminate at that point. triviality = Triviality.analyzing; - /* - * Check out everything else this function calls. If any say they - * aren't trivial, then we say this function isn't trivial. - */ + // Check out everything else this function calls. If any say they + // aren't trivial, then we say this function isn't trivial. foreach(TokenRValCall call in unknownTrivialityCalls) { if(!call.IsRValTrivial(scg, null)) @@ -6362,28 +5946,22 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * All functions called by this function are trivial, and this - * function's code doesn't have any loops, so we can mark this - * function as being trivial. - */ + // All functions called by this function are trivial, and this + // function's code doesn't have any loops, so we can mark this + // function as being trivial. triviality = Triviality.trivial; return true; } - /* - * We already know that it is trivial. - */ + // We already know that it is trivial. case Triviality.trivial: { return true; } - /* - * We either know it is complex or are trying to analyze it already. - * If we are already analyzing it, it means it has a recursive loop - * and we assume those are non-trivial. - */ + // We either know it is complex or are trying to analyze it already. + // If we are already analyzing it, it means it has a recursive loop + // and we assume those are non-trivial. default: return false; } @@ -6450,22 +6028,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine for(Token stmt = body.statements; stmt != null; stmt = stmt.nextToken) { - - /* - * Body of the function should all be arithmetic statements (not eg for loops, if statements etc). - */ + // Body of the function should all be arithmetic statements (not eg for loops, if statements etc). TokenRVal rval = ((TokenStmtRVal)stmt).rVal; - /* - * And the opcode should be a simple assignment operator. - */ + // And the opcode should be a simple assignment operator. TokenRValOpBin rvob = (TokenRValOpBin)rval; if(!(rvob.opcode is TokenKwAssign)) throw new Exception("bad op type " + rvob.opcode.GetType().Name); - /* - * Get field or variable being assigned to. - */ + // Get field or variable being assigned to. TokenDeclVar var = null; TokenRVal left = rvob.rValLeft; if(left is TokenLValIField) @@ -6490,28 +6061,22 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(var == null) throw new Exception("unknown var type " + left.GetType().Name); - /* - * Output flags, type name and bare variable name. - * This should look like a declaration in the 'sb' - * as it is not enclosed in a function. - */ + // Output flags, type name and bare variable name. + // This should look like a declaration in the 'sb' + // as it is not enclosed in a function. var.DebStringSDTFlags(sb); var.type.DebString(sb); sb.Append(' '); sb.Append(var.name.val); - /* - * Maybe it has a non-default initialization value. - */ + // Maybe it has a non-default initialization value. if((var.init != null) && !(var.init is TokenRValInitDef)) { sb.Append(" = "); var.init.DebString(sb); } - /* - * End of declaration statement. - */ + // End of declaration statement. sb.Append(';'); } } @@ -6578,17 +6143,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine { TokenType baseType = baseRVal.GetRValType(scg, null); - /* - * Maybe referencing element of a fixed-dimension array. - */ + // Maybe referencing element of a fixed-dimension array. if((baseType is TokenTypeSDTypeClass) && (((TokenTypeSDTypeClass)baseType).decl.arrayOfType != null)) { return ((TokenTypeSDTypeClass)baseType).decl.arrayOfType; } - /* - * Maybe referencing $idxprop property of script-defined class or interface. - */ + // Maybe referencing $idxprop property of script-defined class or interface. if(baseType is TokenTypeSDTypeClass) { TokenDeclSDTypeClass sdtDecl = ((TokenTypeSDTypeClass)baseType).decl; @@ -6604,17 +6165,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return idxProp.type; } - /* - * Maybe referencing single character of a string. - */ + // Maybe referencing single character of a string. if((baseType is TokenTypeKey) || (baseType is TokenTypeStr)) { return new TokenTypeChar(this); } - /* - * Assume XMR_Array element or extracting element from list. - */ + // Assume XMR_Array element or extracting element from list. if((baseType is TokenTypeArray) || (baseType is TokenTypeList)) { return new TokenTypeObject(this); @@ -6714,19 +6271,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) { - /* - * If getting pointer to instance isn't trivial, then accessing the member isn't trivial either. - */ + // If getting pointer to instance isn't trivial, then accessing the member isn't trivial either. if(!baseRVal.IsRValTrivial(scg, null)) return false; - /* - * Accessing a member of a class depends on the member. - * In the case of a method, this is accessing it as a delegate, not calling it, and - * argsig simply serves as selecting which of possibly overloaded methods to select. - * The case of accessing a property, however, depends on the property implementation, - * as there could be looping inside the property code. - */ + // Accessing a member of a class depends on the member. + // In the case of a method, this is accessing it as a delegate, not calling it, and + // argsig simply serves as selecting which of possibly overloaded methods to select. + // The case of accessing a property, however, depends on the property implementation, + // as there could be looping inside the property code. TokenType baseType = baseRVal.GetRValType(scg, null); if(baseType is TokenTypeSDTypeClass) { @@ -6734,9 +6287,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return (var != null) && var.IsVarTrivial(scg); } - /* - * Accessing the members of anything else (arrays, rotations, vectors) is always trivial. - */ + // Accessing the members of anything else (arrays, rotations, vectors) is always trivial. return true; } @@ -6748,15 +6299,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public override bool IsCallTrivial(ScriptCodeGen scg, TokenType[] argsig) { - /* - * If getting pointer to instance isn't trivial, then calling the method isn't trivial either. - */ + // If getting pointer to instance isn't trivial, then calling the method isn't trivial either. if(!baseRVal.IsRValTrivial(scg, null)) return false; - /* - * Calling a method of a class depends on the method. - */ + // Calling a method of a class depends on the method. TokenType baseType = baseRVal.GetRValType(scg, null); if(baseType is TokenTypeSDTypeClass) { @@ -6764,21 +6311,17 @@ namespace OpenSim.Region.ScriptEngine.Yengine return (var != null) && var.IsFuncTrivial(scg); } - /* - * Calling via a pointer to an interface instance is never trivial. - * (It is really a pointer to an array of delegates). - * We can't tell for this call site whether the actual method being called is trivial or not, - * so we have to assume it isn't. - * ??? We could theoretically check to see if *all* implementations of this method of - * this interface are trivial, then we could conclude that this call is trivial. - */ + // Calling via a pointer to an interface instance is never trivial. + // (It is really a pointer to an array of delegates). + // We can't tell for this call site whether the actual method being called is trivial or not, + // so we have to assume it isn't. + // ??? We could theoretically check to see if *all* implementations of this method of + // this interface are trivial, then we could conclude that this call is trivial. if(baseType is TokenTypeSDTypeInterface) return false; - /* - * Calling a method of anything else (arrays, rotations, vectors) is always trivial. - * Even methods of delegates, such as ".GetArgTypes()" that we may someday do is trivial. - */ + // Calling a method of anything else (arrays, rotations, vectors) is always trivial. + // Even methods of delegates, such as ".GetArgTypes()" that we may someday do is trivial. return true; } @@ -6801,23 +6344,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine public TokenLValName(TokenName name, VarDict stack) : base(name) { - /* - * Save name of variable/method/function/field. - */ + // Save name of variable/method/function/field. this.name = name; - /* - * Save where in the stack it can be looked up. - * If the current stack is for locals, do not allow forward references. - * this allows idiocy like: - * list buttons = [ 1, 2, 3 ]; - * x () { - * list buttons = llList2List (buttons, 0, 1); - * llOwnerSay (llList2CSV (buttons)); - * } - * If it is not locals, allow forward references. - * this allows function X() to call Y() and Y() to call X(). - */ + // Save where in the stack it can be looked up. + // If the current stack is for locals, do not allow forward references. + // this allows idiocy like: + // list buttons = [ 1, 2, 3 ]; + // x () { + // list buttons = llList2List (buttons, 0, 1); + // llOwnerSay (llList2CSV (buttons)); + // } + // If it is not locals, allow forward references. + // this allows function X() to call Y() and Y() to call X(). this.stack = stack.FreezeLocals(); } @@ -6879,22 +6418,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) { - /* - * Accessing a member of a class depends on the member. - * In the case of a method, this is accessing it as a delegate, not calling it, and - * argsig simply serves as selecting which of possibly overloaded methods to select. - * The case of accessing a property, however, depends on the property implementation, - * as there could be looping inside the property code. - */ + // Accessing a member of a class depends on the member. + // In the case of a method, this is accessing it as a delegate, not calling it, and + // argsig simply serves as selecting which of possibly overloaded methods to select. + // The case of accessing a property, however, depends on the property implementation, + // as there could be looping inside the property code. if(baseType is TokenTypeSDTypeClass) { TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); return (var != null) && var.IsVarTrivial(scg); } - /* - * Accessing the fields/methods/properties of anything else (arrays, rotations, vectors) is always trivial. - */ + // Accessing the fields/methods/properties of anything else (arrays, rotations, vectors) is always trivial. return true; } @@ -6906,18 +6441,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public override bool IsCallTrivial(ScriptCodeGen scg, TokenType[] argsig) { - /* - * Calling a static method of a class depends on the method. - */ + // Calling a static method of a class depends on the method. if(baseType is TokenTypeSDTypeClass) { TokenDeclVar var = scg.FindThisMember((TokenTypeSDTypeClass)baseType, fieldName, argsig); return (var != null) && var.IsFuncTrivial(scg); } - /* - * Calling a static method of anything else (arrays, rotations, vectors) is always trivial. - */ + // Calling a static method of anything else (arrays, rotations, vectors) is always trivial. return true; } @@ -7075,9 +6606,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) { - /* - * Build type signature so we select correct overloaded function. - */ + // Build type signature so we select correct overloaded function. if(myArgSig == null) { myArgSig = new TokenType[nArgs]; @@ -7088,9 +6617,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Get the type of the method itself. This should get us a delegate type. - */ + // Get the type of the method itself. This should get us a delegate type. TokenType delType = meth.GetRValType(scg, myArgSig); if(!(delType is TokenTypeSDTypeDelegate)) { @@ -7098,9 +6625,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new TokenTypeVoid(meth); } - /* - * Get the return type from the delegate type. - */ + // Get the return type from the delegate type. return ((TokenTypeSDTypeDelegate)delType).decl.GetRetType(); } @@ -7112,9 +6637,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public override bool IsRValTrivial(ScriptCodeGen scg, TokenType[] argsig) { - /* - * Build type signature so we select correct overloaded function. - */ + // Build type signature so we select correct overloaded function. if(myArgSig == null) { myArgSig = new TokenType[nArgs]; @@ -7125,18 +6648,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Make sure all arguments can be computed trivially. - */ + // Make sure all arguments can be computed trivially. for(Token t = args; t != null; t = t.nextToken) { if(!((TokenRVal)t).IsRValTrivial(scg, null)) return false; } - /* - * See if the function call itself and the function body are trivial. - */ + // See if the function call itself and the function body are trivial. return meth.IsCallTrivial(scg, myArgSig); } @@ -7717,9 +7236,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine public override TokenType GetRValType(ScriptCodeGen scg, TokenType[] argsig) { - /* - * Comparisons and the like always return bool. - */ + // Comparisons and the like always return bool. string opstr = opcode.ToString(); if((opstr == "==") || (opstr == "!=") || (opstr == ">=") || (opstr == ">") || (opstr == "&&") || (opstr == "||") || (opstr == "<=") || (opstr == "<") || @@ -7728,25 +7245,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new TokenTypeBool(opcode); } - /* - * Comma is always type of right-hand operand. - */ + // Comma is always type of right-hand operand. if(opstr == ",") return rValRight.GetRValType(scg, argsig); - /* - * Assignments are always the type of the left-hand operand, - * including stuff like "+=". - */ + // Assignments are always the type of the left-hand operand, + // including stuff like "+=". if(opstr.EndsWith("=")) { return rValLeft.GetRValType(scg, argsig); } - /* - * string+something or something+string is always string. - * except list+something or something+list is always a list. - */ + // string+something or something+string is always string. + // except list+something or something+list is always a list. string lType = rValLeft.GetRValType(scg, argsig).ToString(); string rType = rValRight.GetRValType(scg, argsig).ToString(); if((opstr == "+") && ((lType == "list") || (rType == "list"))) @@ -7759,9 +7270,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new TokenTypeStr(opcode); } - /* - * Everything else depends on both operands. - */ + // Everything else depends on both operands. string key = lType + opstr + rType; BinOpStr binOpStr; if(BinOpStr.defined.TryGetValue(key, out binOpStr)) @@ -8234,7 +7743,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public class TokenStmtBlock: TokenStmt { - public Token statements; // null-terminated list of statements, can also have TokenDeclVar's in here public TokenStmtBlock outerStmtBlock; // next outer stmtBlock or null if top-level, ie, function definition public TokenDeclVar function; // function it is part of @@ -8262,7 +7770,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public class TokenStmtLabel: TokenStmt { - public TokenName name; // the label's name public TokenStmtBlock block; // which block it is defined in public bool hasBkwdRefs = false; @@ -8437,7 +7944,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine public class TokenStmtNull: TokenStmt { - public TokenStmtNull(Token original) : base(original) { } public override void DebString(StringBuilder sb) @@ -8448,7 +7954,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine public class TokenStmtRet: TokenStmt { - public TokenRVal rVal; // null if void public TokenStmtRet(Token original) : base(original) { } @@ -8470,7 +7975,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public class TokenStmtState: TokenStmt { - public TokenName state; // null for default public TokenStmtState(Token original) : base(original) { } @@ -8488,7 +7992,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public class TokenStmtSwitch: TokenStmt { - public TokenRValParen testRVal; // the integer index expression public TokenSwitchCase cases = null; // list of all cases, linked by .nextCase public TokenSwitchCase lastCase = null; // used during reduce to point to last in 'cases' list @@ -8558,7 +8061,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine public class TokenStmtThrow: TokenStmt { - public TokenRVal rVal; // null if rethrow style public TokenStmtThrow(Token original) : base(original) { } @@ -8576,7 +8078,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public class TokenStmtTry: TokenStmt { - public TokenStmtBlock tryStmt; public TokenDeclVar catchVar; // null iff catchStmt is null public TokenStmtBlock catchStmt; // can be null @@ -8620,7 +8121,6 @@ namespace OpenSim.Region.ScriptEngine.Yengine public class TokenStmtWhile: TokenStmt { - public TokenRValParen testRVal; public TokenStmt bodyStmt; diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs index 1bcb5b6935..6c233bc24c 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs @@ -219,9 +219,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { sourceHash = null; - /* - * Now do the tokenization. - */ + // Now do the tokenization. TokenBegin tokenBegin = new TokenBegin(emsg, "", 0, 0); tokenBegin.cameFrom = cameFrom; tokenBegin.saveSource = saveSource; @@ -384,17 +382,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(c == '\n') { - /* - * Increment source line number and set char index of beg of next line. - */ + // Increment source line number and set char index of beg of next line. lineNo++; bolIdx = i + 1; - /* - * Check for '#' lineno filename newline - * lineno is line number of next line in file - * If found, save values and remove tokens from stream - */ + // Check for '#' lineno filename newline + // lineno is line number of next line in file + // If found, save values and remove tokens from stream if((lastToken is TokenStr) && (lastToken.prevToken is TokenInt) && (lastToken.prevToken.prevToken is TokenKwHash)) @@ -407,15 +401,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Skip over whitespace. - */ + // Skip over whitespace. if(c <= ' ') continue; - /* - * Skip over comments. - */ + // Skip over comments. if((i + 2 <= source.Length) && source.Substring(i, 2).Equals("//")) { while((i < source.Length) && (source[i] != '\n')) @@ -440,9 +430,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for numbers. - */ + // Check for numbers. if((c >= '0') && (c <= '9')) { int j = TryParseFloat(i); @@ -459,9 +447,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for quoted strings. - */ + // Check for quoted strings. if(c == '"') { StringBuilder sb = new StringBuilder(); @@ -509,9 +495,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for quoted characters. - */ + // Check for quoted characters. if(c == '\'') { char cb = (char)0; @@ -560,9 +544,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for keywords/names. - */ + // Check for keywords/names. if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c == '_') || (c == '$' && options.dollarsigns)) { int j; @@ -629,9 +611,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Check for option enables. - */ + // Check for option enables. if((c == ';') && (lastToken is TokenName) && (lastToken.prevToken is TokenName) && (strcasecmp(((TokenName)lastToken.prevToken).val, "yoption") == 0)) @@ -669,9 +649,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine continue; } - /* - * Lastly, check for delimeters. - */ + // Lastly, check for delimeters. { int j; int len = 0; @@ -692,9 +670,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Don't know what it is! - */ + // Don't know what it is! TokenError(i, "unknown character '" + c + "'"); } } diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs index 8761e7acae..dd0e5e061e 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTypeCast.cs @@ -177,11 +177,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public static bool IsAssignableFrom(TokenType dstType, TokenType srcType) { - /* - * Do a 'dry run' of the casting operation, discarding any emits and not printing any errors. - * But if the casting tries to print error(s), return false. - * Otherwise assume the cast is allowed and return true. - */ + // Do a 'dry run' of the casting operation, discarding any emits and not printing any errors. + // But if the casting tries to print error(s), return false. + // Otherwise assume the cast is allowed and return true. SCGIAF scg = new SCGIAF(); scg.ok = true; scg._ilGen = migiaf; @@ -305,9 +303,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine string oldString = oldType.ToString(); string newString = newType.ToString(); - /* - * 'key' -> 'bool' is the only time we care about key being different than string. - */ + // 'key' -> 'bool' is the only time we care about key being different than string. if((oldString == "key") && (newString == "bool")) { LSLUnwrap(scg, errorAt, oldType); @@ -316,18 +312,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Treat key and string as same type for all other type casts. - */ + // Treat key and string as same type for all other type casts. if(oldString == "key") oldString = "string"; if(newString == "key") newString = "string"; - /* - * If the types are the same, there is no conceptual casting needed. - * However, there may be wraping/unwraping to/from the LSL wrappers. - */ + // If the types are the same, there is no conceptual casting needed. + // However, there may be wraping/unwraping to/from the LSL wrappers. if(oldString == newString) { if(oldType.ToLSLWrapType() != newType.ToLSLWrapType()) @@ -338,9 +330,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Script-defined classes can be cast up and down the tree. - */ + // Script-defined classes can be cast up and down the tree. if((oldType is TokenTypeSDTypeClass) && (newType is TokenTypeSDTypeClass)) { TokenDeclSDTypeClass oldSDTC = ((TokenTypeSDTypeClass)oldType).decl; @@ -369,11 +359,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine goto illcast; } - /* - * One script-defined interface type cannot be cast to another script-defined interface type, - * unless the old interface declares that it implements the new interface. That proves that - * the underlying object, no matter what type, implements the new interface. - */ + // One script-defined interface type cannot be cast to another script-defined interface type, + // unless the old interface declares that it implements the new interface. That proves that + // the underlying object, no matter what type, implements the new interface. if((oldType is TokenTypeSDTypeInterface) && (newType is TokenTypeSDTypeInterface)) { TokenDeclSDTypeInterface oldDecl = ((TokenTypeSDTypeInterface)oldType).decl; @@ -385,11 +373,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * A script-defined class type can be implicitly cast to a script-defined interface type that it - * implements. The result is an array of delegates that give the class's implementation of the - * various methods defined by the interface. - */ + // A script-defined class type can be implicitly cast to a script-defined interface type that it + // implements. The result is an array of delegates that give the class's implementation of the + // various methods defined by the interface. if((oldType is TokenTypeSDTypeClass) && (newType is TokenTypeSDTypeInterface)) { TokenDeclSDTypeClass oldSDTC = ((TokenTypeSDTypeClass)oldType).decl; @@ -402,13 +388,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * A script-defined interface type can be explicitly cast to a script-defined class type by - * extracting the Target property from element 0 of the delegate array that is the interface - * object and making sure it casts to the correct script-defined class type. - * - * But then only if the class type implements the interface type. - */ + // A script-defined interface type can be explicitly cast to a script-defined class type by + // extracting the Target property from element 0 of the delegate array that is the interface + // object and making sure it casts to the correct script-defined class type. + // + // But then only if the class type implements the interface type. if((oldType is TokenTypeSDTypeInterface) && (newType is TokenTypeSDTypeClass)) { TokenTypeSDTypeInterface oldSDTI = (TokenTypeSDTypeInterface)oldType; @@ -423,17 +407,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * A script-defined interface type can be implicitly cast to object. - */ + // A script-defined interface type can be implicitly cast to object. if((oldType is TokenTypeSDTypeInterface) && (newType is TokenTypeObject)) { return; } - /* - * An object can be explicitly cast to a script-defined interface. - */ + // An object can be explicitly cast to a script-defined interface. if((oldType is TokenTypeObject) && (newType is TokenTypeSDTypeInterface)) { ExplCheck(scg, errorAt, explicitAllowed, oldString, newString); @@ -442,18 +422,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Cast to void is always allowed, such as discarding value from 'i++' or function return value. - */ + // Cast to void is always allowed, such as discarding value from 'i++' or function return value. if(newType is TokenTypeVoid) { scg.ilGen.Emit(errorAt, OpCodes.Pop); return; } - /* - * Cast from undef to object or script-defined type is always allowed. - */ + // Cast from undef to object or script-defined type is always allowed. if((oldType is TokenTypeUndef) && ((newType is TokenTypeObject) || (newType is TokenTypeSDTypeClass) || @@ -462,19 +438,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Script-defined classes can be implicitly cast to objects. - */ + // Script-defined classes can be implicitly cast to objects. if((oldType is TokenTypeSDTypeClass) && (newType is TokenTypeObject)) { return; } - /* - * Script-defined classes can be explicitly cast from objects and other script-defined classes. - * Note that we must manually check that it is the correct SDTypeClass however because as far as - * mono is concerned, all SDTypeClass's are the same. - */ + // Script-defined classes can be explicitly cast from objects and other script-defined classes. + // Note that we must manually check that it is the correct SDTypeClass however because as far as + // mono is concerned, all SDTypeClass's are the same. if((oldType is TokenTypeObject) && (newType is TokenTypeSDTypeClass)) { ExplCheck(scg, errorAt, explicitAllowed, oldString, newString); @@ -483,9 +455,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Delegates can be implicitly cast to/from objects. - */ + // Delegates can be implicitly cast to/from objects. if((oldType is TokenTypeSDTypeDelegate) && (newType is TokenTypeObject)) { return; @@ -496,9 +466,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Some actual conversion is needed, see if it is in table of legal casts. - */ + // Some actual conversion is needed, see if it is in table of legal casts. string key = oldString + " " + newString; if(!legalTypeCasts.TryGetValue(key, out castDelegate)) { @@ -508,11 +476,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine ExplCheck(scg, errorAt, explicitAllowed, oldString, newString); } - /* - * Ok, output cast. But make sure it is in native form without any LSL wrapping - * before passing to our casting routine. Then if caller is expecting an LSL- - * wrapped value on the stack upon return, wrap it up after our casting. - */ + // Ok, output cast. But make sure it is in native form without any LSL wrapping + // before passing to our casting routine. Then if caller is expecting an LSL- + // wrapped value on the stack upon return, wrap it up after our casting. LSLUnwrap(scg, errorAt, oldType); castDelegate(scg, errorAt); LSLWrap(scg, errorAt, newType); diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs index 2561d0290b..a0bc7ba41d 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptVarDict.cs @@ -130,9 +130,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine throw new Exception("var dict is frozen"); } - /* - * Make sure we have a sub-dictionary based on the bare name (ie, no signature) - */ + // Make sure we have a sub-dictionary based on the bare name (ie, no signature) Dictionary typedic; if(!master.TryGetValue(var.name.val, out typedic)) { @@ -140,19 +138,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine master.Add(var.name.val, typedic); } - /* - * See if there is an entry in the sub-dictionary that matches the argument signature. - * Note that fields have null argument lists. - * Methods always have a non-null argument list, even if only 0 entries long. - */ + // See if there is an entry in the sub-dictionary that matches the argument signature. + // Note that fields have null argument lists. + // Methods always have a non-null argument list, even if only 0 entries long. ArgTypes types; types.argTypes = (var.argDecl == null) ? null : KeyTypesToStringTypes(var.argDecl.types); if(typedic.ContainsKey(types)) return false; - /* - * It is unique, add to its name-specific sub-dictionary. - */ + // It is unique, add to its name-specific sub-dictionary. TDVEntry entry; entry.count = ++count; entry.var = var; @@ -175,28 +169,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public VarDict FreezeLocals() { - /* - * If not local var frame, return original frame as is. - * This will allow forward references as the future additions - * will be seen by lookups done in this dictionary. - */ + // If not local var frame, return original frame as is. + // This will allow forward references as the future additions + // will be seen by lookups done in this dictionary. if(!locals) return this; - /* - * If local var frame, return a copy frozen at this point. - * This disallows forward referenes as those future additions - * will not be seen by lookups done in the frozen dictionary. - */ + // If local var frame, return a copy frozen at this point. + // This disallows forward referenes as those future additions + // will not be seen by lookups done in the frozen dictionary. if((frozenLocals == null) || (frozenLocals.count != this.count)) { - - /* - * Make a copy of the current var dictionary frame. - * We copy a reference to the dictionary, and though it may - * contain additions made after this point, those additions - * will have a count .gt. frozen count and will be ignored. - */ + // Make a copy of the current var dictionary frame. + // We copy a reference to the dictionary, and though it may + // contain additions made after this point, those additions + // will have a count .gt. frozen count and will be ignored. frozenLocals = new VarDict(true); frozenLocals.outerVarDict = this.outerVarDict; @@ -205,11 +192,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine frozenLocals.count = this.count; frozenLocals.frozenLocals = frozenLocals; - /* - * Mark it as being frozen. - * - assert fail if any attempt is made to add to it - * - ignore any additions to the dictionary with greater count - */ + // Mark it as being frozen. + // - assert fail if any attempt is made to add to it + // - ignore any additions to the dictionary with greater count frozenLocals.isFrozen = true; } return frozenLocals; @@ -257,46 +242,34 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public TokenDeclVar FindExact(string name, TokenType[] argTypes) { - /* - * Look for list of stuff that matches the given name. - */ + // Look for list of stuff that matches the given name. Dictionary typedic; if(!master.TryGetValue(name, out typedic)) return null; - /* - * Loop through all fields/methods declared by that name, regardless of arg signature. - */ + // Loop through all fields/methods declared by that name, regardless of arg signature. foreach(TDVEntry entry in typedic.Values) { if(entry.count > this.count) continue; TokenDeclVar var = entry.var; - /* - * Get argument types of declaration. - * fields are always null - * methods are always non-null, though may be zero-length - */ + // Get argument types of declaration. + // fields are always null + // methods are always non-null, though may be zero-length TokenType[] declArgs = (var.argDecl == null) ? null : var.argDecl.types; - /* - * Convert any key args to string args. - */ + // Convert any key args to string args. declArgs = KeyTypesToStringTypes(declArgs); - /* - * If both are null, they are signature-less (ie, both are fields), and so match. - */ + // If both are null, they are signature-less (ie, both are fields), and so match. if((declArgs == null) && (argTypes == null)) return var; - /* - * If calling a delegate, it is a match, regardless of delegate arg types. - * If it turns out the arg types do not match, the compiler will give an error - * trying to cast the arguments to the delegate arg types. - * We don't allow overloading same field name with different delegate types. - */ + // If calling a delegate, it is a match, regardless of delegate arg types. + // If it turns out the arg types do not match, the compiler will give an error + // trying to cast the arguments to the delegate arg types. + // We don't allow overloading same field name with different delegate types. if((declArgs == null) && (argTypes != null)) { TokenType fieldType = var.type; @@ -304,15 +277,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine return var; } - /* - * If not both null, no match, keep looking. - */ + // If not both null, no match, keep looking. if((declArgs == null) || (argTypes == null)) continue; - /* - * Both not null, match argument types to make sure we have correct overload. - */ + // Both not null, match argument types to make sure we have correct overload. int i = declArgs.Length; if(i != argTypes.Length) continue; @@ -331,9 +300,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return var; } - /* - * No match. - */ + // No match. return null; } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs index b79722483b..3d0525b7a4 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRArray.cs @@ -108,10 +108,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine { key = FixKey(key); - /* - * Update heap use throwing an exception on failure - * before making any changes to the array. - */ + // Update heap use throwing an exception on failure + // before making any changes to the array. int keysize = HeapTrackerObject.Size(key); int newheapuse = heapUse; object oldval; @@ -125,10 +123,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } heapUse = inst.UpdateHeapUse(heapUse, newheapuse); - /* - * Save new value in array, replacing one of same key if there. - * null means remove the value, ie, script did array[key] = undef. - */ + // Save new value in array, replacing one of same key if there. + // null means remove the value, ie, script did array[key] = undef. if(value != null) { dnary[key] = value; @@ -137,19 +133,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine { dnary.Remove(key); - /* - * Shrink the enumeration array, but always leave at least one element. - */ + // Shrink the enumeration array, but always leave at least one element. if((array != null) && (dnary.Count < array.Length / 2)) { Array.Resize>(ref array, array.Length / 2); } } - /* - * The enumeration array is invalid because the dictionary has been modified. - * Next time a ForEach() call happens, it will repopulate 'array' as elements are retrieved. - */ + // The enumeration array is invalid because the dictionary has been modified. + // Next time a ForEach() call happens, it will repopulate 'array' as elements are retrieved. arrayValid = 0; } @@ -236,29 +228,23 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private bool ForEach(int number) { - /* - * If we don't have any array, we can't have ever done - * any calls here before, so allocate an array big enough - * and set everything else to the beginning. - */ + // If we don't have any array, we can't have ever done + // any calls here before, so allocate an array big enough + // and set everything else to the beginning. if(array == null) { array = new KeyValuePair[dnary.Count]; arrayValid = 0; } - /* - * If dictionary modified since last enumeration, get a new enumerator. - */ + // If dictionary modified since last enumeration, get a new enumerator. if(arrayValid == 0) { enumr = dnary.GetEnumerator(); enumrValid = true; } - /* - * Make sure we have filled the array up enough for requested element. - */ + // Make sure we have filled the array up enough for requested element. while((arrayValid <= number) && enumrValid && enumr.MoveNext()) { if(arrayValid >= array.Length) @@ -268,9 +254,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine array[arrayValid++] = enumr.Current; } - /* - * If we don't have that many elements, return end-of-array status. - */ + // If we don't have that many elements, return end-of-array status. return number < arrayValid; } @@ -281,10 +265,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine public delegate void SendArrayObjDelegate(object graph); public void SendArrayObj(SendArrayObjDelegate sendObj) { - /* - * Set the count then the elements themselves. - * UnfixKey() because sendObj doesn't handle XMRArrayListKeys. - */ + // Set the count then the elements themselves. + // UnfixKey() because sendObj doesn't handle XMRArrayListKeys. sendObj(dnary.Count); foreach(KeyValuePair kvp in dnary) { @@ -304,17 +286,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine { heapUse = inst.UpdateHeapUse(heapUse, EMPTYHEAP); - /* - * Cause any enumeration to refill the array from the sorted dictionary. - * Since it is a sorted dictionary, any enumerations will be in the same - * order as on the sending side. - */ + // Cause any enumeration to refill the array from the sorted dictionary. + // Since it is a sorted dictionary, any enumerations will be in the same + // order as on the sending side. arrayValid = 0; enumrValid = false; - /* - * Fill dictionary. - */ + // Fill dictionary. dnary.Clear(); int count = (int)recvObj(); while(--count >= 0) @@ -375,9 +353,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public int Compare(object x, object y) // IComparer { - /* - * Use short type name (eg, String, Int32, XMRArrayListKey) as most significant part of key. - */ + // Use short type name (eg, String, Int32, XMRArrayListKey) as most significant part of key. string xtn = x.GetType().Name; string ytn = y.GetType().Name; int ctn = String.CompareOrdinal(xtn, ytn); diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs b/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs index 19ff336742..ea306c8119 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMREngXmrTestLs.cs @@ -56,9 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine string outName = null; XMRInstance[] instances; - /* - * Decode command line options. - */ + // Decode command line options. for(int i = indx; i < args.Length; i++) { if(args[i] == "-full") @@ -126,10 +124,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine try { - - /* - * Scan instance list to find those that match selection criteria. - */ + // Scan instance list to find those that match selection criteria. if(!Monitor.TryEnter(m_InstancesDict, 100)) { m_log.Error("[YEngine]: deadlock m_LockedDict=" + m_LockedDict); @@ -151,17 +146,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine Monitor.Exit(m_InstancesDict); } - /* - * Maybe sort by descending CPU time. - */ + // Maybe sort by descending CPU time. if(flagTopCPU) { Array.Sort(instances, CompareInstancesByCPUTime); } - /* - * Print the entries. - */ + // Print the entries. if(!flagFull) { outFile.WriteLine(" ItemID" + @@ -176,15 +167,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine outFile.WriteLine(instances[i].RunTestLs(flagFull)); } - /* - * Print number of scripts that match selection criteria, - * even if we were told to print fewer. - */ + // Print number of scripts that match selection criteria, + // even if we were told to print fewer. outFile.WriteLine("total of {0} script(s)", numScripts); - /* - * If -queues given, print out queue contents too. - */ + // If -queues given, print out queue contents too. if(flagQueues) { LsQueue(outFile, "start", m_StartQueue, args, indx); @@ -204,9 +191,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine int numScripts = 0; XMRInstance[] instances; - /* - * Decode command line options. - */ + // Decode command line options. int i, j; List selargs = new List(args.Length); MethodInfo[] eventmethods = typeof(IEventHandlers).GetMethods(); @@ -271,9 +256,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine OpenSim.Region.ScriptEngine.Shared.EventParams eps = new OpenSim.Region.ScriptEngine.Shared.EventParams(eventname, paramvalues, zeroDetectParams); - /* - * Scan instance list to find those that match selection criteria. - */ + // Scan instance list to find those that match selection criteria. if(!Monitor.TryEnter(m_InstancesDict, 100)) { m_log.Error("[YEngine]: deadlock m_LockedDict=" + m_LockedDict); @@ -296,9 +279,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine Monitor.Exit(m_InstancesDict); } - /* - * Post event to the matching instances. - */ + // Post event to the matching instances. for(i = 0; i < numScripts; i++) { XMRInstance inst = instances[i]; @@ -415,9 +396,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Decode command line options. - */ + // Decode command line options. for(int i = indx; i < args.Length; i++) { if(args[i] == "-all") @@ -437,9 +416,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Scan instance list to find those that match selection criteria. - */ + // Scan instance list to find those that match selection criteria. if(!Monitor.TryEnter(m_InstancesDict, 100)) { m_log.Error("[YEngine]: deadlock m_LockedDict=" + m_LockedDict); @@ -462,9 +439,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine Monitor.Exit(m_InstancesDict); } - /* - * Reset the instances as if someone clicked their "Reset" button. - */ + // Reset the instances as if someone clicked their "Reset" button. for(int i = 0; i < numScripts; i++) { XMRInstance inst = instances[i]; @@ -499,10 +474,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { try { - - /* - * Try to print instance name. - */ + // Try to print instance name. if(InstanceMatchesArgs(inst, args, indx)) { outFile.WriteLine(" " + inst.ItemID.ToString() + " " + inst.m_DescName); @@ -510,10 +482,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } catch(Exception e) { - - /* - * Sometimes there are instances in the queue that are disposed. - */ + // Sometimes there are instances in the queue that are disposed. outFile.WriteLine(" " + inst.ItemID.ToString() + " " + inst.m_DescName + ": " + e.Message); } } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs index a0bb3e0122..b3ff76555a 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstAbstract.cs @@ -473,10 +473,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine { ScriptEventHandler seh; - /* - * CallMode_NORMAL: run event handler from the beginning normally - * CallMode_RESTORE: restore event handler stack from stackFrames - */ + // CallMode_NORMAL: run event handler from the beginning normally + // CallMode_RESTORE: restore event handler stack from stackFrames callMode = (stackFrames == null) ? XMRInstAbstract.CallMode_NORMAL : XMRInstAbstract.CallMode_RESTORE; @@ -723,25 +721,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(o is LSL_Vector) return "vector"; - /* - * A script-defined interface is represented as an array of delegates. - * If that is the case, convert it to the object of the script-defined - * class that is implementing the interface. This should let the next - * step get the script-defined type name of the object. - */ + // A script-defined interface is represented as an array of delegates. + // If that is the case, convert it to the object of the script-defined + // class that is implementing the interface. This should let the next + // step get the script-defined type name of the object. if(o is Delegate[]) o = ((Delegate[])o)[0].Target; - /* - * If script-defined class instance, get the script-defined - * type name. - */ + // If script-defined class instance, get the script-defined + // type name. if(o is XMRSDTypeClObj) return ((XMRSDTypeClObj)o).sdtcClass.longName.val; - /* - * If it's a delegate, maybe we can look up its script-defined type name. - */ + // If it's a delegate, maybe we can look up its script-defined type name. Type ot = o.GetType(); if(o is Delegate) { @@ -750,9 +742,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return os; } - /* - * Don't know what it is, get the C#-level type name. - */ + // Don't know what it is, get the C#-level type name. return ot.ToString(); } @@ -964,17 +954,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine { TokenDeclSDType sdType = inst.m_ObjCode.sdObjTypesIndx[sdtypeindex]; - /* - * If it is a script-defined interface object, convert to the original XMRSDTypeClObj. - */ + // If it is a script-defined interface object, convert to the original XMRSDTypeClObj. if(thrown is Delegate[]) { thrown = ((Delegate[])thrown)[0].Target; } - /* - * If it is a script-defined delegate object, make sure it is an instance of the expected type. - */ + // If it is a script-defined delegate object, make sure it is an instance of the expected type. if(thrown is Delegate) { Type ot = thrown.GetType(); @@ -982,17 +968,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine return (ot == tt) ? thrown : null; } - /* - * If it is a script-defined class object, make sure it is an instance of the expected class. - */ + // If it is a script-defined class object, make sure it is an instance of the expected class. if(thrown is XMRSDTypeClObj) { - - /* - * Step from the object's actual class rootward. - * If we find the requested class along the way, the cast is valid. - * If we run off the end of the root, the cast is not valid. - */ + // Step from the object's actual class rootward. + // If we find the requested class along the way, the cast is valid. + // If we run off the end of the root, the cast is not valid. for(TokenDeclSDTypeClass ac = ((XMRSDTypeClObj)thrown).sdtcClass; ac != null; ac = ac.extends) { if(ac == sdType) @@ -1000,9 +981,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Don't know what it is, assume it is not what caller wants. - */ + // Don't know what it is, assume it is not what caller wants. return null; } @@ -1070,24 +1049,18 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public static void xmrArrayCopy(object srcobj, int srcstart, object dstobj, int dststart, int count) { - /* - * The script writer should only pass us script-defined class objects. - * Throw exception otherwise. - */ + // The script writer should only pass us script-defined class objects. + // Throw exception otherwise. XMRSDTypeClObj srcsdt = (XMRSDTypeClObj)srcobj; XMRSDTypeClObj dstsdt = (XMRSDTypeClObj)dstobj; - /* - * Get the script-visible type name of the arrays, brackets and all. - */ + // Get the script-visible type name of the arrays, brackets and all. string srctypename = srcsdt.sdtcClass.longName.val; string dsttypename = dstsdt.sdtcClass.longName.val; - /* - * The part before the first '[' of each should match exactly, - * meaning the basic data type (eg, float, List) is the same. - * And there must be a '[' in each meaning that it is a script-defined array type. - */ + // The part before the first '[' of each should match exactly, + // meaning the basic data type (eg, float, List) is the same. + // And there must be a '[' in each meaning that it is a script-defined array type. int i = srctypename.IndexOf('['); int j = dsttypename.IndexOf('['); if((i < 0) || (j < 0)) @@ -1095,12 +1068,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine if((i != j) || !srctypename.StartsWith(dsttypename.Substring(0, j))) throw new ArrayTypeMismatchException(srctypename + " vs " + dsttypename); - /* - * The number of brackets must match exactly. - * This permits copying from something like a float[,][] to something like a float[][]. - * But you cannot copy from a float[][] to a float[] or wisa wersa. - * Counting either '[' or ']' would work equally well. - */ + // The number of brackets must match exactly. + // This permits copying from something like a float[,][] to something like a float[][]. + // But you cannot copy from a float[][] to a float[] or wisa wersa. + // Counting either '[' or ']' would work equally well. int srclen = srctypename.Length; int dstlen = dsttypename.Length; int srcjags = 0; @@ -1114,9 +1085,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(dstjags != srcjags) throw new ArrayTypeMismatchException(srctypename + " vs " + dsttypename); - /* - * Perform the copy. - */ + // Perform the copy. Array srcarray = (Array)srcsdt.instVars.iarObjects[0]; Array dstarray = (Array)dstsdt.instVars.iarObjects[0]; Array.Copy(srcarray, srcstart, dstarray, dststart, count); @@ -1131,19 +1100,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public static LSL_List xmrArray2List(object srcar, int start, int count) { - /* - * Get the script-visible type of the array. - * We only do arrays. - */ + // Get the script-visible type of the array. + // We only do arrays. XMRSDTypeClObj array = (XMRSDTypeClObj)srcar; TokenDeclSDTypeClass sdtClass = array.sdtcClass; if(sdtClass.arrayOfRank == 0) throw new InvalidCastException("only do arrays not " + sdtClass.longName.val); - /* - * Validate objects they want to put in the list. - * We can't allow anything funky that OpenSim runtime doesn't expect. - */ + // Validate objects they want to put in the list. + // We can't allow anything funky that OpenSim runtime doesn't expect. Array srcarray = (Array)array.instVars.iarObjects[0]; object[] output = new object[count]; for(int i = 0; i < count; i++) @@ -1179,9 +1144,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine throw new InvalidCastException("invalid element " + i + " type " + src.GetType().Name); } - /* - * Make a list out of that now immutable array. - */ + // Make a list out of that now immutable array. return new LSL_List(output); } @@ -1195,19 +1158,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public static void xmrList2Array(LSL_List srclist, int srcstart, object dstobj, int dststart, int count) { - /* - * Get the script-visible type of the destination. - * We only do arrays. - */ + // Get the script-visible type of the destination. + // We only do arrays. XMRSDTypeClObj dstarray = (XMRSDTypeClObj)dstobj; TokenDeclSDTypeClass sdtClass = dstarray.sdtcClass; if(sdtClass.arrayOfType == null) throw new InvalidCastException("only do arrays not " + sdtClass.longName.val); - /* - * Copy from the immutable array to the mutable array. - * Strip off any LSL wrappers as the script code doesn't expect any. - */ + // Copy from the immutable array to the mutable array. + // Strip off any LSL wrappers as the script code doesn't expect any. object[] srcarr = srclist.Data; Array dstarr = (Array)dstarray.instVars.iarObjects[0]; @@ -1233,18 +1192,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public static string xmrChars2String(object srcar, int start, int count) { - /* - * Make sure they gave us a script-defined array object. - */ + // Make sure they gave us a script-defined array object. XMRSDTypeClObj array = (XMRSDTypeClObj)srcar; TokenDeclSDTypeClass sdtClass = array.sdtcClass; if(sdtClass.arrayOfRank == 0) throw new InvalidCastException("only do arrays not " + sdtClass.longName.val); - /* - * We get a type cast error from mono if they didn't give us a character array. - * But if it is ok, create a string from the requested characters. - */ + // We get a type cast error from mono if they didn't give us a character array. + // But if it is ok, create a string from the requested characters. char[] srcarray = (char[])array.instVars.iarObjects[0]; return new string(srcarray, start, count); } @@ -1259,18 +1214,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public static void xmrString2Chars(string srcstr, int srcstart, object dstobj, int dststart, int count) { - /* - * Make sure they gave us a script-defined array object. - */ + // Make sure they gave us a script-defined array object. XMRSDTypeClObj dstarray = (XMRSDTypeClObj)dstobj; TokenDeclSDTypeClass sdtClass = dstarray.sdtcClass; if(sdtClass.arrayOfType == null) throw new InvalidCastException("only do arrays not " + sdtClass.longName.val); - /* - * We get a type cast error from mono if they didn't give us a character array. - * But if it is ok, copy from the string to the character array. - */ + // We get a type cast error from mono if they didn't give us a character array. + // But if it is ok, copy from the string to the character array. char[] dstarr = (char[])dstarray.instVars.iarObjects[0]; for(int i = 0; i < count; i++) dstarr[i + dststart] = srcstr[i + srcstart]; @@ -1343,12 +1294,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine // '"''"' case '"': - { - --idx; - string val = ParseJSONString(json, ref idx); - dict.SetByKey(keys, val); - break; - } + { + --idx; + string val = ParseJSONString(json, ref idx); + dict.SetByKey(keys, val); + break; + } // true false null case 't': if(json.Substring(idx, 3) != "rue") @@ -1373,12 +1324,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine // otherwise assume it's a number default: - { - --idx; - object val = ParseJSONNumber(json, ref idx); - dict.SetByKey(keys, val); - break; - } + { + --idx; + object val = ParseJSONNumber(json, ref idx); + dict.SetByKey(keys, val); + break; + } } return idx; } @@ -1805,9 +1756,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine { BinaryWriter mow = this.migrateOutWriter; - /* - * Value types (including nulls) are always output directly. - */ + // Value types (including nulls) are always output directly. if(graph == null) { mow.Write((byte)Ser.NULL); @@ -1893,20 +1842,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Script instance pointer is always just that. - */ + // Script instance pointer is always just that. if(graph == this) { mow.Write((byte)Ser.XMRINST); return; } - /* - * Convert lists to object type. - * This is compatible with old migration data and also - * two vars pointing to same list won't duplicate it. - */ + // Convert lists to object type. + // This is compatible with old migration data and also + // two vars pointing to same list won't duplicate it. if(graph is LSL_List) { object[] data = ((LSL_List)graph).Data; @@ -1920,14 +1865,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine graph = oll; } - /* - * If this same exact object was already serialized, - * just output an index telling the receiver to use - * that same old object, rather than creating a whole - * new object with the same values. Also this prevents - * self-referencing objects (like arrays) from causing - * an infinite loop. - */ + // If this same exact object was already serialized, + // just output an index telling the receiver to use + // that same old object, rather than creating a whole + // new object with the same values. Also this prevents + // self-referencing objects (like arrays) from causing + // an infinite loop. int ident; if(this.migrateOutObjects.TryGetValue(graph, out ident)) { @@ -1936,20 +1879,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine return; } - /* - * Object not seen before, save its address with an unique - * ident number that the receiver can easily regenerate. - */ + // Object not seen before, save its address with an unique + // ident number that the receiver can easily regenerate. ident = this.migrateOutObjects.Count; this.migrateOutObjects.Add(graph, ident); - /* - * Now output the object's value(s). - * If the object self-references, the object is alreay entered - * in the dictionary and so the self-reference will just emit - * a DUPREF tag instead of trying to output the whole object - * again. - */ + // Now output the object's value(s). + // If the object self-references, the object is alreay entered + // in the dictionary and so the self-reference will just emit + // a DUPREF tag instead of trying to output the whole object + // again. if(graph is ObjLslList) { mow.Write((byte)Ser.LSLLIST); @@ -2182,43 +2121,43 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new LSL_Key((string)RecvObjValue()); case Ser.LSLLIST: - { - this.migrateInObjects.Add(ident, null); // placeholder - object[] data = (object[])RecvObjValue(); // read data, maybe using another index - LSL_List list = new LSL_List(data); // make LSL-level list - this.migrateInObjects[ident] = list; // fill in slot - return list; - } + { + this.migrateInObjects.Add(ident, null); // placeholder + object[] data = (object[])RecvObjValue(); // read data, maybe using another index + LSL_List list = new LSL_List(data); // make LSL-level list + this.migrateInObjects[ident] = list; // fill in slot + return list; + } case Ser.LSLROT: - { - double x = mir.ReadDouble(); - double y = mir.ReadDouble(); - double z = mir.ReadDouble(); - double w = mir.ReadDouble(); - return new LSL_Rotation(x, y, z, w); - } + { + double x = mir.ReadDouble(); + double y = mir.ReadDouble(); + double z = mir.ReadDouble(); + double w = mir.ReadDouble(); + return new LSL_Rotation(x, y, z, w); + } case Ser.LSLSTR: return new LSL_String((string)RecvObjValue()); case Ser.LSLVEC: - { - double x = mir.ReadDouble(); - double y = mir.ReadDouble(); - double z = mir.ReadDouble(); - return new LSL_Vector(x, y, z); - } + { + double x = mir.ReadDouble(); + double y = mir.ReadDouble(); + double z = mir.ReadDouble(); + return new LSL_Vector(x, y, z); + } case Ser.SYSARRAY: - { - Type eletype = String2SysType(mir.ReadString()); - int length = mir.ReadInt32(); - Array array = Array.CreateInstance(eletype, length); - this.migrateInObjects.Add(ident, array); - for(int i = 0; i < length; i++) - array.SetValue(RecvObjValue(), i); - return array; - } + { + Type eletype = String2SysType(mir.ReadString()); + int length = mir.ReadInt32(); + Array array = Array.CreateInstance(eletype, length); + this.migrateInObjects.Add(ident, array); + for(int i = 0; i < length; i++) + array.SetValue(RecvObjValue(), i); + return array; + } case Ser.SYSBOOL: return mir.ReadBoolean(); @@ -2241,21 +2180,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine return s; case Ser.XMRARRAY: - { - XMR_Array array = new XMR_Array(this); - this.migrateInObjects.Add(ident, array); - array.RecvArrayObj(this.RecvObjValue); - return array; - } + { + XMR_Array array = new XMR_Array(this); + this.migrateInObjects.Add(ident, array); + array.RecvArrayObj(this.RecvObjValue); + return array; + } case Ser.DUPREF: - { - ident = mir.ReadInt32(); - object obj = this.migrateInObjects[ident]; - if(obj is ObjLslList) - obj = new LSL_List(((ObjLslList)obj).objarray); - return obj; - } + { + ident = mir.ReadInt32(); + object obj = this.migrateInObjects[ident]; + if(obj is ObjLslList) + obj = new LSL_List(((ObjLslList)obj).objarray); + return obj; + } case Ser.XMRINST: return this; @@ -2276,29 +2215,29 @@ namespace OpenSim.Region.ScriptEngine.Yengine return clobj; case Ser.SYSERIAL: - { - int rawLength = mir.ReadInt32(); - byte[] rawBytes = mir.ReadBytes(rawLength); - MemoryStream memoryStream = new MemoryStream(rawBytes); - System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bformatter = - new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); - object graph = bformatter.Deserialize(memoryStream); - this.migrateInObjects.Add(ident, graph); - return graph; - } + { + int rawLength = mir.ReadInt32(); + byte[] rawBytes = mir.ReadBytes(rawLength); + MemoryStream memoryStream = new MemoryStream(rawBytes); + System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bformatter = + new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + object graph = bformatter.Deserialize(memoryStream); + this.migrateInObjects.Add(ident, graph); + return graph; + } case Ser.THROWNEX: - { - int rawLength = mir.ReadInt32(); - byte[] rawBytes = mir.ReadBytes(rawLength); - MemoryStream memoryStream = new MemoryStream(rawBytes); - System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bformatter = - new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); - object graph = bformatter.Deserialize(memoryStream); - this.migrateInObjects.Add(ident, graph); - ((ScriptThrownException)graph).thrown = RecvObjValue(); - return graph; - } + { + int rawLength = mir.ReadInt32(); + byte[] rawBytes = mir.ReadBytes(rawLength); + MemoryStream memoryStream = new MemoryStream(rawBytes); + System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bformatter = + new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); + object graph = bformatter.Deserialize(memoryStream); + this.migrateInObjects.Add(ident, graph); + ((ScriptThrownException)graph).thrown = RecvObjValue(); + return graph; + } default: throw new Exception("bad stream code " + code.ToString()); diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs index fb5c75ea26..833211f81d 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstBackend.cs @@ -249,22 +249,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine { lock(m_QueueLock) { - /* - * Say how long to sleep. - */ + // Say how long to sleep. m_SleepUntil = DateTime.UtcNow + TimeSpan.FromMilliseconds(ms); - /* - * Don't wake on any events. - */ + // Don't wake on any events. m_SleepEventMask1 = 0; m_SleepEventMask2 = 0; } - /* - * The compiler follows all calls to llSleep() with a call to CheckRun(). - * So tell CheckRun() to suspend the microthread. - */ + // The compiler follows all calls to llSleep() with a call to CheckRun(). + // So tell CheckRun() to suspend the microthread. suspendOnCheckRunTemp = true; } @@ -327,10 +321,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(callMode == CallMode_NORMAL) goto findevent; - /* - * Stack frame is being restored as saved via CheckRun...(). - * Restore necessary values then jump to __call label to resume processing. - */ + // Stack frame is being restored as saved via CheckRun...(). + // Restore necessary values then jump to __call label to resume processing. sv = RestoreStackFrame("xmrEventDequeue", out callNo); sleepUntil = DateTime.Parse((string)sv[0]); returnMask1 = (int)sv[1]; @@ -353,9 +345,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } throw new ScriptBadCallNoException(callNo); - /* - * Find first event that matches either the return or background masks. - */ + // Find first event that matches either the return or background masks. findevent: Monitor.Enter(m_QueueLock); for(lln = m_EventQueue.First; lln != null; lln = lln.Next) @@ -369,9 +359,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine goto remfromq; } - /* - * Nothing found, sleep while one comes in. - */ + // Nothing found, sleep while one comes in. m_SleepUntil = sleepUntil; m_SleepEventMask1 = mask1; m_SleepEventMask2 = mask2; @@ -382,9 +370,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine CheckRunQuick(); goto checktmo; - /* - * Found one, remove it from queue. - */ + // Found one, remove it from queue. remfromq: m_EventQueue.Remove(lln); if((uint)evc1 < (uint)m_EventCounts.Length) @@ -393,16 +379,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine Monitor.Exit(m_QueueLock); m_InstEHEvent++; - /* - * See if returnable or background event. - */ + // See if returnable or background event. if((((uint)evc1 < (uint)32) && (((returnMask1 >> evc1) & 1) != 0)) || (((uint)evc2 < (uint)32) && (((returnMask2 >> evc2) & 1) != 0))) { - /* - * Returnable event, return its parameters in a list. - * Also set the detect parameters to what the event has. - */ + // Returnable event, return its parameters in a list. + // Also set the detect parameters to what the event has. int plen = evt.Params.Length; object[] plist = new object[plen + 1]; plist[0] = (LSL_Integer)evc1; @@ -421,10 +403,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine return new LSL_List(plist); } - /* - * It is a background event, simply call its event handler, - * then check event queue again. - */ + // It is a background event, simply call its event handler, + // then check event queue again. callNo = 1; __call1: ScriptEventHandler seh = m_ObjCode.scriptEventHandlerTable[stateCode, evc1]; @@ -450,28 +430,21 @@ namespace OpenSim.Region.ScriptEngine.Yengine this.eventCode = saveEventCode; } - /* - * Keep waiting until we find a returnable event or timeout. - */ + // Keep waiting until we find a returnable event or timeout. checktmo: if(DateTime.UtcNow < sleepUntil) goto findevent; - /* - * We timed out, return an empty list. - */ + // We timed out, return an empty list. return emptyList; } finally { if(callMode != CallMode_NORMAL) { - - /* - * Stack frame is being saved by CheckRun...(). - * Save everything we need at the __call labels so we can restore it - * when we need to. - */ + // Stack frame is being saved by CheckRun...(). + // Save everything we need at the __call labels so we can restore it + // when we need to. sv = CaptureStackFrame("xmrEventDequeue", callNo, 9); sv[0] = sleepUntil.ToString(); // needed at __call0,__call1 sv[1] = returnMask1; // needed at __call0,__call1 @@ -606,22 +579,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public override void StateChange() { - /* - * Cancel any llListen()s etc. - * But llSetTimerEvent() should persist. - */ + // Cancel any llListen()s etc. + // But llSetTimerEvent() should persist. object[] timers = m_XMRLSLApi.acm.TimerPlugin.GetSerializationData(m_ItemID); AsyncCommandManager.RemoveScript(m_Engine, m_LocalID, m_ItemID); m_XMRLSLApi.acm.TimerPlugin.CreateFromData(m_LocalID, m_ItemID, UUID.Zero, timers); - /* - * Tell whoever cares which event handlers the new state has. - */ + // Tell whoever cares which event handlers the new state has. m_Part.SetScriptEvents(m_ItemID, GetStateEventFlags(stateCode)); - /* - * Clear out any old events from the queue. - */ + // Clear out any old events from the queue. lock(m_QueueLock) { m_EventQueue.Clear(); diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs index 68ec322061..85867ab820 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstCtor.cs @@ -390,9 +390,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine LoadScriptState(doc); } - /* - * Post event(s) saying what caused the script to start. - */ + // Post event(s) saying what caused the script to start. if(m_PostOnRez) { PostEvent(new EventParams("on_rez", diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs index 8f020ce3bd..0af3d37c3a 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstMisc.cs @@ -74,14 +74,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public void Dispose() { - /* - * Tell script stop executing next time it calls CheckRun(). - */ + // Tell script stop executing next time it calls CheckRun(). suspendOnCheckRunHold = true; - /* - * Don't send us any more events. - */ + // Don't send us any more events. lock(m_RunLock) { if(m_Part != null) @@ -92,10 +88,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Let script methods get garbage collected if no one else is using - * them. - */ + // Let script methods get garbage collected if no one else is using + // them. DecObjCodeRefCount(); } @@ -244,26 +238,20 @@ namespace OpenSim.Region.ScriptEngine.Yengine public static string GetScriptFileName(string scriptBasePath, string filename) { - /* - * Get old path, ie, all files lumped in a single huge directory. - */ + // Get old path, ie, all files lumped in a single huge directory. string oldPath = Path.Combine(scriptBasePath, filename); - /* - * Get new path, ie, files split up based on first 2 chars of name. - */ - // string subdir = filename.Substring (0, 2); - // filename = filename.Substring (2); + // Get new path, ie, files split up based on first 2 chars of name. + // string subdir = filename.Substring (0, 2); + // filename = filename.Substring (2); string subdir = filename.Substring(0, 1); filename = filename.Substring(1); scriptBasePath = Path.Combine(scriptBasePath, subdir); Directory.CreateDirectory(scriptBasePath); string newPath = Path.Combine(scriptBasePath, filename); - /* - * If file exists only in old location, move to new location. - * If file exists in both locations, delete old location. - */ + // If file exists only in old location, move to new location. + // If file exists in both locations, delete old location. if(File.Exists(oldPath)) { if(File.Exists(newPath)) @@ -276,9 +264,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Always return new location. - */ + // Always return new location. return newPath; } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs index 8603fbffef..8ac9794a23 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRInstRun.cs @@ -66,36 +66,27 @@ namespace OpenSim.Region.ScriptEngine.Yengine ScriptEventCode evc = (ScriptEventCode)Enum.Parse(typeof(ScriptEventCode), evt.EventName); - /* - * Put event on end of event queue. - */ + // Put event on end of event queue. bool startIt = false; bool wakeIt = false; lock(m_QueueLock) { bool construct = (m_IState == XMRInstState.CONSTRUCT); - /* - * Ignore event if we don't even have such an handler in any state. - * We can't be state-specific here because state might be different - * by the time this event is dequeued and delivered to the script. - */ + // Ignore event if we don't even have such an handler in any state. + // We can't be state-specific here because state might be different + // by the time this event is dequeued and delivered to the script. if(!construct && // make sure m_HaveEventHandlers is filled in ((uint)evc < (uint)m_HaveEventHandlers.Length) && !m_HaveEventHandlers[(int)evc]) // don't bother if we don't have such a handler in any state return; - - /* - * Not running means we ignore any incoming events. - * But queue if still constructing because m_Running is not yet valid. - */ + // Not running means we ignore any incoming events. + // But queue if still constructing because m_Running is not yet valid. if(!m_Running && !construct) return; - /* - * Only so many of each event type allowed to queue. - */ + // Only so many of each event type allowed to queue. if((uint)evc < (uint)m_EventCounts.Length) { if(evc == ScriptEventCode.timer) @@ -109,29 +100,23 @@ namespace OpenSim.Region.ScriptEngine.Yengine m_EventCounts[(int)evc]++; } - /* - * Put event on end of instance's event queue. - */ + // Put event on end of instance's event queue. LinkedListNode lln = new LinkedListNode(evt); switch(evc) { - /* - * These need to go first. The only time we manually - * queue them is for the default state_entry() and we - * need to make sure they go before any attach() events - * so the heapLimit value gets properly initialized. - */ + // These need to go first. The only time we manually + // queue them is for the default state_entry() and we + // need to make sure they go before any attach() events + // so the heapLimit value gets properly initialized. case ScriptEventCode.state_entry: m_EventQueue.AddFirst(lln); break; - /* - * The attach event sneaks to the front of the queue. - * This is needed for quantum limiting to work because - * we want the attach(NULL_KEY) event to come in front - * of all others so the m_DetachQuantum won't run out - * before attach(NULL_KEY) is executed. - */ + // The attach event sneaks to the front of the queue. + // This is needed for quantum limiting to work because + // we want the attach(NULL_KEY) event to come in front + // of all others so the m_DetachQuantum won't run out + // before attach(NULL_KEY) is executed. case ScriptEventCode.attach: if(evt.Params[0].ToString() == UUID.Zero.ToString()) { @@ -150,11 +135,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine else m_EventQueue.AddBefore(lln2, lln); - /* If we're detaching, limit the qantum. This will also - * cause the script to self-suspend after running this - * event - */ - + // If we're detaching, limit the qantum. This will also + // cause the script to self-suspend after running this + // event m_DetachReady.Reset(); m_DetachQuantum = 100; } @@ -163,31 +146,25 @@ namespace OpenSim.Region.ScriptEngine.Yengine break; - /* - * All others just go on end in the order queued. - */ + // All others just go on end in the order queued. default: m_EventQueue.AddLast(lln); break; } - /* - * If instance is idle (ie, not running or waiting to run), - * flag it to be on m_StartQueue as we are about to do so. - * Flag it now before unlocking so another thread won't try - * to do the same thing right now. - * Dont' flag it if it's still suspended! - */ + // If instance is idle (ie, not running or waiting to run), + // flag it to be on m_StartQueue as we are about to do so. + // Flag it now before unlocking so another thread won't try + // to do the same thing right now. + // Dont' flag it if it's still suspended! if((m_IState == XMRInstState.IDLE) && !m_Suspended) { m_IState = XMRInstState.ONSTARTQ; startIt = true; } - /* - * If instance is sleeping (ie, possibly in xmrEventDequeue), - * wake it up if event is in the mask. - */ + // If instance is sleeping (ie, possibly in xmrEventDequeue), + // wake it up if event is in the mask. if((m_SleepUntil > DateTime.UtcNow) && !m_Suspended) { int evc1 = (int)evc; @@ -198,16 +175,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If transitioned from IDLE->ONSTARTQ, actually go insert it - * on m_StartQueue and give the RunScriptThread() a wake-up. - */ + // If transitioned from IDLE->ONSTARTQ, actually go insert it + // on m_StartQueue and give the RunScriptThread() a wake-up. if(startIt) m_Engine.QueueToStart(this); - /* - * Likewise, if the event mask triggered a wake, wake it up. - */ + // Likewise, if the event mask triggered a wake, wake it up. if(wakeIt) { m_SleepUntil = DateTime.MinValue; @@ -215,20 +188,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * This is called in the script thread to step script until it calls - * CheckRun(). It returns what the instance's next state should be, - * ONSLEEPQ, ONYIELDQ, SUSPENDED or FINISHED. - */ + // This is called in the script thread to step script until it calls + // CheckRun(). It returns what the instance's next state should be, + // ONSLEEPQ, ONYIELDQ, SUSPENDED or FINISHED. public XMRInstState RunOne() { DateTime now = DateTime.UtcNow; m_SliceStart = Util.GetTimeStampMS(); - /* - * If script has called llSleep(), don't do any more until time is - * up. - */ + // If script has called llSleep(), don't do any more until time is up. m_RunOnePhase = "check m_SleepUntil"; if(m_SleepUntil > now) { @@ -236,9 +204,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return XMRInstState.ONSLEEPQ; } - /* - * Also, someone may have called Suspend(). - */ + // Also, someone may have called Suspend(). m_RunOnePhase = "check m_SuspendCount"; if(m_SuspendCount > 0) { @@ -246,11 +212,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine return XMRInstState.SUSPENDED; } - /* - * Make sure we aren't being migrated in or out and prevent that - * whilst we are in here. If migration has it locked, don't call - * back right away, delay a bit so we don't get in infinite loop. - */ + // Make sure we aren't being migrated in or out and prevent that + // whilst we are in here. If migration has it locked, don't call + // back right away, delay a bit so we don't get in infinite loop. m_RunOnePhase = "lock m_RunLock"; if(!Monitor.TryEnter(m_RunLock)) { @@ -264,18 +228,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine CheckRunLockInvariants(true); Exception e = null; - /* - * Maybe it has been Disposed() - */ + // Maybe it has been Disposed() if(m_Part == null) { m_RunOnePhase = "runone saw it disposed"; return XMRInstState.DISPOSED; } - /* - * Do some more of the last event if it didn't finish. - */ + // Do some more of the last event if it didn't finish. if(this.eventCode != ScriptEventCode.None) { lock(m_QueueLock) @@ -297,10 +257,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine e = ResumeEx(); } - /* - * Otherwise, maybe we can dequeue a new event and start - * processing it. - */ + // Otherwise, maybe we can dequeue a new event and start + // processing it. else { m_RunOnePhase = "lock event queue"; @@ -310,14 +268,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine lock(m_QueueLock) { - /* We can't get here unless the script has been resumed - * after creation, then suspended again, and then had - * an event posted to it. We just pretend there is no - * event int he queue and let the normal mechanics - * carry out the suspension. A Resume will handle the - * restarting gracefully. This is taking the easy way - * out and may be improved in the future. - */ + // We can't get here unless the script has been resumed + // after creation, then suspended again, and then had + // an event posted to it. We just pretend there is no + // event int he queue and let the normal mechanics + // carry out the suspension. A Resume will handle the + // restarting gracefully. This is taking the easy way + // out and may be improved in the future. if(m_Suspended) { @@ -336,11 +293,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine evt.EventName); if(evc != ScriptEventCode.attach) { - /* - * This is the case where the attach event - * has completed and another event is queued - * Stop it from running and suspend - */ + // This is the case where the attach event + // has completed and another event is queued + // Stop it from running and suspend m_Suspended = true; m_DetachReady.Set(); m_DetachQuantum = 0; @@ -356,18 +311,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine m_EventCounts[(int)evc]--; } - /* - * If there is no event to dequeue, don't run this script - * until another event gets queued. - */ + // If there is no event to dequeue, don't run this script + // until another event gets queued. if(evt == null) { if(m_DetachQuantum > 0) { - /* - * This will happen if the attach event has run - * and exited with time slice left. - */ + // This will happen if the attach event has run + // and exited with time slice left. m_Suspended = true; m_DetachReady.Set(); m_DetachQuantum = 0; @@ -378,10 +329,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Dequeued an event, so start it going until it either - * finishes or it calls CheckRun(). - */ + // Dequeued an event, so start it going until it either + // finishes or it calls CheckRun(). m_RunOnePhase = "start event handler"; m_DetectParams = evt.DetectParams; m_LastRanAt = now; @@ -391,9 +340,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine m_RunOnePhase = "done running"; m_CPUTime += DateTime.UtcNow.Subtract(now).TotalMilliseconds; - /* - * Maybe it puqued. - */ + // Maybe it puqued. if(e != null) { m_RunOnePhase = "handling exception " + e.Message; @@ -403,9 +350,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine return XMRInstState.FINISHED; } - /* - * If event handler completed, get rid of detect params. - */ + // If event handler completed, get rid of detect params. if(this.eventCode == ScriptEventCode.None) m_DetectParams = null; @@ -417,9 +362,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine Monitor.Exit(m_RunLock); } - /* - * Cycle script through the yield queue and call it back asap. - */ + // Cycle script through the yield queue and call it back asap. m_RunOnePhase = "last return"; return XMRInstState.ONYIELDQ; } @@ -433,10 +376,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine public void CheckRunLockInvariants(bool throwIt) { - /* - * If not executing any event handler, there shouldn't be any saved stack frames. - * If executing an event handler, there should be some saved stack frames. - */ + // If not executing any event handler, there shouldn't be any saved stack frames. + // If executing an event handler, there should be some saved stack frames. bool active = (stackFrames != null); ScriptEventCode ec = this.eventCode; if(((ec == ScriptEventCode.None) && active) || @@ -470,88 +411,67 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private Exception StartEventHandler(ScriptEventCode eventCode, object[] ehArgs) { - /* - * We use this.eventCode == ScriptEventCode.None to indicate we are idle. - * So trying to execute ScriptEventCode.None might make a mess. - */ + // We use this.eventCode == ScriptEventCode.None to indicate we are idle. + // So trying to execute ScriptEventCode.None might make a mess. if(eventCode == ScriptEventCode.None) return new Exception("Can't process ScriptEventCode.None"); - /* - * Silly to even try if there is no handler defined for this event. - */ + // Silly to even try if there is no handler defined for this event. if(((int)eventCode >= 0) && (m_ObjCode.scriptEventHandlerTable[this.stateCode, (int)eventCode] == null)) return null; - /* - * The microthread shouldn't be processing any event code. - * These are assert checks so we throw them directly as exceptions. - */ + // The microthread shouldn't be processing any event code. + // These are assert checks so we throw them directly as exceptions. if(this.eventCode != ScriptEventCode.None) throw new Exception("still processing event " + this.eventCode.ToString()); - /* - * Save eventCode so we know what event handler to run in the microthread. - * And it also marks us busy so we can't be started again and this event lost. - */ + // Save eventCode so we know what event handler to run in the microthread. + // And it also marks us busy so we can't be started again and this event lost. this.eventCode = eventCode; this.ehArgs = ehArgs; - /* - * This calls ScriptUThread.Main() directly, and returns when Main() [indirectly] - * calls Suspend() or when Main() returns, whichever occurs first. - * Setting stackFrames = null means run the event handler from the beginning - * without doing any stack frame restores first. - */ + // This calls ScriptUThread.Main() directly, and returns when Main() [indirectly] + // calls Suspend() or when Main() returns, whichever occurs first. + // Setting stackFrames = null means run the event handler from the beginning + // without doing any stack frame restores first. this.stackFrames = null; return StartEx(); } - /** * @brief There was an exception whilst starting/running a script event handler. * Maybe we handle it directly or just print an error message. */ private void HandleScriptException(Exception e) { - /* - * The script threw some kind of exception that was not caught at - * script level, so the script is no longer running an event handler. - */ + // The script threw some kind of exception that was not caught at + // script level, so the script is no longer running an event handler. eventCode = ScriptEventCode.None; if(e is ScriptDeleteException) { - /* - * Script did something like llRemoveInventory(llGetScriptName()); - * ... to delete itself from the object. - */ + // Script did something like llRemoveInventory(llGetScriptName()); + // ... to delete itself from the object. m_SleepUntil = DateTime.MaxValue; Verbose("[YEngine]: script self-delete {0}", m_ItemID); m_Part.Inventory.RemoveInventoryItem(m_ItemID); } else if(e is ScriptDieException) { - /* - * Script did an llDie() - */ + // Script did an llDie() m_RunOnePhase = "dying..."; m_SleepUntil = DateTime.MaxValue; m_Engine.World.DeleteSceneObject(m_Part.ParentGroup, false); } else if(e is ScriptResetException) { - /* - * Script did an llResetScript(). - */ + // Script did an llResetScript(). m_RunOnePhase = "resetting..."; ResetLocked("HandleScriptResetException"); } else { - /* - * Some general script error. - */ + // Some general script error. SendErrorMessage(e); } return; @@ -570,16 +490,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine msg.Append(m_ItemID); msg.Append('\n'); - /* - * Add exception message. - */ + // Add exception message. string des = e.Message; des = (des == null) ? "" : (": " + des); msg.Append(e.GetType().Name + des + "\n"); - /* - * Tell script owner what to do. - */ + // Tell script owner what to do. msg.Append("Prim: <"); msg.Append(m_Part.Name); msg.Append(">, Script: <"); @@ -595,20 +511,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine msg.Append((int)Math.Floor(pos.Z)); msg.Append(">\nScript must be Reset to re-enable.\n"); - /* - * Display full exception message in log. - */ + // Display full exception message in log. m_log.Info(msg.ToString() + XMRExceptionStackString(e), e); - /* - * Give script owner the stack dump. - */ + // Give script owner the stack dump. msg.Append(XMRExceptionStackString(e)); - /* - * Send error message to owner. - * Suppress internal code stack trace lines. - */ + // Send error message to owner. + // Suppress internal code stack trace lines. string msgst = msg.ToString(); if(!msgst.EndsWith("\n")) msgst += '\n'; @@ -630,10 +540,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine imstr.Append('\n'); } - /* - * Send as instant message in case user not online. - * Code modelled from llInstantMessage(). - */ + // Send as instant message in case user not online. + // Code modelled from llInstantMessage(). IMessageTransferModule transferModule = m_Engine.World.RequestModuleInterface(); if(transferModule != null) { @@ -661,10 +569,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine }); } - /* - * Say script is sleeping for a very long time. - * Reset() is able to cancel this sleeping. - */ + // Say script is sleeping for a very long time. + // Reset() is able to cancel this sleeping. m_SleepUntil = DateTime.MaxValue; } @@ -678,18 +584,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine XMRInstState iState = m_IState; switch(iState) { - /* - * If it's really being constructed now, that's about as reset as we get. - */ + // If it's really being constructed now, that's about as reset as we get. case XMRInstState.CONSTRUCT: return; - /* - * If it's idle, that means it is ready to receive a new event. - * So we lock the event queue to prevent another thread from taking - * it out of idle, verify that it is still in idle then transition - * it to resetting so no other thread will touch it. - */ + // If it's idle, that means it is ready to receive a new event. + // So we lock the event queue to prevent another thread from taking + // it out of idle, verify that it is still in idle then transition + // it to resetting so no other thread will touch it. case XMRInstState.IDLE: lock(m_QueueLock) { @@ -701,12 +603,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine } goto checkstate; - /* - * If it's on the start queue, that means it is about to dequeue an - * event and start processing it. So we lock the start queue so it - * can't be started and transition it to resetting so no other thread - * will touch it. - */ + // If it's on the start queue, that means it is about to dequeue an + // event and start processing it. So we lock the start queue so it + // can't be started and transition it to resetting so no other thread + // will touch it. case XMRInstState.ONSTARTQ: lock(m_Engine.m_StartQueue) { @@ -719,10 +619,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } goto checkstate; - /* - * If it's running, tell CheckRun() to suspend the thread then go back - * to see what it got transitioned to. - */ + // If it's running, tell CheckRun() to suspend the thread then go back + // to see what it got transitioned to. case XMRInstState.RUNNING: suspendOnCheckRunHold = true; lock(m_QueueLock) @@ -730,11 +628,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } goto checkstate; - - /* - * If it's sleeping, remove it from sleep queue and transition it to - * resetting so no other thread will touch it. - */ + // If it's sleeping, remove it from sleep queue and transition it to + // resetting so no other thread will touch it. case XMRInstState.ONSLEEPQ: lock(m_Engine.m_SleepQueue) { @@ -747,19 +642,15 @@ namespace OpenSim.Region.ScriptEngine.Yengine } goto checkstate; - /* - * It was just removed from the sleep queue and is about to be put - * on the yield queue (ie, is being woken up). - * Let that thread complete transition and try again. - */ + // It was just removed from the sleep queue and is about to be put + // on the yield queue (ie, is being woken up). + // Let that thread complete transition and try again. case XMRInstState.REMDFROMSLPQ: Sleep(10); goto checkstate; - /* - * If it's yielding, remove it from yield queue and transition it to - * resetting so no other thread will touch it. - */ + // If it's yielding, remove it from yield queue and transition it to + // resetting so no other thread will touch it. case XMRInstState.ONYIELDQ: lock(m_Engine.m_YieldQueue) { @@ -772,52 +663,38 @@ namespace OpenSim.Region.ScriptEngine.Yengine } goto checkstate; - /* - * If it just finished running something, let that thread transition it - * to its next state then check again. - */ + // If it just finished running something, let that thread transition it + // to its next state then check again. case XMRInstState.FINISHED: Sleep(10); goto checkstate; - /* - * If it's disposed, that's about as reset as it gets. - */ + // If it's disposed, that's about as reset as it gets. case XMRInstState.DISPOSED: return; - /* - * Some other thread is already resetting it, let it finish. - */ + // Some other thread is already resetting it, let it finish. + case XMRInstState.RESETTING: return; - default: throw new Exception("bad state"); } - /* - * This thread transitioned the instance to RESETTING so reset it. - */ + // This thread transitioned the instance to RESETTING so reset it. lock(m_RunLock) { CheckRunLockInvariants(true); - /* - * No other thread should have transitioned it from RESETTING. - */ + // No other thread should have transitioned it from RESETTING. if(m_IState != XMRInstState.RESETTING) throw new Exception("bad state"); - /* - * Mark it idle now so it can get queued to process new stuff. - */ + // Mark it idle now so it can get queued to process new stuff. m_IState = XMRInstState.IDLE; - /* - * Reset everything and queue up default's start_entry() event. - */ + // Reset everything and queue up default's start_entry() event. ClearQueue(); ResetLocked("external Reset"); @@ -886,16 +763,12 @@ namespace OpenSim.Region.ScriptEngine.Yengine m_SleepUntil = DateTime.MinValue; // not doing llSleep() m_ResetCount++; // has been reset once more - /* - * Tell next call to 'default state_entry()' to reset all global - * vars to their initial values. - */ + // Tell next call to 'default state_entry()' to reset all global + // vars to their initial values. doGblInit = true; - /* - * Set script to 'default' state and queue call to its - * 'state_entry()' event handler. - */ + // Set script to 'default' state and queue call to its + // 'state_entry()' event handler. m_RunOnePhase = "ResetLocked: posting default:state_entry() event"; stateCode = 0; m_Part.SetScriptEvents(m_ItemID, GetStateEventFlags(0)); @@ -903,9 +776,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine zeroObjectArray, zeroDetectParams)); - /* - * Tell CheckRun() to let script run. - */ + // Tell CheckRun() to let script run. suspendOnCheckRunHold = false; suspendOnCheckRunTemp = false; m_RunOnePhase = "ResetLocked: reset complete"; @@ -955,9 +826,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine } m_CheckRunPhase = "entered"; - /* - * Stay stuck in this loop as long as something wants us suspended. - */ + // Stay stuck in this loop as long as something wants us suspended. while(suspendOnCheckRunHold || suspendOnCheckRunTemp) { m_CheckRunPhase = "top of while"; @@ -997,10 +866,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine m_CheckRunPhase = "returning"; - /* - * Upon return from CheckRun() it should always be the case that the script is - * going to process calls normally, neither saving nor restoring stack frame state. - */ + // Upon return from CheckRun() it should always be the case that the script is + // going to process calls normally, neither saving nor restoring stack frame state. if(callMode != CallMode_NORMAL) throw new Exception("bad callMode " + callMode); } diff --git a/OpenSim/Region/ScriptEngine/YEngine/XMRObjectTokens.cs b/OpenSim/Region/ScriptEngine/YEngine/XMRObjectTokens.cs index d3ae1654e8..76762dd0d8 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/XMRObjectTokens.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/XMRObjectTokens.cs @@ -501,10 +501,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ public override void EndMethod() { - /* - * Convert CIL code to primitive statements. - * There are a bunch of labels and internal code such as call stack save restore. - */ + // Convert CIL code to primitive statements. + // There are a bunch of labels and internal code such as call stack save restore. topBlock = new OTStmtBlock(); blockstack.Push(topBlock); for(LinkedListNode link = cilinstrs.First; link != null; link = link.Next) @@ -512,10 +510,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine link.Value.BuildStatements(this, link); } - /* - * Strip out stuff we don't want, such as references to callMode. - * This strips out stack frame capture and restore code. - */ + // Strip out stuff we don't want, such as references to callMode. + // This strips out stack frame capture and restore code. topBlock.StripStuff(null); // including a possible final return statement @@ -532,22 +528,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /** - * At this point, all behind-the-scenes references are removed except - * that the do/for/if/while blocks are represented by OTStmtCont-style - * if/jumps. So try to convert them to the higher-level structures. - */ + // At this point, all behind-the-scenes references are removed except + // that the do/for/if/while blocks are represented by OTStmtCont-style + // if/jumps. So try to convert them to the higher-level structures. topBlock.DetectDoForIfWhile(null); - /* - * Final strip to get rid of unneeded @forbreak_; labels and the like. - */ + // Final strip to get rid of unneeded @forbreak_; labels and the like. topBlock.StripStuff(null); - /* - * Build reference counts so we don't output unneeded declarations, - * especially temps and internal variables. - */ + // Build reference counts so we don't output unneeded declarations, + // especially temps and internal variables. foreach(OTLocal local in locals.Values) { local.nlclreads = 0; @@ -564,10 +554,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * Strip the $n off of local vars that are not ambiguous. - * Make sure they don't mask globals and arguments as well. - */ + // Strip the $n off of local vars that are not ambiguous. + // Make sure they don't mask globals and arguments as well. Dictionary namecounts = new Dictionary(); foreach(Dictionary varnames in scriptObjCode.globalVarNames.Values) { @@ -607,9 +595,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine local.name = name; } - /* - * Print out result. - */ + // Print out result. if(method.Name == _globalvarinit) { GlobalsDump(); @@ -725,10 +711,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine */ private void GlobalsDump() { - /* - * Scan $globalvarinit(). It should only have global var assignments in it. - * Also gather up list of variables it initializes. - */ + // Scan $globalvarinit(). It should only have global var assignments in it. + // Also gather up list of variables it initializes. bool badinit = false; Dictionary inittypes = new Dictionary(); foreach(OTStmt stmt in topBlock.blkstmts) @@ -748,11 +732,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine inittypes[globalop.PrintableString] = ""; } - /* - * Scan through list of all global variables in the script. - * Output declarations for those what don't have any init statement for them. - * Save the type for those that do have init statements. - */ + // Scan through list of all global variables in the script. + // Output declarations for those what don't have any init statement for them. + // Save the type for those that do have init statements. bool first = true; foreach(string iartypename in scriptObjCode.globalVarNames.Keys) { @@ -778,10 +760,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine } } - /* - * If $globalvarinit() has anything bad in it, output it as a function. - * Otherwise, output it as a series of global declarations with init values. - */ + // If $globalvarinit() has anything bad in it, output it as a function. + // Otherwise, output it as a series of global declarations with init values. if(badinit) { MethodDump(); @@ -809,19 +789,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine { string indent; - /* - * Event handlers don't have an argument list as such in the original - * code. Instead they have a series of assignments from ehargs[] to - * local variables. So make those local variables look like they are - * an argument list. - */ + // Event handlers don't have an argument list as such in the original + // code. Instead they have a series of assignments from ehargs[] to + // local variables. So make those local variables look like they are + // an argument list. int i = method.Name.IndexOf(' '); if(i >= 0) { - - /* - * Maybe we have to output the state name. - */ + // Maybe we have to output the state name. string statename = method.Name.Substring(0, i); string eventname = method.Name.Substring(++i); @@ -844,10 +819,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine twout.Write('\n'); } - /* - * Output event name and argument list. - * Remove from locals list so they don't print below. - */ + // Output event name and argument list. + // Remove from locals list so they don't print below. twout.Write('\n' + INDENT + eventname + " ("); MethodInfo meth = typeof(IEventHandlers).GetMethod(eventname); i = 0; @@ -873,35 +846,26 @@ namespace OpenSim.Region.ScriptEngine.Yengine } twout.Write(')'); - /* - * Indent method body by 4 spaces. - */ + // Indent method body by 4 spaces. indent = INDENT; } else { - - /* - * Maybe need to close out previous state. - */ + // Maybe need to close out previous state. if(laststate != null) { twout.Write("\n}"); laststate = null; } - /* - * Output blank line and return type (if any). - */ + // Output blank line and return type (if any). twout.Write("\n\n"); if(method.ReturnType != typeof(void)) { twout.Write(AbbrType(method.ReturnType) + ' '); } - /* - * Output method name and argument list. - */ + // Output method name and argument list. int j = method.Name.IndexOf('('); if(j < 0) { @@ -926,15 +890,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine twout.Write(')'); } - /* - * Don't indent method body at all. - */ + // Don't indent method body at all. indent = ""; } - /* - * Output local variable declarations. - */ + // Output local variable declarations. twout.Write('\n' + indent + '{'); bool didOne = false; foreach(OTLocal local in locals.Values) @@ -945,9 +905,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine if(didOne) twout.Write('\n'); - /* - * Output statements. - */ + // Output statements. if(topBlock.blkstmts.Count == 0) { twout.Write(" }"); @@ -1634,22 +1592,19 @@ namespace OpenSim.Region.ScriptEngine.Yengine { switch(opCode.ToString()) { - - /* - * We don't handle non-empty stack at branch points. - * - * So handle this case specially: - * - * dup - * ldc.i4.0 - * bge.s llAbstemp << we are here - * neg - * llAbstemp: - * - * becomes: - * - * call llAbs - */ + // We don't handle non-empty stack at branch points. + // + // So handle this case specially: + // + // dup + // ldc.i4.0 + // bge.s llAbstemp << we are here + // neg + // llAbstemp: + // + // becomes: + // + // call llAbs case "bge.s": { OTOpnd rite = decompile.opstack.Pop(); // alleged zero @@ -2103,50 +2058,33 @@ namespace OpenSim.Region.ScriptEngine.Yengine public static OTOpnd Make(OTOpnd array, OTOpnd index, bool byref, OTDecompile decompile) { - /* - * arg$0.glblVars.iar[] is a reference to a global variable - * likewise so is __xmrinst.glblVars.iar[] - */ + // arg$0.glblVars.iar[] is a reference to a global variable + // likewise so is __xmrinst.glblVars.iar[] if((array is OTOpndField) && (index is OTOpndInt)) { - - /* - * arrayfield = (arg$0.glblVars).iar - * arrayfieldobj = arg$0.glblVars - * iartypename = iar - */ + // arrayfield = (arg$0.glblVars).iar + // arrayfieldobj = arg$0.glblVars + // iartypename = iar OTOpndField arrayfield = (OTOpndField)array; OTOpnd arrayfieldobj = arrayfield.obj; string iartypename = arrayfield.field.Name; - /* - * See if they are what they are supposed to be. - */ + // See if they are what they are supposed to be. if((arrayfieldobj is OTOpndField) && iartypename.StartsWith("iar")) { - - /* - * arrayfieldobjfield = arg$0.glblVars - */ + // arrayfieldobjfield = arg$0.glblVars OTOpndField arrayfieldobjfield = (OTOpndField)arrayfieldobj; - /* - * See if the parts are what they are supposed to be. - */ + // See if the parts are what they are supposed to be. if(IsArg0OrXMRInst(arrayfieldobjfield.obj) && (arrayfieldobjfield.field.Name == "glblVars")) { - - /* - * Everything matches up, make a global variable instead of an array reference. - */ + // Everything matches up, make a global variable instead of an array reference. return new OTOpndGlobal(iartypename, ((OTOpndInt)index).value, byref, decompile.scriptObjCode); } } } - /* - * Other array reference. - */ + // Other array reference. OTOpndArrayElem it = new OTOpndArrayElem(); it.array = array; it.index = index; @@ -3097,17 +3035,13 @@ namespace OpenSim.Region.ScriptEngine.Yengine return false; int listsize = ((OTOpndInt)storeval.index).value; - /* - * Good chance of having list initializer, malloc an object to hold it. - */ + // Good chance of having list initializer, malloc an object to hold it. OTOpndListIni it = new OTOpndListIni(); it.values = new OTOpnd[listsize]; - /* - * There should be exactly listsize statements following that of the form: - * dup$[] = bla - * If so, save the bla values in the values[] array. - */ + // There should be exactly listsize statements following that of the form: + // dup$[] = bla + // If so, save the bla values in the values[] array. LinkedListNode vallink = link; for(int i = 0; i < listsize; i++) { @@ -3129,10 +3063,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine it.values[i] = valstore.value; } - /* - * The next statement should have a 'newobj list (dup$)' in it somewhere - * that we want to replace with 'it'. - */ + // The next statement should have a 'newobj list (dup$)' in it somewhere + // that we want to replace with 'it'. ConstructorInfo protoctor = typeof(LSL_List).GetConstructor(new Type[] { typeof(object[]) }); OTOpnd[] protoargs = new OTOpnd[] { storevar }; OTOpnd proto = OTOpndNewobj.Make(protoctor, protoargs); @@ -3140,9 +3072,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine vallink = vallink.Next; bool rc = vallink.Value.ReplaceOperand(proto, it); - /* - * If successful, delete 'dup$n =' and all 'dup$n[i] =' statements. - */ + // If successful, delete 'dup$n =' and all 'dup$n[i] =' statements. if(rc) { do