本文整理汇总了C#中AssociativeGraph类的典型用法代码示例。如果您正苦于以下问题:C# AssociativeGraph类的具体用法?C# AssociativeGraph怎么用?C# AssociativeGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AssociativeGraph类属于命名空间,在下文中一共展示了AssociativeGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetFinalGraphNodeRuntimeDependents
/// <summary>
/// This function sets the modified temp graphnodes to the last graphnode in a statement
/// </summary>
/// <param name="graphnode"></param>
public static void SetFinalGraphNodeRuntimeDependents(AssociativeGraph.GraphNode graphnode)
{
if (null != graphnode && graphnode.IsSSANode())
{
if (null != graphnode.lastGraphNode)
{
graphnode.lastGraphNode.symbolListWithinExpression.Add(graphnode.updateNodeRefList[0].nodeList[0].symbol);
}
}
}
示例2: LogSemanticError
public void LogSemanticError(string msg, string fileName = null, int line = -1, int col = -1, AssociativeGraph.GraphNode graphNode = null)
{
/*if (fileName == null)
{
fileName = "N.A.";
}*/
if (logErrors)
{
System.Console.WriteLine("{0}({1},{2}) Error:{3}", fileName, line, col, msg);
}
if (compileState.Options.IsDeltaExecution)
{
compileState.LogErrorInGlobalMap(ProtoLanguage.CompileStateTracker.ErrorType.Error, msg, fileName, line, col);
}
BuildData.ErrorEntry errorEntry = new BuildData.ErrorEntry
{
FileName = fileName,
Message = msg,
Line = line,
Col = col
};
errors.Add(errorEntry);
// Comment: This is true for example in Graph Execution mode
/*if (errorAsWarning)
{
if (graphNode != null)
{
graphNode.isDirty = false;
return;
}
}*/
OutputMessage outputmessage = new OutputMessage(OutputMessage.MessageType.Error, msg.Trim(), fileName, line, col);
if (MessageHandler != null)
{
MessageHandler.Write(outputmessage);
if (WebMsgHandler != null)
{
OutputMessage webOutputMsg = new OutputMessage(OutputMessage.MessageType.Error, msg.Trim(), "", line, col);
WebMsgHandler.Write(webOutputMsg);
}
if (!outputmessage.Continue)
throw new BuildHaltException(msg);
}
throw new BuildHaltException(msg);
}
示例3: UpdateDependencyGraph
/// <summary>
/// Check if an update is triggered;
/// Find all graph nodes whos dependents contain this symbol;
/// Mark those nodes as dirty
/// </summary>
public int UpdateDependencyGraph(
int exprUID,
int modBlkId,
bool isSSAAssign,
AssociativeGraph.GraphNode executingGraphNode,
bool propertyChanged = false)
{
int nodesMarkedDirty = 0;
if (executingGraphNode == null)
{
return nodesMarkedDirty;
}
int classIndex = executingGraphNode.classIndex;
int procIndex = executingGraphNode.procIndex;
var graph = istream.dependencyGraph;
var graphNodes = graph.GetGraphNodesAtScope(classIndex, procIndex);
if (graphNodes == null)
{
return nodesMarkedDirty;
}
//foreach (var graphNode in graphNodes)
for (int i = 0; i < graphNodes.Count; ++i)
{
var graphNode = graphNodes[i];
// If the graphnode is inactive then it is no longer executed
if (!graphNode.isActive)
{
continue;
}
//
// Comment Jun:
// This is clarifying the intention that if the graphnode is within the same SSA expression, we still allow update
//
bool allowUpdateWithinSSA = false;
if (core.Options.ExecuteSSA)
{
allowUpdateWithinSSA = true;
isSSAAssign = false; // Remove references to this when ssa flag is removed
// Do not update if its a property change and the current graphnode is the same expression
if (propertyChanged && graphNode.exprUID == Properties.executingGraphNode.exprUID)
{
continue;
}
}
else
{
// TODO Jun: Remove this code immediatley after enabling SSA
bool withinSSAStatement = graphNode.UID == executingGraphNode.UID;
allowUpdateWithinSSA = !withinSSAStatement;
}
if (!allowUpdateWithinSSA || (propertyChanged && graphNode == Properties.executingGraphNode))
{
continue;
}
foreach (var noderef in executingGraphNode.updateNodeRefList)
{
ProtoCore.AssociativeGraph.GraphNode matchingNode = null;
if (!graphNode.DependsOn(noderef, ref matchingNode))
{
continue;
}
// Jun: only allow update to other expr id's (other statements) if this is the final SSA assignment
if (core.Options.ExecuteSSA && !propertyChanged)
{
if (null != Properties.executingGraphNode && Properties.executingGraphNode.IsSSANode())
{
// This is still an SSA statement, if a node of another statement depends on it, ignore it
if (graphNode.exprUID != Properties.executingGraphNode.exprUID)
{
// Defer this update until the final non-ssa node
deferedGraphNodes.Add(graphNode);
continue;
}
}
}
// @keyu: if we are modifying an object's property, e.g.,
//
// foo.id = 42;
//
// both dependent list and update list of the corresponding
// graph node contains "foo" and "id", so if property "id"
// is changed, this graph node will be re-executed and the
// value of "id" is incorrectly set back to old value.
if (propertyChanged)
{
var depUpdateNodeRef = graphNode.dependentList[0].updateNodeRefList[0];
//.........这里部分代码省略.........
示例4: SetGraphNodeStackValueNull
private void SetGraphNodeStackValueNull(AssociativeGraph.GraphNode graphNode)
{
StackValue svNull = StackValue.Null;
SetGraphNodeStackValue(graphNode, svNull);
}
示例5: HasCyclicDependency
private bool HasCyclicDependency(AssociativeGraph.GraphNode node)
{
return node.counter > runtimeCore.Options.kDynamicCycleThreshold;
}
示例6: BuildRealDependencyForIdentList
protected void BuildRealDependencyForIdentList(AssociativeGraph.GraphNode graphNode)
{
if (ssaPointerStack.Count == 0)
{
return;
}
// Push all dependent pointers
ProtoCore.AST.AssociativeAST.IdentifierListNode identList = BuildIdentifierList(ssaPointerStack.Peek());
// Comment Jun: perhaps this can be an assert?
if (null != identList)
{
ProtoCore.Type type = new ProtoCore.Type();
type.UID = globalClassIndex;
ProtoCore.AssociativeGraph.UpdateNodeRef nodeRef = new AssociativeGraph.UpdateNodeRef();
int functionIndex = globalProcIndex;
DFSGetSymbolList_Simple(identList, ref type, ref functionIndex, nodeRef);
if (null != graphNode && nodeRef.nodeList.Count > 0)
{
ProtoCore.AssociativeGraph.GraphNode dependentNode = new ProtoCore.AssociativeGraph.GraphNode();
dependentNode.updateNodeRefList.Add(nodeRef);
graphNode.PushDependent(dependentNode);
// If the pointerList is a setter, then it should also be in the lhs of a graphNode
// Given:
// a.x = 1
// Which was converted to:
// tvar = a.set_x(1)
// Set a.x as lhs of the graphnode.
// This means that statement that depends on a.x can re-execute, such as:
// p = a.x;
//
List<ProtoCore.AST.AssociativeAST.AssociativeNode> topList = ssaPointerStack.Peek();
string propertyName = topList[topList.Count - 1].Name;
bool isSetter = propertyName.StartsWith(Constants.kSetterPrefix);
if (isSetter)
{
graphNode.updateNodeRefList.Add(nodeRef);
graphNode.IsLHSIdentList = true;
AutoGenerateUpdateArgumentReference(nodeRef, graphNode);
}
}
}
}
示例7: EmitStringNode
protected void EmitStringNode(
Node node,
ref Type inferedType,
AssociativeGraph.GraphNode graphNode = null,
ProtoCore.CompilerDefinitions.Associative.SubCompilePass subPass = ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kNone)
{
if (subPass == ProtoCore.CompilerDefinitions.Associative.SubCompilePass.kUnboundIdentifier)
{
return;
}
dynamic sNode = node;
if (!enforceTypeCheck || core.TypeSystem.IsHigherRank((int)PrimitiveType.kTypeString, inferedType.UID))
{
inferedType.UID = (int)PrimitiveType.kTypeString;
}
if (core.Options.TempReplicationGuideEmptyFlag && emitReplicationGuide)
{
EmitInstrConsole(ProtoCore.DSASM.kw.push, 0 + "[guide]");
StackValue opNumGuides = StackValue.BuildReplicationGuide(0);
EmitPush(opNumGuides);
}
string value = (string)sNode.Value;
StackValue svString = core.Heap.AllocateFixedString(value);
if (core.Options.TempReplicationGuideEmptyFlag && emitReplicationGuide)
{
EmitInstrConsole(kw.pushg, "\"" + value + "\"");
EmitPushG(svString, node.line, node.col);
}
else
{
EmitInstrConsole(kw.push, "\"" + value + "\"");
EmitPush(svString, node.line, node.col);
}
if (IsAssociativeArrayIndexing && graphNode != null && graphNode.isIndexingLHS)
{
SymbolNode literalSymbol = new SymbolNode();
literalSymbol.name = value;
var dimNode = new AssociativeGraph.UpdateNode();
dimNode.symbol = literalSymbol;
dimNode.nodeType = AssociativeGraph.UpdateNodeType.kLiteral;
graphNode.dimensionNodeList.Add(dimNode);
}
}
示例8: PushGraphNode
/// <summary>
/// Append the graphnode to the instruction stream and procedure nodes
/// </summary>
/// <param name="graphnode"></param>
protected void PushGraphNode(AssociativeGraph.GraphNode graphnode)
{
codeBlock.instrStream.dependencyGraph.Push(graphnode);
if (globalProcIndex != Constants.kGlobalScope)
{
localProcedure.GraphNodeList.Add(graphnode);
}
}
示例9: UpdateGraphNodeDependency
//
// Comment Jun: Revised
//
// proc UpdateGraphNodeDependency(execnode)
// foreach node in graphnodelist
// if execnode.lhs is equal to node.lhs
// if execnode.HasDependents()
// if execnode.Dependents() is not equal to node.Dependents()
// node.RemoveDependents()
// end
// end
// end
// end
// end
//
private void UpdateGraphNodeDependency(AssociativeGraph.GraphNode gnode, AssociativeGraph.GraphNode executingNode)
{
if (gnode.UID >= executingNode.UID // for previous graphnodes
|| gnode.updateNodeRefList.Count == 0
|| gnode.updateNodeRefList.Count != executingNode.updateNodeRefList.Count
|| gnode.isAutoGenerated)
{
return;
}
for (int n = 0; n < executingNode.updateNodeRefList.Count; ++n)
{
if (!gnode.updateNodeRefList[n].IsEqual(executingNode.updateNodeRefList[n]))
{
return;
}
}
//if (executingNode.dependentList.Count > 0)
{
// if execnode.Dependents() is not equal to node.Dependents()
// TODO Jun: Extend this check
bool areDependentsEqual = false;
if (!areDependentsEqual)
{
gnode.dependentList.Clear();
}
}
}
示例10: SetGraphNodeStackValueNull
private void SetGraphNodeStackValueNull(AssociativeGraph.GraphNode graphNode)
{
StackValue svNull = StackUtils.BuildNull();
SetGraphNodeStackValue(graphNode, svNull);
}
示例11: SetUpStepOverFunctionCalls
public void SetUpStepOverFunctionCalls(ProtoCore.Core core, ProcedureNode fNode, AssociativeGraph.GraphNode graphNode, bool hasDebugInfo)
{
int tempPC = DebugEntryPC;
int limit = 0; // end pc of current expression
InstructionStream istream;
int pc = tempPC;
if (core.DebugProps.InlineConditionOptions.isInlineConditional == true)
{
tempPC = InlineConditionOptions.startPc;
limit = InlineConditionOptions.endPc;
istream = core.DSExecutable.instrStreamList[InlineConditionOptions.instructionStream];
}
else
{
pc = tempPC;
istream = core.DSExecutable.instrStreamList[core.RunningBlock];
if (istream.language == Language.kAssociative)
{
limit = FindEndPCForAssocGraphNode(pc, istream, fNode, graphNode, core.Options.ExecuteSSA);
//Validity.Assert(limit != ProtoCore.DSASM.Constants.kInvalidIndex);
}
else if (istream.language == Language.kImperative)
{
// Check for 'SETEXPUID' instruction to check for end of expression
while (++pc < istream.instrList.Count)
{
Instruction instr = istream.instrList[pc];
if (instr.opCode == OpCode.SETEXPUID)
{
limit = pc;
break;
}
}
}
}
// Determine if this is outermost CALLR in the expression
// until then do not restore any breakpoints
// If outermost CALLR, restore breakpoints after end of expression
pc = tempPC;
int numNestedFunctionCalls = 0;
while (++pc <= limit)
{
Instruction instr = istream.instrList[pc];
if (instr.opCode == OpCode.CALLR && instr.debug != null)
{
numNestedFunctionCalls++;
}
}
if (numNestedFunctionCalls == 0)
{
// If this is the outermost function call
core.Breakpoints.Clear();
core.Breakpoints.AddRange(AllbreakPoints);
pc = tempPC;
while (++pc <= limit)
{
Instruction instr = istream.instrList[pc];
// We still want to break at the closing brace of a function or ctor call or language block
if (instr.debug != null && instr.opCode != OpCode.RETC && instr.opCode != OpCode.RETURN &&
(instr.opCode != OpCode.RETB))
{
if (core.Breakpoints.Contains(instr))
core.Breakpoints.Remove(instr);
}
}
}
}
示例12: FindEndPCForAssocGraphNode
private int FindEndPCForAssocGraphNode(int tempPC, InstructionStream istream, ProcedureNode fNode, AssociativeGraph.GraphNode graphNode, bool handleSSATemps)
{
int limit = Constants.kInvalidIndex;
//AssociativeGraph.GraphNode currentGraphNode = executingGraphNode;
AssociativeGraph.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;
AssociativeGraph.GraphNode nextGraphNode = currentGraphNode;
while (currentGraphNode.exprUID != ProtoCore.DSASM.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;
}
示例13: UpdateDependencyGraph
/// <summary>
/// Check if an update is triggered;
/// Find all graph nodes whos dependents contain this symbol;
/// Mark those nodes as dirty
/// </summary>
public int UpdateDependencyGraph(
int exprUID,
int modBlkId,
bool isSSAAssign,
AssociativeGraph.GraphNode executingGraphNode,
bool propertyChanged = false)
{
int nodesMarkedDirty = 0;
if (executingGraphNode == null)
{
return nodesMarkedDirty;
}
int classIndex = executingGraphNode.classIndex;
int procIndex = executingGraphNode.procIndex;
var graph = istream.dependencyGraph;
var graphNodes = graph.GetGraphNodesAtScope(classIndex, procIndex);
if (graphNodes == null)
{
return nodesMarkedDirty;
}
foreach (var graphNode in graphNodes)
{
//
// Comment Jun:
// This is clarifying the intention that if the graphnode is within the same SSA expression, we still allow update
//
bool allowUpdateWithinSSA = true;
if (!allowUpdateWithinSSA || (propertyChanged && graphNode == Properties.executingGraphNode))
{
continue;
}
foreach (var noderef in executingGraphNode.updateNodeRefList)
{
ProtoCore.AssociativeGraph.GraphNode matchingNode = null;
if (!graphNode.DependsOn(noderef, ref matchingNode))
{
continue;
}
// @keyu: if we are modifying an object's property, e.g.,
//
// foo.id = 42;
//
// both dependent list and update list of the corresponding
// graph node contains "foo" and "id", so if property "id"
// is changed, this graph node will be re-executed and the
// value of "id" is incorrectly set back to old value.
if (propertyChanged)
{
var depUpdateNodeRef = graphNode.dependentList[0].updateNodeRefList[0];
if (graphNode.updateNodeRefList.Count == 1)
{
var updateNodeRef = graphNode.updateNodeRefList[0];
if (depUpdateNodeRef.IsEqual(updateNodeRef))
{
continue;
}
}
}
//
// Comment Jun: We dont want to cycle between such statements:
//
// a1.a = 1;
// a1.a = 10;
//
Validity.Assert(null != matchingNode);
bool isLHSModification = matchingNode.isLHSNode;
bool isUpdateable = matchingNode.IsUpdateableBy(noderef);
// isSSAAssign means this is the graphnode of the final SSA assignment
// Overrride this if allowing within SSA update
// TODO Jun: Remove this code when SSA is completely enabled
bool allowSSADownstream = graphNode.UID > executingGraphNode.UID;
// Comment Jun:
// If the triggered dependent graphnode is LHS
// and...
// the triggering node (executing graphnode)
if (isLHSModification && !isUpdateable)
{
break;
}
// TODO Jun: Optimization - Reimplement update delta evaluation using registers
//if (IsNodeModified(EX, FX))
if (exprUID != graphNode.exprUID && modBlkId != graphNode.modBlkUID)
{
UpdateModifierBlockDependencyGraph(graphNode);
//.........这里部分代码省略.........
示例14: DfsEmitArrayIndexHeap
protected int DfsEmitArrayIndexHeap(Node node, AssociativeGraph.GraphNode graphNode = null, ProtoCore.AST.Node parentNode = null, ProtoCore.DSASM.AssociativeSubCompilePass subPass = ProtoCore.DSASM.AssociativeSubCompilePass.kNone)
{
int indexCnt = 0;
Debug.Assert(node is ProtoCore.AST.AssociativeAST.ArrayNode || node is ProtoCore.AST.ImperativeAST.ArrayNode);
IsAssociativeArrayIndexing = true;
dynamic arrayNode = node;
while (arrayNode is ProtoCore.AST.AssociativeAST.ArrayNode || arrayNode is ProtoCore.AST.ImperativeAST.ArrayNode)
{
++indexCnt;
dynamic array = arrayNode;
ProtoCore.Type lastType = new ProtoCore.Type();
lastType.UID = (int)PrimitiveType.kTypeVoid;
lastType.IsIndexable = false;
DfsTraverse(array.Expr, ref lastType, false, graphNode, subPass, parentNode);
arrayNode = array.Type;
}
IsAssociativeArrayIndexing = false;
return indexCnt;
}
示例15: EmitStringNode
protected void EmitStringNode(
Node node,
ref Type inferedType,
AssociativeGraph.GraphNode graphNode = null,
AssociativeSubCompilePass subPass = AssociativeSubCompilePass.kNone)
{
if (subPass == AssociativeSubCompilePass.kUnboundIdentifier)
{
return;
}
dynamic sNode = node;
if (!enforceTypeCheck || core.TypeSystem.IsHigherRank((int)PrimitiveType.kTypeString, inferedType.UID))
{
inferedType.UID = (int)PrimitiveType.kTypeString;
}
Byte[] utf8bytes = EncodingUtils.UTF8StringToUTF8Bytes((String)sNode.value);
String value = Encoding.UTF8.GetString(utf8bytes);
foreach (char ch in value)
{
String strValue = "'" + ch + "'";
EmitInstrConsole(kw.push, strValue);
StackValue op = StackValue.BuildChar(ch);
EmitPush(op, node.line, node.col);
}
if (IsAssociativeArrayIndexing && graphNode != null && graphNode.isIndexingLHS)
{
SymbolNode literalSymbol = new SymbolNode();
literalSymbol.name = value;
var dimNode = new AssociativeGraph.UpdateNode();
dimNode.symbol = literalSymbol;
dimNode.nodeType = AssociativeGraph.UpdateNodeType.kLiteral;
graphNode.dimensionNodeList.Add(dimNode);
}
EmitInstrConsole(kw.alloca, value.Length.ToString());
EmitPopString(value.Length);
}