本文整理汇总了C#中VirtualMachine.AddInstructions方法的典型用法代码示例。如果您正苦于以下问题:C# VirtualMachine.AddInstructions方法的具体用法?C# VirtualMachine.AddInstructions怎么用?C# VirtualMachine.AddInstructions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine.AddInstructions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination)
{
into.SetPendingAnnotation(this.ToString());
into.AddInstructions("ALLOC_RSO NEXT PUSH", ResultType.Size);
into.AddInstructions("STORE_RSO_M NEXT PEEK NEXT", ResultType.ID, 0); //Store type id
if (Constructor != null)
{
if (Constructor.OwnerContextID == Scope.EnvironmentContext.ID && Constructor.OwnerContextID != 0)
{
into.AddInstructions("CALL NEXT #" + Constructor.DescriptiveHeader, 0);
Constructor.Body.CallPoints.Add(into.Count - 1);
}
else
{
into.AddInstructions("STACK_INVOKE NEXT", Constructor.MakeInvokableFunction());
}
}
if (Initializers != null)
{
foreach (var initializer in Initializers)
initializer.Emit(into, OperationDestination.Discard);
}
if (Destination != OperationDestination.Stack)
into.AddInstructions("MOVE POP " + WriteOperand(Destination));
}
示例2: Emit
public override void Emit(VirtualMachine.InstructionList into, Ast.OperationDestination Destination)
{
//Prepare loop control variables
List.Emit(into, Ast.OperationDestination.Stack); //[email protected]
LengthFunc.Emit(into, Ast.OperationDestination.Stack); //[email protected]
into.AddInstructions("MOVE NEXT PUSH # SET [email protected]", 0); //[email protected]
var LoopStart = into.Count;
into.AddInstructions(
"LOAD_PARAMETER NEXT R #" + TotalVariable.Name, TotalVariable.Offset,
"GREATER_EQUAL PEEK R R #PEEK = [email protected]",
"IF_TRUE R",
"JUMP NEXT", 0);
var BreakPoint = into.Count - 1;
Indexer.Emit(into, Ast.OperationDestination.Stack);
Body.Emit(into, Ast.OperationDestination.Discard);
into.AddInstructions(
"MOVE POP #REMOVE [email protected]",
"INCREMENT PEEK PEEK",
"JUMP NEXT", LoopStart);
into[BreakPoint] = into.Count;
into.AddInstructions("CLEANUP NEXT #REMOVE [email protected], [email protected], [email protected]", 3);
}
示例3: Emit
public override void Emit(VirtualMachine.InstructionList into, Ast.OperationDestination Destination)
{
Max.Emit(into, Ast.OperationDestination.Stack);
Min.Emit(into, Ast.OperationDestination.Stack);
var LoopStart = into.Count;
into.AddInstructions(
"LOAD_PARAMETER NEXT R", TotalVariable.Offset,
"GREATER PEEK R R",
"IF_TRUE R",
"JUMP NEXT", 0);
var BreakPoint = into.Count - 1;
into.AddInstructions("MOVE PEEK PUSH");
Body.Emit(into, Ast.OperationDestination.Discard);
into.AddInstructions(
"MOVE POP",
"INCREMENT PEEK PEEK",
"JUMP NEXT", LoopStart);
into[BreakPoint] = into.Count;
into.AddInstructions(
"MOVE POP",
"MOVE POP");
}
示例4: Emit
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination)
{
Value.Emit(into, OperationDestination.R);
into.AddInstructions("ALLOC_RSO NEXT PUSH", 3,
"STORE_RSO_M NEXT PEEK NEXT", ResultType.ID, 0,
"STORE_RSO_M NEXT PEEK NEXT", Value.ResultType.ID, 1,
"STORE_RSO_M R PEEK NEXT", 2);
if (Destination != OperationDestination.Stack)
into.AddInstructions("MOVE POP " + WriteOperand(Destination));
}
示例5: Emit
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination)
{
into.SetPendingAnnotation(this.ToString());
foreach (var n in Parameters)
n.Emit(into, OperationDestination.Stack);
into.AddInstructions("COMPAT_INVOKE NEXT", Parameters.Count);
if (Destination != OperationDestination.R && Destination != OperationDestination.Discard)
into.AddInstructions("MOVE R " + Node.WriteOperand(Destination));
}
示例6: Emit
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination)
{
into.SetPendingAnnotation(this.ToString());
foreach (var arg in Arguments)
arg.Emit(into, OperationDestination.Stack);
into.AddInstructions("STACK_INVOKE NEXT", Function.MakeInvokableFunction());
if (Arguments.Count > 0) into.AddInstructions("CLEANUP NEXT", Arguments.Count);
if (Destination != OperationDestination.R && Destination != OperationDestination.Discard)
into.AddInstructions("MOVE R " + Node.WriteOperand(Destination));
}
示例7: Emit
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination)
{
into.SetPendingAnnotation(this.ToString());
if (Value != null)
Value.Emit(into, OperationDestination.R);
else
into.AddInstructions("MOVE NEXT R", 0);
into.AddInstructions("JUMP NEXT", 0);
DeclarationScope.RecordReturnJumpSource(into.Count - 1);
}
示例8: EmitAssignment
public void EmitAssignment(VirtualMachine.InstructionList into)
{
if (Name.Type == TokenType.Identifier)
{
if (MatchedVariable.StorageMethod == VariableStorageMethod.Local)
into.AddInstructions("STORE_PARAMETER POP NEXT", MatchedVariable.Offset);
else if (MatchedVariable.StorageMethod == VariableStorageMethod.Static)
into.AddInstructions("STORE_STATIC POP NEXT", MatchedVariable.Offset);
else
throw new NotImplementedException();
}
else
throw new InvalidOperationException();
}
示例9: Emit
public override void Emit(VirtualMachine.InstructionList Instructions, OperationDestination Destination)
{
Instructions.AddInstructions("EMPTY_LIST PUSH");
foreach (var member in Members)
{
member.Emit(Instructions, OperationDestination.R);
Instructions.AddInstructions("APPEND R PEEK PEEK");
}
if (Destination == OperationDestination.Discard)
Instructions.AddInstructions("MOVE POP");
else if (Destination != OperationDestination.Top)
Instructions.AddInstructions("MOVE POP " + WriteOperand(Destination));
}
示例10: EmitUnbox
public static void EmitUnbox(
VirtualMachine.InstructionList into,
OperationDestination Source,
OperationDestination Destination)
{
into.AddInstructions("LOAD_RSO_M " + ReadOperand(Source) + " NEXT " + WriteOperand(Destination), 2);
}
示例11: EmitInstructions
public virtual void EmitInstructions(ParseScope DeclarationScope, VirtualMachine.InstructionList Into)
{
if (Instructions != null) throw new InvalidOperationException("Instructions should not be emitted twice");
CleanupPoint = Into.Count;
if (CleanupCall >= 0)
Into[CleanupCall] = CleanupPoint;
Into.AddInstructions("CLEANUP NEXT #Cleanup " + Name, DeclarationScope.Owner.ActualParameterCount, "RETURN POP");
Instructions = Into;
EntryPoint = Into.Count;
Instructions.AddInstructions("MOVE F PUSH #Enter " + Name, "MARK_STACK F");
Body.Emit(Instructions, Ast.OperationDestination.Discard);
//Instructions.AddInstructions("MOVE NEXT R", 0); //If a function has no return statement, it returns 0.
var returnJumpPoint = Instructions.Count;
Instructions.AddInstructions(
"RESTORE_STACK F",
"MOVE POP F",
"RETURN POP");
System.Diagnostics.Debug.Assert(DeclarationScope.Type == ScopeType.Function);
System.Diagnostics.Debug.Assert(DeclarationScope.ReturnJumpSources != null);
foreach (var point in DeclarationScope.ReturnJumpSources)
Instructions[point] = returnJumpPoint;
}
示例12: Emit
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination)
{
into.SetPendingAnnotation(this.ToString());
Header.Emit(into, OperationDestination.R);
into.AddInstructions("IF_FALSE R", "JUMP NEXT", 0);
var jumpFrom = into.Count - 1;
ThenBlock.Emit(into, OperationDestination.Discard);
if (ElseBlock != null)
{
into.AddInstructions("JUMP NEXT", 0);
into[jumpFrom] = into.Count;
jumpFrom = into.Count - 1;
ElseBlock.Emit(into, OperationDestination.Discard);
}
into[jumpFrom] = into.Count;
}
示例13: Emit
public override void Emit(VirtualMachine.InstructionList into, OperationDestination Destination)
{
into.SetPendingAnnotation(this.ToString());
//Assumes the RSO is on the top of the stack.
Value.Emit(into, OperationDestination.R);
into.AddInstructions("STORE_RSO_M R PEEK NEXT", Member.Offset);
}
示例14: Emit
public override void Emit(VirtualMachine.InstructionList into, Ast.OperationDestination Destination)
{
var LoopStart = into.Count;
Condition.Emit(into, Ast.OperationDestination.R);
into.AddInstructions(
"IF_FALSE R",
"JUMP NEXT", 0);
var BreakPoint = into.Count - 1;
Body.Emit(into, Ast.OperationDestination.Discard);
into.AddInstructions("JUMP NEXT", LoopStart);
into[BreakPoint] = into.Count;
}
示例15: EmitInstructions
public override void EmitInstructions(ParseScope DeclarationScope, VirtualMachine.InstructionList Into)
{
if (Instructions != null) throw new InvalidOperationException("Instructions should not be emitted twice");
CleanupPoint = Into.Count;
if (CleanupCall >= 0)
Into[CleanupCall] = CleanupPoint;
Into.AddInstructions("CLEANUP NEXT #Cleanup when clause for " + Name,
DeclarationScope.Owner.ActualParameterCount, "RETURN POP");
Instructions = Into;
EntryPoint = Into.Count;
Instructions.AddInstructions("MOVE F PUSH #Enter " + Name, "MARK_STACK F");
Body.Emit(Instructions, Ast.OperationDestination.R);
Instructions.AddInstructions(
"RESTORE_STACK F",
"MOVE POP F",
"RETURN POP");
}