示例#1
0
        private void ExternalMethod()
        {
            if (!Method.IsExternal)
            {
                return;
            }

            IsCILDecodeRequired  = false;
            IsExecutePipeline    = false;
            IsStackFrameRequired = false;

            var intrinsic = Architecture.GetInstrinsicMethod(Method.ExternMethodModule);

            if (intrinsic != null)
            {
                return;
            }

            Symbol.ExternalSymbolName = Method.ExternMethodName;
            Symbol.IsExternalSymbol   = true;

            if (Trace.IsTraceable(5))
            {
                var traceLog = new TraceLog(TraceType.MethodInstructions, Method, "XX-External Method");
                traceLog?.Log($"This method is external linked: {Method.ExternMethodName}");
                Trace.PostTraceLog(traceLog);
            }
        }
示例#2
0
        protected override void Run()
        {
            foreach (var block in BasicBlocks)
            {
                for (var node = block.AfterFirst; !node.IsBlockEndInstruction; node = node.Next)
                {
                    if (node.IsEmptyOrNop)
                    {
                        continue;
                    }

                    if (node.Instruction != IRInstruction.IntrinsicMethodCall)
                    {
                        continue;
                    }

                    var intrinsic = Architecture.GetInstrinsicMethod(node.Operand1.Method.ExternMethodModule);

                    if (intrinsic == null)
                    {
                        continue;
                    }

                    var operands = node.GetOperands();
                    operands.RemoveAt(0);
                    node.SetInstruction(IRInstruction.IntrinsicMethodCall, node.Result, operands);

                    intrinsic(new Context(node), MethodCompiler);
                }
            }
        }
示例#3
0
        private void ExternalMethod()
        {
            if (!Method.IsExternal)
            {
                return;
            }

            IsCILDecodeRequired  = false;
            IsExecutePipeline    = false;
            IsStackFrameRequired = false;
            MethodData.IsMethodImplementationReplaced = false;

            var intrinsic = Architecture.GetInstrinsicMethod(Method.ExternMethodModule);

            if (intrinsic != null)
            {
                return;
            }

            Symbol.ExternalSymbolName = Method.ExternMethodName;
            Symbol.IsExternalSymbol   = true;

            var filename = Method.ExternMethodModule;

            if (filename != null)
            {
                foreach (var path in Compiler.CompilerOptions.SearchPaths)
                {
                    var src = Path.Combine(path, filename);

                    if (File.Exists(src))
                    {
                        var b = File.ReadAllBytes(src);

                        Symbol.SetData(b);

                        break;
                    }
                }

                // TODO: Generate an error if the file is not found
                // CompilerException.FileNotFound
            }

            if (Trace.IsTraceable(5))
            {
                var traceLog = new TraceLog(TraceType.MethodInstructions, Method, "XX-External Method", MethodData.Version);
                traceLog?.Log($"This method is external linked: {Method.ExternMethodName}");
                Trace.PostTraceLog(traceLog);
            }
        }
示例#4
0
        private void ExternalMethod()
        {
            if (!Method.IsExternal)
            {
                return;
            }

            IsCILDecodeRequired  = false;
            IsExecutePipeline    = false;
            IsStackFrameRequired = false;

            var intrinsic = Architecture.GetInstrinsicMethod(Method.ExternMethodModule);

            if (intrinsic != null)
            {
                return;
            }

            Linker.DefineExternalSymbol(Method.FullName, Method.ExternMethodName, SectionKind.Text);
        }
示例#5
0
        private void ExternalMethod()
        {
            if (!Method.IsExternal)
            {
                return;
            }

            IsCILStream          = false;
            IsExecutePipeline    = false;
            IsStackFrameRequired = false;
            MethodData.IsMethodImplementationReplaced = false;

            var intrinsic = Architecture.GetInstrinsicMethod(Method.ExternMethodModule);

            if (intrinsic != null)
            {
                return;
            }

            Symbol.ExternalSymbolName = Method.ExternMethodName;
            Symbol.IsExternalSymbol   = true;

            var filename = Method.ExternMethodModule;

            if (filename != null)
            {
                var bytes = Compiler.SearchPathsForFileAndLoad(filename);

                // TODO: Generate an error if the file is not found
                // CompilerException.FileNotFound

                Symbol.SetData(bytes);
            }

            if (NotifyTraceLogHandler != null)
            {
                var traceLog = new TraceLog(TraceType.MethodInstructions, Method, "XX-External Method", MethodData.Version);
                traceLog?.Log($"This method is external linked: {Method.ExternMethodName}");
                NotifyTraceLogHandler.Invoke(traceLog);
            }
        }