本文整理汇总了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);
}
}
示例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, "");
}
示例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, "");
}
示例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";
}
}
示例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);
}
}
示例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);
}