示例#1
0
        public GMLCode(GMAssets _assets, string _name, string _code, eGMLCodeType _type)
        {
            Name = _name.Replace(' ', '_').Replace('\t', '_');
            Code = _code;
            Type = _type;
            List <GMLError> _errors = null;

            Token  = GMLCompile.Compile(_assets, Name, Code, out _errors);
            Errors = _errors;
        }
示例#2
0
        public void Compile(GMAssets _assets)
        {
            switch (Kind)
            {
            case eAction.ACT_VARIABLE:
                if (Relative)
                {
                    Code = Code + Args[0] + " += " + Args[1];
                }
                else
                {
                    Code = Code + Args[0] + " = " + Args[1];
                }
                Kind = eAction.ACT_NORMAL;
                Args.Clear();
                break;

            case eAction.ACT_CODE:
                Code = Args[0];
                Kind = eAction.ACT_NORMAL;
                Args.Clear();
                if (Program.RemoveDND)
                {
                    List <GMLError> _errors            = null;
                    bool            inhibitErrorOutput = Program.InhibitErrorOutput;
                    Program.InhibitErrorOutput = true;
                    GMLCompile.Compile(_assets, "test_compile", Code, out _errors);
                    Program.InhibitErrorOutput = inhibitErrorOutput;
                    if (_errors.Count > 0)
                    {
                        foreach (GMLError item2 in _errors)
                        {
                            eErrorKind kind = item2.Kind;
                            if (kind == eErrorKind.Warning_Unclosed_Comment)
                            {
                                Code += "*/";
                            }
                        }
                    }
                }
                break;
            }
            if (IsQuestion && ExeType == eExecuteTypes.EXE_CODE)
            {
                Name = string.Format("__script{0}__", countScript);
                GMScript value = new GMScript(Code);
                KeyValuePair <string, GMScript> item = new KeyValuePair <string, GMScript>(Name, value);
                _assets.Scripts.Add(item);
                countScript++;
                ExeType = eExecuteTypes.EXE_FUNCTION;
            }
        }