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


C# Kernel.Lookup方法代码示例

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


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

示例1: 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

示例2: 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

示例3: Compile

        public override void Compile(Kernel k)
        {
            Symbol breakSymbol = k.Lookup("+break");
            uint mem = 0;
            Scope current = k.CurrentScope;
            while (current != breakSymbol.SScope)
            {
                mem += current.MemorySpace;
                current.PopMemory(k, false);

                current = current.Parent;
            }

            current.PopMemory(k, false);

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

            k.Emit(Opcode.GOTO, "\"" + breakSymbol.AsmName + "\"").SetDebug(File, Line, Column, DebugType.Break, "");
        }
开发者ID:redxdev,项目名称:shogun-old,代码行数:20,代码来源:BreakNode.cs

示例4: Compile

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

            switch(symbol.SType)
            {
                case Symbol.Type.Function:
                    break;

                default:
                    throw new InvalidOperationException(string.Format("Tried to compile a function call on a non-function symbol \"{0}\"", this.Function));
            }

            if (symbol.Args != this.Arguments.Count)
                throw new ArgumentOutOfRangeException(string.Format("Tried to pass {0} arguments to {1} (requires: {2})", this.Arguments.Count, symbol.Name, symbol.Args));

            switch(symbol.SMode)
            {
                default:
                    throw new InvalidOperationException(string.Format("Unknown symbol mode {0} on symbol \"{1}\"", symbol.SMode.ToString(), this.Function));

                case Symbol.Mode.Extern:
                    this.CompileExtern(k);
                    break;

                case Symbol.Mode.Intern:
                    this.CompileIntern(k);
                    break;

                case Symbol.Mode.Library:
                    this.CompileLibrary(k);
                    break;
            }

            if(!this.UseReturn)
            {
                k.Emit(Opcode.POP).Comment = "remove unused return value";
            }
        }
开发者ID:redxdev,项目名称:shogun-old,代码行数:39,代码来源:FunctionCallNode.cs

示例5: Compile

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

            if (symbol.SType != Symbol.Type.Variable)
            {
                throw new CompileException(String.Format("Symbol {0} is not a variable", this.VariableName));
            }

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

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

示例6: CompileIntern

        protected void CompileIntern(Kernel k)
        {
            for(int i = this.Arguments.Count - 1; i >= 0; i--)
            {
                this.Arguments[i].Compile(k);
            }

            uint returnId = k.CurrentScope.RequestLabelId();

            k.CurrentScope.PushMemory(k);
            k.Emit(Opcode.PLABL, "\"sl_r_" + k.GetScopeName() + "_" + returnId.ToString() + "\"");
            k.Emit(Opcode.GOTO, '"' + k.Lookup(this.Function).AsmName + '"').SetDebug(File, Line, Column, DebugType.Call, this.Function);

            k.Emit(Opcode.LABEL, "sl_r_" + k.GetScopeName() + "_" + returnId.ToString()).Comment = "return point from " + this.Function;
            k.CurrentScope.PopMemory(k);
        }
开发者ID:redxdev,项目名称:shogun-old,代码行数:16,代码来源:FunctionCallNode.cs


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