コード例 #1
0
ファイル: References.cs プロジェクト: f0829/2calgo.Library
        public static string AddRefModifiers(this string code)
        {
            var functions = FunctionsParser.Parse(code);

            foreach (var function in functions
                     .ToArray()
                     .Where(f => f.Parameters.Any(p => p.ByReference)))
            {
                var f = function;

                foreach (var methodCall in MethodCallsParser.Parse(code)
                         .Where(call => call.MethodName == f.Name)
                         .ToArray())
                {
                    foreach (var parameter in f.Parameters.Where(p => p.ByReference))
                    {
                        var parameterValue = methodCall.Parameters[parameter.Index];
                        if (parameter.Type != "IMq4DoubleArray")
                        {
                            methodCall.Parameters[parameter.Index] = "ref " + parameterValue;
                        }
                    }
                    code = code.Replace(methodCall.OriginalText, methodCall.ToCSharpCode());
                }
            }

            return(code);
        }
コード例 #2
0
        public static string RenameFunctions(this string code)
        {
            var functions = FunctionsParser.Parse(code);

            foreach (var function in functions)
            {
                if (function.Name == "start" || function.Name == "init")
                {
                    continue;
                }

                var regex = new Regex(@"(?<!\w)" + function.Name + @"\s*\(");
                code = regex.Replace(code, function.Name + "Func(");
            }
            return(code);
        }
コード例 #3
0
        public GameObjectResolver(string questFile, HashSet <string> alreadyLoadedFiles = null)
        {
            AlreadyLoadedFiles = alreadyLoadedFiles ?? new HashSet <string>();
            _filePath          = new FileInfo(questFile).Directory?.FullName;
            using (var file = File.Open(questFile, FileMode.Open))
                _gameFile = XDocument.Load(file);

            if (_gameFile.Root == null)
            {
                throw new ArgumentException("ASLX game file should not be empty...", nameof(questFile));
            }

            InferFileType();

            ProcessIncludeReferences();

            var functionParser  = new FunctionsParser(this);
            var parsedFunctions = functionParser.Parse(_gameFile);

            _functionReferenceGraph.MergeWith(parsedFunctions.ReferenceGraph);
            _functionDefinitions.MergeWith(parsedFunctions.Definitions);

            var delegateParser = new DelegatesParser();

            _delegateDefinitions.MergeWith(delegateParser.Parse(_gameFile));

            var objectTypeParser = new ObjectTypeParser(_delegateDefinitions);

            _typeInheritanceGraph.MergeWith(objectTypeParser.Parse(_gameFile));
            _objectTypeDefinitions.MergeWith(_typeInheritanceGraph.ToDictionary(x => x.Name, x => x));

            BuildTypeInheritanceGraph();

            var objectParser = new ObjectParser(_delegateDefinitions, _typeInheritanceGraph, _objectTypeDefinitions);

            _objectDefinitions.MergeWith(objectParser.Parse(_gameFile));

            PostLoadInitialization();
        }
コード例 #4
0
 public Function GetFunction()
 {
     return(FunctionsParser.Parse(functionText));
 }