private static void clearFuncCallMemory(FunctionCall theFuncCall)
        {
            if (theFuncCall.returnCalculations == null)
            {
                return;
            }

            foreach (Logic[] l in theFuncCall.returnCalculations)
            {
                searchLogicOrder(l);
            }

            theFuncCall.resetCalculations();
        }
示例#2
0
        private static bool insertReturnValueIntoFuncCall(FunctionCall theFuncCall, int lineNumber, Variable returnVar)
        {
            if (theFuncCall.returnCalculations == null)
            {
                return(false);
            }

            foreach (Logic[] l in theFuncCall.returnCalculations)
            {
                if (searchInLogicOrder(l, lineNumber, returnVar))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#3
0
        private static bool insertReturnValueIntoFuncCallExpect(FunctionCall theFuncCall, int lineNumber, Logic targetLogic)
        {
            if (theFuncCall.returnCalculations == null)
            {
                return(false);
            }


            foreach (Logic[] l in theFuncCall.returnCalculations)
            {
                if (searchInLogicOrderExpect(l, lineNumber, targetLogic))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#4
0
        // Could be optimized so that we save left, right and operators for next comparision so we do not need to parse every loop instance!


        public static Logic parseDefStatement(Logic[] logicOrder, int lineNumber, Scope currentScope)
        {
            FunctionCall theFuncCall = logicOrder [1] as FunctionCall;

            if (SpecialWordParser.isKeyWord(theFuncCall.name))
            {
                ErrorMessage.sendErrorMessage(lineNumber, string.Format("\"{0}\" är ett Python keyword, du kan därför inte döpa en funktion till det", theFuncCall.name));
            }

            int          paraAmount = (FunctionParser.getParameterAmount(theFuncCall.parameter, lineNumber, currentScope));
            UserFunction theFunc    = new UserFunction(theFuncCall.name, (logicOrder [0] as ScopeStarter).getTargetScope(), paraAmount);

            currentScope.scopeFunctions.addFunction(theFunc);

            theFunc.inputParameterNames = FunctionParser.getParameterNames(theFuncCall.parameter, lineNumber, currentScope);

            return(new DefStatement());
        }
示例#5
0
        public static Variable[] getValueOfParameters(string trimmedPara, Function calledFunction, int lineNumber, Scope currentScope, FunctionCall theFuncCall)
        {
            string[] words = WordParser.parseWords(trimmedPara);

            if (words.Length != 0)
            {
                Logic[]        logicOrder   = WordsToLogicParser.determineLogicFromWords(words, lineNumber, currentScope);
                List <Logic[]> packedLogics = convertIntoParameterLogic(words, logicOrder, lineNumber);
                theFuncCall.setReturnCalculations(packedLogics);

                if (packedLogics != null)
                {
                    return(parseInputVariables(packedLogics, lineNumber, calledFunction, currentScope));
                }
            }

            return(new Variable[0]);
        }