当前位置: 首页>>代码示例>>C#>>正文


C# Kernel类代码示例

本文整理汇总了C#中Kernel的典型用法代码示例。如果您正苦于以下问题:C# Kernel类的具体用法?C# Kernel怎么用?C# Kernel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Kernel类属于命名空间,在下文中一共展示了Kernel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Compile

        public override void Compile(Kernel k)
        {
            Symbol returnSymbol = k.Lookup("+return");

            if (this.Value != null)
                this.Value.Compile(k);
            else
                k.Emit(Opcode.PUSHNIL);

            var rvn = new RetrieveVariableNode(-1, -1) {VariableName = "+return"};
            rvn.PrePass(k);
            rvn.PreCompile(k);
            rvn.Compile(k);

            uint mem = 0;
            Scope current = k.CurrentScope;
            while(current != returnSymbol.SScope)
            {
                mem += current.MemorySpace;
                current.PopMemory(k, false);

                current = current.Parent;
            }

            mem += current.MemorySpace;

            current.PopMemory(k, false);

            k.EmitPush(mem + "u").Comment = "deallocate function memory";
            k.Emit(Opcode.DEALLOC);

            k.Emit(Opcode.JUMP).SetDebug(File, Line, Column, DebugType.Return, "");
        }
开发者ID:redxdev,项目名称:shogun-old,代码行数:33,代码来源:ReturnNode.cs

示例2: Compile

        public override void Compile(Kernel k)
        {
            Symbol symbol = k.Lookup(this.VariableName);

            if(this.Value == null)
            {
                k.Emit(Opcode.PUSHNIL).Comment = "set variable to nil";
            }
            else
            {
                this.Value.Compile(k);
            }

            if (symbol.SScope == k.CurrentScope)
            {
                k.EmitPush(symbol.Id.ToString() + "u").Comment = "store into variable " + this.VariableName;
                k.Emit(Opcode.STLO).SetDebug(File, Line, Column, DebugType.Set, this.VariableName);
            }
            else
            {
                uint mem = k.CurrentScope.WalkMemoryBack(symbol.SScope);
                mem -= symbol.Id;

                k.EmitPush(mem.ToString() + "u").Comment = "store into variable " + this.VariableName;
                k.Emit(Opcode.STNLO).SetDebug(File, Line, Column, DebugType.Set, this.VariableName);
            }
        }
开发者ID:redxdev,项目名称:shogun-old,代码行数:27,代码来源:SetVariableNode.cs

示例3: FinishedLaunching

 public override void FinishedLaunching(UIApplication app)
 {
     Instance = this;
     Application application = new Application ();
     kernel = new Kernel (application);
     kernel.Run ();
 }
开发者ID:Syderis,项目名称:CellSDK-Tutorials,代码行数:7,代码来源:Program.cs

示例4: PreCompile

 public override void PreCompile(Kernel k)
 {
     foreach (ICompileNode node in this.Children)
     {
         node.PreCompile(k);
     }
 }
开发者ID:redxdev,项目名称:shogun-old,代码行数:7,代码来源:TreeNode.cs

示例5: Compile

        public override void Compile(Kernel k)
        {
            k.EmitPush("1u");
            k.Emit(Opcode.ALLOC).SetDebug(File, Line, Column, DebugType.Define, this.VariableName);
            k.CurrentScope.MemorySpace += 1;

            Symbol symbol = new Symbol()
                {
                    Name = this.VariableName,
                    SMode = Symbol.Mode.Intern,
                    SType = Symbol.Type.Variable,
                    Id = k.CurrentScope.RequestId()
                };

            k.RegisterSymbol(symbol);

            if (this.Value == null)
            {
                k.Emit(Opcode.PUSHNIL).Comment = "clear memory for variable";
            }
            else
            {
                this.Value.Compile(k);
            }

            k.EmitPush(symbol.Id.ToString() + "u");
            k.Emit(Opcode.STLO).SetDebug(File, Line, Column, DebugType.Set, this.VariableName);
        }
开发者ID:redxdev,项目名称:shogun-old,代码行数:28,代码来源:DefineVariableNode.cs

示例6: KNN_SVM

        public KNN_SVM(string path, double sigma, double gamma, Kernel kernel, int k, ImageVector[] goodImages, ImageVector[] badImages)
        {
            type = "KNN & SVM";
            svm = new SVM_Matlab(path, sigma, gamma, (SVM_Matlab.Kernel)kernel, goodImages, badImages);
            knn = new KNN_Matlab(path, k, goodImages, badImages);

            totalImages = 0;

            this.goodImages = goodImages;
            this.badImages = badImages;

            learnedTrue = new bool[goodImages.Length];
            learnedFalse = new bool[badImages.Length];
            restartTest();

            userPath = path + "\\KNN_SVM";
            resultPath = userPath + "\\sigma_" + sigma + "_gamma_" + gamma;

            learn = GetLearnCommand(userPath, sigma, gamma, kernel);
            decideSVM = GetDecideCommandSVM(userPath, kernel);
            decideKNN = GetDecideCommandKNN(userPath, k);

            matlab = new MLApp.MLApp();
            cd = "cd " + smartAlbum.getMatlabDirectory();
            matlab.Execute(cd);
        }
开发者ID:ravitle,项目名称:Smart-Album,代码行数:26,代码来源:KNN_SVM.cs

示例7: TraceDlg

        public TraceDlg(Kernel kernel)
        {
            InitializeComponent();

            _kernel = kernel;

            _colJp.Add("送受");
            _colJp.Add("スレッドID");
            _colJp.Add("アドレス");
            _colJp.Add("データ");
            _colEn.Add("Direction");
            _colEn.Add("ThreadID");
            _colEn.Add("Address");
            _colEn.Add("Data");

            //オーナー描画
            foreach (var t in _colJp){
                listViewTrace.Columns.Add(t);
            }
            listViewTrace.Columns[2].Width = 100;
            listViewTrace.Columns[3].Width = 500;

            _timer = new Timer{Enabled = true, Interval = 100};
            _timer.Tick += TimerTick;

            kernel.WindowSize.Read(this);//ウインドサイズの復元
            kernel.WindowSize.Read(listViewTrace);//カラム幅の復元
        }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:28,代码来源:TraceDlg.cs

示例8: RunKernel

        public static void RunKernel(
            Context context,
            Device device,
            Kernel kernel,
            int size,
            IEnumerable<int> indicesOfPinnedArraysToReadBack,
            params IPinnedArrayOfStruct[] pinnedArrays)
        {
            ErrorCode errorCode;

            var commandQueue = Cl.CreateCommandQueue(context, device, CommandQueueProperties.ProfilingEnable, out errorCode);
            errorCode.Check("CreateCommandQueue");

            var setKernelArgErrorCodes = pinnedArrays.Select((pinnedArray, index) =>
            {
                var ec = Cl.SetKernelArg(kernel, (uint) index, pinnedArray.Buffer);
                ec.Check($"SetKernelArg({index})");
                return ec;
            });
            Debug.Assert(setKernelArgErrorCodes.All(e => e == ErrorCode.Success));

            var globalWorkSize = new[] {(IntPtr) size};

            Event e1;
            errorCode = Cl.EnqueueNDRangeKernel(
                commandQueue,
                kernel,
                (uint)globalWorkSize.Length, // workDim
                null, // globalWorkOffset
                globalWorkSize,
                null, // localWorkSize
                0, // numEventsInWaitList
                null, // eventWaitList
                out e1);
            errorCode.Check("EnqueueNDRangeKernel");

            var eventsToWaitFor = new List<Event>();

            foreach (var index in indicesOfPinnedArraysToReadBack)
            {
                Event e2;
                errorCode = Cl.EnqueueReadBuffer(
                    commandQueue,
                    pinnedArrays[index].Buffer,
                    Bool.False, // blockingRead
                    IntPtr.Zero, // offsetInBytes
                    (IntPtr)pinnedArrays[index].Size,
                    pinnedArrays[index].Handle,
                    0, // numEventsInWaitList
                    null, // eventWaitList
                    out e2);
                errorCode.Check("EnqueueReadBuffer");

                eventsToWaitFor.Add(e2);
            }

            var evs = eventsToWaitFor.ToArray();
            errorCode = Cl.WaitForEvents((uint)evs.Length, evs);
            errorCode.Check("WaitForEvents");
        }
开发者ID:taylorjg,项目名称:OpenCLExperiments,代码行数:60,代码来源:KernelRunner.cs

示例9: CreateInstance

        public static Object CreateInstance(Kernel kernel, string path, string className, Object[] param)
        {
            if (File.Exists(path)){
                var dllName = Path.GetFileNameWithoutExtension(path);
                try{
                    var asm = Assembly.LoadFile(path);
                    if (asm != null){
                        return asm.CreateInstance(dllName + "." + className, true, BindingFlags.Default, null, param,
                                                  null, null);
                    }
                }
                catch (Exception ex){

                    //Ver6.1.7
                    if (ex.InnerException != null) {
                        throw new Exception(ex.InnerException.Message);
                    }

                    var logger = kernel.CreateLogger("CreateInstance", false, null);
                    logger.Set(LogKind.Error, null, 9000051,
                               string.Format("DLL={0} CLASS={1} {2}", dllName, className, ex.Message));

                    return null;
                }
            }
            return null;
        }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:27,代码来源:Util.cs

示例10: SockTcp

        //ACCEPT
        //Ver5.9.2 Java fix
        //public SockTcp(Kernel kernel, Socket s) : base(kernel){
        public SockTcp(Kernel kernel, Ssl ssl, Socket s)
            : base(kernel)
        {
            //************************************************
            //selector/channel生成
            //************************************************
            _socket = s;
            _ssl = ssl;

            //既に接続を完了している
            if (_ssl != null){
                //SSL通信の場合は、SSLのネゴシエーションが行われる
                _oneSsl = _ssl.CreateServerStream(_socket);
                if (_oneSsl == null) {
                    SetError("_ssl.CreateServerStream() faild");
                    return;
                }
            }

            //************************************************
            //ここまでくると接続が完了している
            //************************************************
            //Set(SockState.Connect, (InetSocketAddress) channel.socket().getLocalSocketAddress(), (InetSocketAddress) channel.socket().getRemoteSocketAddress());

            //************************************************
            //read待機
            //************************************************
            BeginReceive(); //接続完了処理(受信待機開始)
        }
开发者ID:jsakamoto,项目名称:bjd5,代码行数:32,代码来源:SockTcp.cs

示例11: Init

        /// <summary>
        /// The Init method is called when the plug-in is loaded by MediaBrowser.  You should perform all your specific initializations
        /// here - including adding your theme to the list of available themes.
        /// </summary>
        /// <param name="kernel"></param>
        public override void Init(Kernel kernel)
        {
            try
            {
                //the AddTheme method will add your theme to the available themes in MediaBrowser.  You need to call it and send it
                //resx references to your mcml pages for the main "Page" selector and the MovieDetailPage for your theme.
                //The template should have generated some default pages and values for you here but you will need to create all the
                //specific mcml files for the individual views (or, alternatively, you can reference existing views in MB.
                kernel.AddTheme("Classic", "resx://Classic/Classic.Resources/Page#PageClassic", "resx://Classic/Classic.Resources/DetailMovieView#ClassicMovieView");

                //The AddConfigPanel method will allow you to extend the config page of MediaBrowser with your own options panel.
                //You must create this as an mcml UI that fits within the standard config panel area.  It must take Application and
                //FocusItem as parameters.  The project template should have generated an example ConfigPage.mcml that you can modify
                //or, if you don't wish to extend the config, remove it and the following call to AddConfigPanel
                //kernel.AddConfigPanel("Classic Options", "resx://Classic/Classic.Resources/ConfigPanel#ConfigPanel");

                //The AddStringData method will allow you to extend the localized strings used by MediaBrowser with your own.
                //This is useful for adding descriptive text to go along with your theme options.  If you don't have any theme-
                //specific options or other needs to extend the string data, remove the following call.
                //kernel.StringData.AddStringData(MyStrings.FromFile(MyStrings.GetFileName("Classic-")));

                //Tell the log we loaded.
                Logger.ReportInfo("Classic Theme Loaded.");
            }
            catch (Exception ex)
            {
                Logger.ReportException("Error adding theme - probably incompatable MB version", ex);
            }
        }
开发者ID:rickbassham,项目名称:videobrowser,代码行数:34,代码来源:Plugin.cs

示例12: PreCompile

        public override void PreCompile(Kernel k)
        {
            if (this.Body != null)
                this.Body.PreCompile(k);

            this.Check.PreCompile(k);
        }
开发者ID:redxdev,项目名称:shogun-old,代码行数:7,代码来源:DoWhileLoopNode.cs

示例13: Stop

 public static void Stop()
 {
     if(null != _Kernel) {
         _Kernel.Dispose();
         _Kernel = null;
     }
 }
开发者ID:Kuick,项目名称:Kuicker,代码行数:7,代码来源:Platform.cs

示例14: PreCompile

 public override void PreCompile(Kernel k)
 {
     foreach (ICompileNode node in this.Values)
     {
         node.PrePass(k);
     }
 }
开发者ID:redxdev,项目名称:shogun-old,代码行数:7,代码来源:ExpressionNode.cs

示例15: Main

        /// <summary>
        /// Represents the entry point to the sample application.
        /// </summary>
        /// <param name="args">The command line arguments, that were passed to the program. Are not used.</param>
        public static void Main(string[] args)
        {
            // Creates a new Simple IoC kernel
            Kernel kernel = new Kernel();

            // Binds the vehicles to the kernel
            kernel.Bind<IVehicle>().ToType<Car>();
            kernel.Bind<IVehicle>().ToType<Motorcycle>().WhenInjectedInto<SuperCoolPerson>(); // Obviously super cool people drive motorcycles!

            // Creates some persons
            Person person = kernel.Resolve<Person>();
            Person superCoolPerson = kernel.Resolve<SuperCoolPerson>();
            Person namedPerson = kernel.Resolve<NamedPerson>("Bob");

            // Prints out the personal information about the persons that were created
            System.Console.WriteLine(person);
            System.Console.WriteLine(superCoolPerson);
            System.Console.WriteLine(namedPerson);

            // Demonstrates singleton scope, where the resolved instance is always the same
            kernel.Bind<DateTime>().ToFactory(() => DateTime.UtcNow).InSingletonScope();
            System.Console.WriteLine(kernel.Resolve<DateTime>().Ticks);
            Thread.Sleep(1000);
            System.Console.WriteLine(kernel.Resolve<DateTime>().Ticks);

            // Waits for a key stroke, before the application is quit
            System.Console.WriteLine("Press any key to quit...");
            System.Console.ReadKey();
        }
开发者ID:lecode-official,项目名称:simple-ioc,代码行数:33,代码来源:Program.cs


注:本文中的Kernel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。