예제 #1
0
        protected override Variable Evaluate(ParsingScript script)
        {
            List <Variable> args = script.GetFunctionArgs();

            Utils.CheckArgs(args.Count, 1, m_name, true);

            string filename = args[0].AsString();
            string pathname = script.GetFilePath(filename);

            EncodeFileFunction.EncodeDecode(pathname, false);
            ParsingScript tempScript    = script.GetIncludeFileScript(filename);
            string        includeScript = tempScript.String;

            EncodeFileFunction.EncodeDecode(pathname, true);

            Variable result = null;

            if (script.Debugger != null)
            {
                result = script.Debugger.StepInIncludeIfNeeded(tempScript).Result;
            }

            while (tempScript.Pointer < includeScript.Length)
            {
                result = tempScript.Execute();
                tempScript.GoToNextStatement();
            }
            return(result == null ? Variable.EmptyInstance : result);
        }
예제 #2
0
        protected override Variable Evaluate(ParsingScript script)
        {
            var labelName = Utils.GetToken(script, Constants.TOKEN_SEPARATION);

            Dictionary <string, int> labels;

            if (script.AllLabels == null || script.LabelToFile == null |
                !script.AllLabels.TryGetValue(script.FunctionName, out labels))
            {
                Utils.ThrowErrorMsg("Couldn't find labels in function [" + script.FunctionName + "].",
                                    script, m_name);
                return(Variable.EmptyInstance);
            }

            int gotoPointer;

            if (!labels.TryGetValue(labelName, out gotoPointer))
            {
                Utils.ThrowErrorMsg("Couldn't find label [" + labelName + "].",
                                    script, m_name);
                return(Variable.EmptyInstance);
            }

            string filename;

            if (script.LabelToFile.TryGetValue(labelName, out filename) &&
                filename != script.Filename && !string.IsNullOrWhiteSpace(filename))
            {
                var newScript = script.GetIncludeFileScript(filename);
                script.Filename = filename;
                script.String   = newScript.String;
            }

            if (!m_isGoto)
            {
                script.PointersBack.Add(script.Pointer);
            }

            script.Pointer = gotoPointer;
            if (string.IsNullOrWhiteSpace(script.FunctionName))
            {
                script.Backward();
            }

            return(Variable.EmptyInstance);
        }