本文整理汇总了C#中ProtoCore.DSASM.InstructionStream类的典型用法代码示例。如果您正苦于以下问题:C# InstructionStream类的具体用法?C# InstructionStream怎么用?C# InstructionStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InstructionStream类属于ProtoCore.DSASM命名空间,在下文中一共展示了InstructionStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CodeBlock
public CodeBlock(CodeBlockType type, ProtoCore.Language langId, int codeBlockId, SymbolTable symbols, ProcedureTable procTable, bool isBreakableBlock = false, ProtoCore.Core core = null)
{
blockType = type;
parent = null;
children = new List<CodeBlock>();
language = langId;
this.codeBlockId = codeBlockId;
instrStream = new InstructionStream(langId, core);
symbolTable = symbols;
procedureTable = procTable;
isBreakable = isBreakableBlock;
}
示例2: CodeBlock
/// <summary>
/// A CodeBlock represents a body of DS code
/// </summary>
/// <param name="guid"></param>
/// <param name="type"></param>
/// <param name="langId"></param>
/// <param name="cbID"></param>
/// <param name="symbols"></param>
/// <param name="procTable"></param>
/// <param name="isBreakableBlock"></param>
/// <param name="core"></param>
public CodeBlock(Guid guid, CodeBlockType type, ProtoCore.Language langId, int cbID, SymbolTable symbols, ProcedureTable procTable, bool isBreakableBlock = false, ProtoCore.Core core = null)
{
this.guid = guid;
blockType = type;
parent = null;
children = new List<CodeBlock>();
language = langId;
instrStream = new InstructionStream(langId, core);
symbolTable = symbols;
procedureTable = procTable;
isBreakable = isBreakableBlock;
core.CompleteCodeBlockList.Add(this);
this.codeBlockId = core.CompleteCodeBlockList.Count - 1;
symbols.RuntimeIndex = this.codeBlockId;
if (core.ProcNode != null)
{
core.ProcNode.ChildCodeBlocks.Add(codeBlockId);
}
}
示例3: FindEndPCForAssocGraphNode
private int FindEndPCForAssocGraphNode(int tempPC, InstructionStream istream, ProcedureNode fNode, GraphNode graphNode, bool handleSSATemps)
{
int limit = Constants.kInvalidIndex;
//AssociativeGraph.GraphNode currentGraphNode = executingGraphNode;
GraphNode currentGraphNode = graphNode;
//Validity.Assert(currentGraphNode != null);
if (currentGraphNode != null)
{
if (tempPC < currentGraphNode.updateBlock.startpc || tempPC > currentGraphNode.updateBlock.endpc)
{
// return false;
return Constants.kInvalidIndex;
}
int i = currentGraphNode.dependencyGraphListID;
GraphNode nextGraphNode = currentGraphNode;
while (currentGraphNode.exprUID != Constants.kInvalidIndex
&& currentGraphNode.exprUID == nextGraphNode.exprUID)
{
limit = nextGraphNode.updateBlock.endpc;
if (++i < istream.dependencyGraph.GraphList.Count)
{
nextGraphNode = istream.dependencyGraph.GraphList[i];
}
else
{
break;
}
// Is it the next statement
// This check will be deprecated on full SSA
if (handleSSATemps)
{
if (!nextGraphNode.IsSSANode())
{
// The next graphnode is nolonger part of the current statement
// This is the end pc needed to run until
nextGraphNode = istream.dependencyGraph.GraphList[i];
limit = nextGraphNode.updateBlock.endpc;
break;
}
}
}
}
// If graph node is null in associative lang block, it either is the very first property declaration or
// it is the very first or only function call statement ("return = f();") inside the calling function
// Here there's most likely a DEP or RETURN respectively after the function call
// in which case, search for the instruction and set that as the new pc limit
else if (!fNode.name.Contains(Constants.kSetterPrefix))
{
while (++tempPC < istream.instrList.Count)
{
Instruction instr = istream.instrList[tempPC];
if (instr.opCode == OpCode.DEP || instr.opCode == OpCode.RETURN)
{
limit = tempPC;
break;
}
}
}
return limit;
}
示例4: BfsBuildInstructionStreams
private void BfsBuildInstructionStreams(CodeBlock codeBlock, InstructionStream[] istreamList)
{
if (null != codeBlock)
{
if (DSASM.CodeBlockType.kLanguage == codeBlock.blockType || DSASM.CodeBlockType.kFunction == codeBlock.blockType)
{
Debug.Assert(codeBlock.codeBlockId < CodeBlockIndex);
istreamList[codeBlock.codeBlockId] = codeBlock.instrStream;
}
foreach (DSASM.CodeBlock child in codeBlock.children)
{
BfsBuildInstructionStreams(child, istreamList);
}
}
}
示例5: Reset
public void Reset()
{
isSingleAssocBlock = true;
runtimeSymbols = null;
procedureTable = null;
classTable = null;
instrStreamList = null;
iStreamCanvas = null;
}
示例6: Executive
public Executive(RuntimeCore runtimeCore, bool isFep = false)
{
IsExplicitCall = false;
Validity.Assert(runtimeCore != null);
this.runtimeCore = runtimeCore;
enableLogging = runtimeCore.Options.Verbose;
exe = runtimeCore.DSExecutable;
istream = null;
fepRun = isFep;
Properties = new InterpreterProperties();
rmem = runtimeCore.RuntimeMemory;
// Execute DS View VM Log
//
debugFlags = (int)DebugFlags.ENABLE_LOG;
bounceType = CallingConvention.BounceType.Implicit;
deferedGraphNodes = new List<AssociativeGraph.GraphNode>();
}
示例7: RestoreDebugPropsOnReturnFromLangBlock
void RestoreDebugPropsOnReturnFromLangBlock(ref int exeblock, ref List<Instruction> instructions)
{
// On the new stack frame, this dependency has already been executed at retb in RestoreFromBounce
//XLangUpdateDependencyGraph(exeblock);
Validity.Assert(core.DebugProps.DebugStackFrame.Count > 0);
{
// Restore fepRun
DebugFrame debugFrame = core.DebugProps.DebugStackFrame.Pop();
bool isResume = debugFrame.IsResume;
if (isResume)
{
if (core.DebugProps.DebugStackFrame.Count > 1)
{
DebugFrame frame = core.DebugProps.DebugStackFrame.Peek();
frame.IsResume = true;
}
terminate = false;
// Restore registers except RX on popping of language stackframe
ResumeRegistersFromStackExceptRX();
}
// Restore return address and lang block
pc = (int)rmem.GetAtRelative(StackFrame.kFrameIndexReturnAddress).opdata;
exeblock = (int)rmem.GetAtRelative(StackFrame.kFrameIndexFunctionCallerBlock).opdata;
istream = exe.instrStreamList[exeblock];
instructions = istream.instrList;
executingLanguage = istream.language;
Properties.executingGraphNode = debugFrame.ExecutingGraphNode;
// Pop language stackframe as this is not allowed in Retb in debug mode
rmem.FramePointer = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFramePointer).opdata;
rmem.PopFrame(ProtoCore.DSASM.StackFrame.kStackFrameSize);
ResumeRegistersFromStackExceptRX();
bounceType = (ProtoCore.DSASM.CallingConvention.BounceType)TX.opdata;
}
if (pc < 0)
{
throw new ProtoCore.Exceptions.EndOfScript();
}
}
示例8: RestoreDebugPropsOnReturnFromFunctionCall
bool RestoreDebugPropsOnReturnFromFunctionCall(ref int exeblock, ref List<Instruction> instructions, out int ci, out int fi, out bool isReplicating,
out DebugFrame debugFrame)
{
//
// TODO: Aparajit, Jun - Determine an alternative to the waspopped flag
//
bool waspopped = false;
Validity.Assert(core.DebugProps.DebugStackFrame.Count > 0);
debugFrame = core.DebugProps.DebugStackFrame.Peek();
isReplicating = debugFrame.IsReplicating;
#if !__DEBUG_REPLICATE
if (!isReplicating)
#endif
{
bool isResume = debugFrame.IsResume;
// Comment Jun: Since we dont step into _Dispose() calls, then its debugframe should not be popped off here.
bool isDispose = debugFrame.IsDisposeCall;
// RestoreCallrForNoBreak and PerformReturnTypeCoerce are NOT called if this is true
// or for base class ctor calls and therefore need to be taken care of here
if ((isResume || debugFrame.IsBaseCall) && !isDispose)
{
debugFrame = core.DebugProps.DebugStackFrame.Pop();
waspopped = true;
if (isResume)
{
if (core.DebugProps.DebugStackFrame.Count > 1)
{
DebugFrame frame = core.DebugProps.DebugStackFrame.Peek();
frame.IsResume = true;
}
}
#if __DEBUG_REPLICATE
// Return type coercion and function call GC for replicating case takes place separately
// in SerialReplication() when ContinuationStruct.Done == true - pratapa
if (!isReplicating)
#endif
{
DebugPerformCoercionAndGC(debugFrame);
}
// Restore registers except RX on popping of function stackframe
ResumeRegistersFromStackExceptRX();
terminate = false;
}
Properties.executingGraphNode = debugFrame.ExecutingGraphNode;
if (core.DebugProps.RunMode.Equals(Runmode.StepOut) && pc == core.DebugProps.StepOutReturnPC)
{
core.Breakpoints.Clear();
core.Breakpoints.AddRange(core.DebugProps.AllbreakPoints);
}
}
// Restore return address and lang block
pc = (int)rmem.GetAtRelative(StackFrame.kFrameIndexReturnAddress).opdata;
exeblock = (int)rmem.GetAtRelative(StackFrame.kFrameIndexFunctionCallerBlock).opdata;
istream = exe.instrStreamList[exeblock];
instructions = istream.instrList;
executingLanguage = istream.language;
ci = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
fi = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFunction).opdata;
int localCount = 0;
int paramCount = 0;
int blockId = (int)rmem.GetAtRelative(StackFrame.kFrameIndexFunctionBlock).opdata;
GetLocalAndParamCount(blockId, ci, fi, out localCount, out paramCount);
// Pop function stackframe as this is not allowed in Ret/Retc in debug mode
rmem.FramePointer = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFramePointer).opdata;
rmem.PopFrame(ProtoCore.DSASM.StackFrame.kStackFrameSize + localCount + paramCount);
ResumeRegistersFromStackExceptRX();
//StackValue svFrameType = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexCallerStackFrameType);
StackValue svFrameType = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexStackFrameType);
StackFrameType frametype = (StackFrameType)svFrameType.opdata;
if (frametype == StackFrameType.kTypeLanguage)
{
bounceType = (ProtoCore.DSASM.CallingConvention.BounceType)TX.opdata;
}
return waspopped;
}
示例9: RestoreExecutive
private void RestoreExecutive(int exeblock)
{
// Jun Comment: the stackframe mpof the current language must still be present for this this method to restore the executuve
// It must be popped off after this call
executingLanguage = exe.instrStreamList[exeblock].language;
// TODO Jun: Remove this check once the global bounce stackframe is pushed
if (rmem.FramePointer >= ProtoCore.DSASM.StackFrame.kStackFrameSize)
{
fepRun = false;
isGlobScope = true;
StackFrameType callerType = (StackFrameType)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexCallerStackFrameType).opdata;
if (callerType == StackFrameType.kTypeFunction)
{
fepRun = true;
isGlobScope = false;
}
}
istream = exe.instrStreamList[exeblock];
Validity.Assert(null != istream);
Validity.Assert(null != istream.instrList);
pc = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexReturnAddress).opdata;
}
示例10: RETB_Handler
private void RETB_Handler()
{
if (runtimeCore.Options.RunMode != InterpreterMode.kExpressionInterpreter)
{
runtimeCore.RuntimeMemory.PopConstructBlockId();
}
if (!runtimeCore.Options.IsDeltaExecution || (runtimeCore.Options.IsDeltaExecution && 0 != runtimeCore.RunningBlock))
{
GCCodeBlock(runtimeCore.RunningBlock);
}
if (CallingConvention.BounceType.kExplicit == bounceType)
{
RestoreFromBounce();
runtimeCore.RunningBlock = executingBlock;
}
if (CallingConvention.BounceType.kImplicit == bounceType)
{
pc = (int)rmem.GetAtRelative(StackFrame.kFrameIndexReturnAddress).opdata;
terminate = true;
}
StackFrameType type;
// Comment Jun: Just want to see if this is the global rerb, in which case we dont retrieve anything
//if (executingBlock > 0)
{
StackValue svCallerType = rmem.GetAtRelative(StackFrame.kFrameIndexCallerStackFrameType);
type = (StackFrameType)svCallerType.opdata;
}
// Pop the frame as we are adding stackframes for language blocks as well - pratapa
// Do not do this for the final Retb
//if (runtimeCore.RunningBlock != 0)
if (!runtimeCore.Options.IDEDebugMode || runtimeCore.Options.RunMode == InterpreterMode.kExpressionInterpreter)
{
rmem.FramePointer = (int)rmem.GetAtRelative(StackFrame.kFrameIndexFramePointer).opdata;
rmem.PopFrame(StackFrame.kStackFrameSize);
if (bounceType == CallingConvention.BounceType.kExplicit)
{
// Restoring the registers require the current frame pointer of the stack frame
RestoreRegistersFromStackFrame();
bounceType = (CallingConvention.BounceType)TX.opdata;
}
}
if (type == StackFrameType.kTypeFunction)
{
// Comment Jun:
// Consider moving this to a restore to function method
// If this language block was called explicitly, only then do we need to restore the instruction stream
if (bounceType == CallingConvention.BounceType.kExplicit)
{
// If we're returning from a block to a function, the instruction stream needs to be restored.
StackValue sv = rmem.GetAtRelative(StackFrame.kFrameIndexRegisterTX);
Validity.Assert(sv.IsCallingConvention);
CallingConvention.CallType callType = (CallingConvention.CallType)sv.opdata;
if (CallingConvention.CallType.kExplicit == callType)
{
int callerblock = (int)rmem.GetAtRelative(StackFrame.kFrameIndexFunctionBlock).opdata;
istream = exe.instrStreamList[callerblock];
}
}
}
Properties = PopInterpreterProps();
SetupGraphNodesInScope();
}
示例11: RestoreFromCall
private void RestoreFromCall()
{
StackValue svExecutingBlock = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFunctionCallerBlock);
Validity.Assert(AddressType.BlockIndex == svExecutingBlock.optype);
executingBlock = (int)svExecutingBlock.opdata;
istream = exe.instrStreamList[executingBlock];
fepRun = false;
isGlobScope = true;
StackFrameType callerType = (StackFrameType)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexCallerStackFrameType).opdata;
if (callerType == StackFrameType.kTypeFunction)
{
fepRun = true;
isGlobScope = false;
}
}
示例12: Executive
public Executive(Core core, bool isFep = false)
{
isExplicitCall = false;
Validity.Assert(core != null);
this.core = core;
enableLogging = core.Options.Verbose;
exe = core.DSExecutable;
istream = null;
fepRun = isFep;
//executingGraphNode = null;
//nodeExecutedSameTimes = new List<AssociativeGraph.GraphNode>();
Properties = new InterpreterProperties();
allSSA = new List<AssociativeGraph.GraphNode>();
rmem = core.Rmem;
// Execute DS View VM Log
//
debugFlags = (int)DebugFlags.ENABLE_LOG;
bounceType = CallingConvention.BounceType.kImplicit;
// Execute DS Debug watch
//debugFlags = (int)DebugFlags.ENABLE_LOG | (int)DebugFlags.SPAWN_DEBUGGER;
}
示例13: SetupExecutive
private void SetupExecutive(int exeblock, int entry, Language language, List<Instruction> breakpoints)
{
core.ExecMode = InterpreterMode.kNormal;
// exe need to be assigned at the constructor,
// for function call with replication, gc is triggered to handle the parameter and return value at FunctionEndPoint
// gc requirs exe to be not null but at that point, Execute has not been called
//Validity.Assert(exe == null);
exe = core.DSExecutable;
executingBlock = exeblock;
core.DebugProps.CurrentBlockId = exeblock;
istream = exe.instrStreamList[exeblock];
Validity.Assert(null != istream);
core.DebugProps.DebugEntryPC = entry;
List<Instruction> instructions = istream.instrList;
Validity.Assert(null != instructions);
// Restore the previous state
rmem = core.Rmem;
bool _isNewFunction = rmem.FramePointer == 0;
if (core.DebugProps.isResume) // resume from a breakpoint,
{
Validity.Assert(core.DebugProps.DebugStackFrame.Count > 0);
DebugFrame debugFrame = core.DebugProps.DebugStackFrame.Peek();
// TODO: The FepRun info need not be cached in DebugProps any longer
// as it can be replaced by StackFrameType in rmem.Stack - pratapa
fepRun = debugFrame.FepRun == 1;
//StackFrameType stackFrameType = (StackFrameType)rmem.GetAtRelative(StackFrame.kFrameIndexStackFrameType).opdata;
//fepRun = (stackFrameType == StackFrameType.kTypeFunction) ? true : false;
//ResumeRegistersFromStack();
fepRunStack = core.DebugProps.FRStack;
Properties = PopInterpreterProps();
Properties.executingGraphNode = core.DebugProps.executingGraphNode;
deferedGraphNodes = core.DebugProps.deferedGraphnodes;
}
else
{
PushInterpreterProps(Properties);
Properties.Reset();
}
if (false == fepRun)
{
if (core.DebugProps.isResume) // resume from a breakpoint,
{
pc = entry;
}
else
{
pc = istream.entrypoint;
rmem.FramePointer = rmem.Stack.Count;
}
}
else
{
pc = entry;
isGlobScope = false;
}
executingLanguage = exe.instrStreamList[exeblock].language;
if (Language.kAssociative == executingLanguage && !core.DebugProps.isResume)
{
if (fepRun)
{
int ci = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
int fi = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFunction).opdata;
UpdateMethodDependencyGraph(pc, fi, ci);
}
else
{
if (!core.Options.IsDeltaExecution)
{
UpdateLanguageBlockDependencyGraph(pc);
}
SetupGraphEntryPoint(pc);
}
}
Validity.Assert(null != rmem);
rmem.Executable = exe;
rmem.ClassTable = exe.classTable;
}
示例14: SetupExecutiveForCall
private void SetupExecutiveForCall(int exeblock, int entry)
{
PushInterpreterProps(Properties);
Properties.Reset();
if (core.ExecMode == InterpreterMode.kNormal)
{
exe = core.DSExecutable;
}
else if (core.ExecMode == InterpreterMode.kExpressionInterpreter)
{
exe = core.ExprInterpreterExe;
}
else
{
Validity.Assert(false, "Invalid execution mode");
}
fepRun = true;
isGlobScope = false;
executingBlock = exeblock;
istream = exe.instrStreamList[exeblock];
Validity.Assert(null != istream);
Validity.Assert(null != istream.instrList);
pc = entry;
executingLanguage = exe.instrStreamList[exeblock].language;
if (Language.kAssociative == executingLanguage)
{
int ci = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
int fi = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFunction).opdata;
UpdateMethodDependencyGraph(pc, fi, ci);
}
}
示例15: SetupExecutiveForCall
private void SetupExecutiveForCall(int exeblock, int entry)
{
PushInterpreterProps(Properties);
Properties.Reset();
if (runtimeCore.Options.RunMode == InterpreterMode.Normal)
{
exe = runtimeCore.DSExecutable;
}
else if (runtimeCore.Options.RunMode == InterpreterMode.Expression)
{
exe = runtimeCore.ExprInterpreterExe;
}
else
{
Validity.Assert(false, "Invalid execution mode");
}
fepRun = true;
executingBlock = exeblock;
istream = exe.instrStreamList[exeblock];
Validity.Assert(null != istream);
Validity.Assert(null != istream.instrList);
SetupGraphNodesInScope();
pc = entry;
executingLanguage = exe.instrStreamList[exeblock].language;
if (Language.Associative == executingLanguage)
{
int ci = rmem.GetAtRelative(StackFrame.FrameIndexClassIndex).ClassIndex;
int fi = rmem.GetAtRelative(StackFrame.FrameIndexFunctionIndex).FunctionIndex;
UpdateMethodDependencyGraph(pc, fi, ci);
}
}