Example #1
0
        private TES5FunctionCodeBlock GetGetArmorRatingOfWornFormFunctionCodeBlock(ITES5Referencer calledOn, TES5CodeScope codeScope)
        {
            TES5FunctionCodeBlock  functionCodeBlock = new TES5FunctionCodeBlock(new TES5FunctionScope(functionName), TES5CodeScopeFactory.CreateCodeScope(codeScope.LocalScope), TES5BasicType.T_INT, false, false);
            TES5SignatureParameter slotMaskParameter = new TES5SignatureParameter("slotMask", TES5BasicType.T_INT, true);

            functionCodeBlock.FunctionScope.AddParameter(slotMaskParameter);
            TES5ObjectCall    getWornForm      = GetGetWornFormObjectCall(calledOn, TES5ReferenceFactory.CreateReferenceToVariableOrProperty(slotMaskParameter));
            TES5LocalVariable wornFormVariable = new TES5LocalVariable("wornForm", TES5BasicType.T_ARMOR);

            functionCodeBlock.CodeScope.AddVariable(wornFormVariable);
            TES5Reference wornFormVariableReference = TES5ReferenceFactory.CreateReferenceToVariableOrProperty(wornFormVariable);

            functionCodeBlock.AddChunk(TES5VariableAssignationFactory.CreateAssignation(wornFormVariableReference, getWornForm));
            functionCodeBlock.AddChunk(new TES5Return(objectCallFactory.CreateObjectCall(wornFormVariableReference, "GetArmorRating")));
            return(functionCodeBlock);
        }
Example #2
0
        /*
         *  The stage ID
         *  List of integers describing targets being enabled or disabled for given stage
         */
        public TES5FunctionCodeBlock CreateEnclosedFragment(TES5GlobalScope globalScope, int stageId, List <int> stageMap)
        {
            string                fragmentName  = "Fragment_" + stageId.ToString();
            TES5FunctionScope     functionScope = TES5FragmentFunctionScopeFactory.CreateFromFragmentType(fragmentName, TES5FragmentType.T_QF);
            TES5CodeScope         codeScope     = TES5CodeScopeFactory.CreateCodeScopeRoot(functionScope);
            TES5FunctionCodeBlock codeBlock     = new TES5FunctionCodeBlock(functionScope, codeScope, new TES5VoidType());
            List <ITES5CodeChunk> chunks        = this.GenerateObjectiveHandling(codeBlock, globalScope, stageMap);

            foreach (var chunk in chunks)
            {
                codeBlock.AddChunk(chunk);
            }
            return(codeBlock);
        }
        public TES5FunctionCodeBlock CreateFragment(TES5FragmentType fragmentType, string fragmentName, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope, TES4CodeChunks chunks)
        {
            TES5FunctionScope     fragmentLocalScope = TES5FragmentFunctionScopeFactory.CreateFromFragmentType(fragmentName, fragmentType);
            TES5FunctionCodeBlock function           = new TES5FunctionCodeBlock(fragmentLocalScope, TES5CodeScopeFactory.CreateCodeScopeRoot(fragmentLocalScope), TES5VoidType.Instance, false, fragmentType == TES5FragmentType.T_QF || fragmentType == TES5FragmentType.T_TIF);

            foreach (var codeChunk in chunks)
            {
                TES5CodeChunkCollection codeChunks = this.codeChunkFactory.CreateCodeChunk(codeChunk, function.CodeScope, globalScope, multipleScriptsScope);
                foreach (var newCodeChunk in codeChunks)
                {
                    function.AddChunk(newCodeChunk);
                }
            }
            return(function);
        }