/*
 *          private void ReportBuildErrorsAndWarnings(string code, SynchronizeData syncDataReturn, Dictionary<uint, string> modifiedGuidList, ref GraphUpdateReadyEventArgs retArgs)
 *          {
 *              //GraphUpdateReadyEventArgs retArgs = null;
 *              if (runner.compileState.BuildStatus.ErrorCount > 0)
 *              {
 *                  retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
 *
 *                  foreach (var err in runner.compileState.BuildStatus.Errors)
 *                  {
 *                      string msg = err.Message;
 *                      int lineNo = err.Line;
 *
 *                      // TODO: How can the lineNo be invalid ?
 *                      if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
 *                      {
 *                          retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
 *                          continue;
 *                      }
 *
 *                      string varName = GetVarNameFromCode(lineNo, code);
 *
 *                      foreach (var ssnode in syncData.AddedNodes)
 *                      {
 *                          if (ssnode.Content.Contains(varName))
 *                          {
 *                              uint id = ssnode.Id;
 *
 *                              retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
 *                              break;
 *                          }
 *                      }
 *                      if (retArgs.Errors.Count == 0)
 *                      {
 *                          foreach (var ssnode in syncData.ModifiedNodes)
 *                          {
 *                              if (ssnode.Content.Contains(varName))
 *                              {
 *                                  uint id = ssnode.Id;
 *
 *                                  retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
 *                                  break;
 *                              }
 *                          }
 *                      }
 *                  }
 *              }
 *              if (runner.compileState.BuildStatus.WarningCount > 0)
 *              {
 *                  if (retArgs == null)
 *                      retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
 *
 *                  foreach (var warning in runner.compileState.BuildStatus.Warnings)
 *                  {
 *                      string msg = warning.msg;
 *                      int lineNo = warning.line;
 *
 *                      // TODO: How can the lineNo be invalid ?
 *                      if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
 *                      {
 *                          retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
 *                          continue;
 *                      }
 *
 *                      string varName = GetVarNameFromCode(lineNo, code);
 *
 *                      // This array should be empty for Build errors
 *
 *                      foreach (var kvp in modifiedGuidList)
 *                      {
 *                          // Get the uid recognized by the graphIDE
 *                          uint guid = kvp.Key;
 *                          string name = kvp.Value;
 *                          if (name.Equals(varName))
 *                          {
 *                              retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = runner.graphCompiler.GetRealUID(guid) });
 *                              break;
 *                          }
 *                      }
 *
 *                      if (retArgs.Warnings.Count == 0)
 *                      {
 *                          LogWarningsFromInputNodes(retArgs, varName, msg);
 *                      }
 *
 *                  }
 *              }
 *
 *          }
 */
            void LogWarningsFromInputNodes(GraphUpdateReadyEventArgs retArgs, string varName, string msg)
            {
                foreach (var ssnode in syncData.AddedNodes)
                {
                    if (ssnode.Content.Contains(varName))
                    {
                        uint id = ssnode.Id;

                        retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                            Message = msg, Id = id
                        });
                        break;
                    }
                }

                if (retArgs.Warnings.Count == 0)
                {
                    foreach (var ssnode in syncData.ModifiedNodes)
                    {
                        if (ssnode.Content.Contains(varName))
                        {
                            uint id = ssnode.Id;

                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                Message = msg, Id = id
                            });
                            break;
                        }
                    }
                }
            }
            public override void Execute()
            {
                if (!objectCreationGraphNode.propertyChanged)
                {
                    return;
                }
                objectCreationGraphNode.propertyChanged = false;
                UpdateNodeRef updateNode = objectCreationGraphNode.updateNodeRefList[0];

                GraphUpdateReadyEventArgs retArgs = null;

                lock (runner.operationsMutex)
                {
                    try
                    {
                        // @keyu: graph nodes may have been recreated caused of
                        // some update on the UI so that we have to find out
                        // new graph code that create this ffi object.
                        var graph      = runner.runnerCore.DSExecutable.instrStreamList[0].dependencyGraph;
                        var graphnodes = graph.GetGraphNodesAtScope(this.objectCreationGraphNode.classIndex, this.objectCreationGraphNode.procIndex);
                        foreach (var graphnode in graphnodes)
                        {
                            if ((graphnode == objectCreationGraphNode) ||
                                (graphnode.updateNodeRefList.Count == 1 &&
                                 updateNode.IsEqual(graphnode.updateNodeRefList[0])))
                            {
                                graphnode.propertyChanged = true;
                                break;
                            }
                        }

                        runner.ResetVMForExecution();
                        runner.Execute();

                        var modfiedGuidList = runner.GetModifiedGuidList();
                        runner.ResetModifiedSymbols();
                        var syncDataReturn = runner.CreateSynchronizeDataForGuidList(modfiedGuidList);
                        retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                    }
                    catch (Exception e)
                    {
                        retArgs = new GraphUpdateReadyEventArgs(new SynchronizeData(),
                                                                EventStatus.Error,
                                                                e.Message);
                    }
                }

                if (runner.GraphUpdateReady != null)
                {
                    runner.GraphUpdateReady(this, retArgs);
                }
            }
            private void ReportRuntimeWarnings(string code, SynchronizeData syncDataReturn, Dictionary <uint, string> modifiedGuidList, ref GraphUpdateReadyEventArgs retArgs)
            {
                //GraphUpdateReadyEventArgs retArgs = null;

                if (runner.runnerCore.RuntimeStatus.Warnings.Count > 0)
                {
                    if (retArgs == null)
                    {
                        retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                    }

                    foreach (var err in runner.runnerCore.RuntimeStatus.Warnings)
                    {
                        string msg    = err.message;
                        int    lineNo = err.Line;

                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
                        {
                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                Message = msg, Id = 0
                            });
                            continue;
                        }

                        string varName = GetVarNameFromCode(lineNo, code);

                        foreach (var kvp in modifiedGuidList)
                        {
                            // Get the uid recognized by the graphIDE
                            uint   guid = kvp.Key;
                            string name = kvp.Value;
                            if (name.Equals(varName))
                            {
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                    Message = msg, Id = runner.graphCompiler.GetRealUID(guid)
                                });
                                break;
                            }
                        }

                        if (retArgs.Warnings.Count == 0)
                        {
                            LogWarningsFromInputNodes(retArgs, varName, msg);
                        }
                    }
                }
            }
            public override void Execute()
            {
                GraphUpdateReadyEventArgs retArgs;

                lock (runner.operationsMutex)
                {
                    try
                    {
                        string code = null;
                        runner.SynchronizeInternal(syncData, out code);

                        var modfiedGuidList = runner.GetModifiedGuidList();
                        runner.ResetModifiedSymbols();
                        var syncDataReturn = runner.CreateSynchronizeDataForGuidList(modfiedGuidList);

                        retArgs = null;

                        ReportErrors(code, syncDataReturn, modfiedGuidList, ref retArgs);

                        //ReportBuildErrorsAndWarnings(code, syncDataReturn, modfiedGuidList, ref retArgs);
                        //ReportRuntimeWarnings(code, syncDataReturn, modfiedGuidList, ref retArgs);

                        if (retArgs == null)
                        {
                            retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                        }
                    }
                    // Any exceptions that are caught here are most likely from the graph compiler
                    catch (Exception e)
                    {
                        retArgs = new GraphUpdateReadyEventArgs(syncData, EventStatus.Error, e.Message);
                    }
                }

                if (runner.GraphUpdateReady != null)
                {
                    runner.GraphUpdateReady(this, retArgs); // Notify all listeners (e.g. UI).
                }
            }
 /// <summary>
 /// GraphUpdateReady event handler.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void GraphUpdateReady(object sender, GraphUpdateReadyEventArgs e)
 {
     if (EventStatus.OK == e.ResultStatus)
     {
     }
 }
            private void ReportRuntimeWarnings(string code, SynchronizeData syncDataReturn, Dictionary<uint, string> modifiedGuidList, ref GraphUpdateReadyEventArgs retArgs)
            {
                //GraphUpdateReadyEventArgs retArgs = null;

                if (runner.runnerCore.RuntimeStatus.Warnings.Count > 0)
                {
                    if (retArgs == null)
                        retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);

                    foreach (var err in runner.runnerCore.RuntimeStatus.Warnings)
                    {
                        string msg = err.message;
                        int lineNo = err.Line;

                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
                        {
                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
                            continue;
                        }

                        string varName = GetVarNameFromCode(lineNo, code);

                        foreach (var kvp in modifiedGuidList)
                        {
                            // Get the uid recognized by the graphIDE
                            uint guid = kvp.Key;
                            string name = kvp.Value;
                            if (name.Equals(varName))
                            {
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = runner.graphCompiler.GetRealUID(guid) });
                                break;
                            }
                        }

                        if (retArgs.Warnings.Count == 0)
                        {
                            LogWarningsFromInputNodes(retArgs, varName, msg);
                        }
                    }
                }
            }
            private void ReportErrors(string code, SynchronizeData syncDataReturn, Dictionary<uint, string> modifiedGuidList, ref GraphUpdateReadyEventArgs retArgs)
            {
                Dictionary<ulong, ProtoCore.Core.ErrorEntry> errorMap = runner.runnerCore.LocationErrorMap;

                if (errorMap.Count == 0)
                    return;

                retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                foreach (var kvp in errorMap)
                {
                    ProtoCore.Core.ErrorEntry err = kvp.Value;
                    string msg = err.Message;
                    int lineNo = err.Line;

                    // If error is a Build error
                    if (err.BuildId != ProtoCore.BuildData.WarningID.kDefault)
                    {
                        // Error comes from imported DS file
                        if (!string.IsNullOrEmpty(err.FileName))
                        {
                            msg += " At line " + err.Line + ", column " + err.Col + ", in " + Path.GetFileName(err.FileName);
                            if (err.Type == ProtoCore.Core.ErrorType.Error)
                            {
                                retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
                            }
                            else if (err.Type == ProtoCore.Core.ErrorType.Warning)
                            {
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
                            }
                            continue;
                        }

                    }

                    string varName = GetVarNameFromCode(lineNo, code);

                    // Errors
                    if (err.Type == ProtoCore.Core.ErrorType.Error)
                    {
                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex || varName == null)
                        {
                            retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
                            continue;
                        }

                        foreach (var pair in runner.graphCompiler.mapModifiedName)
                        {
                            string name = pair.Key;
                            if (name.Equals(varName))
                            {
                                uint guid = pair.Value;
                                retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = runner.graphCompiler.GetRealUID(guid) });
                                break;
                            }

                        }
                    }
                    else if (err.Type == ProtoCore.Core.ErrorType.Warning) // Warnings
                    {
                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex || varName == null)
                        {
                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
                            continue;
                        }

                        foreach (var pair in modifiedGuidList)
                        {
                            // Get the uid recognized by the graphIDE
                            string name = pair.Value;
                            if (name.Equals(varName))
                            {
                                uint guid = pair.Key;
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = runner.graphCompiler.GetRealUID(guid) });
                                break;
                            }
                        }
                        if (retArgs.Warnings.Count == 0)
                        {
                            foreach (var pair in runner.graphCompiler.mapModifiedName)
                            {
                                string name = pair.Key;
                                if (name.Equals(varName))
                                {
                                    uint guid = pair.Value;
                                    retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = runner.graphCompiler.GetRealUID(guid) });
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            private void ReportBuildErrorsAndWarnings(string code, SynchronizeData syncDataReturn, Dictionary<uint, string> modifiedGuidList, ref GraphUpdateReadyEventArgs retArgs)
            {
                //GraphUpdateReadyEventArgs retArgs = null;
                if (runner.compileState.BuildStatus.ErrorCount > 0)
                {
                    retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);

                    foreach (var err in runner.compileState.BuildStatus.Errors)
                    {
                        string msg = err.Message;
                        int lineNo = err.Line;

                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
                        {
                            retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
                            continue;
                        }

                        string varName = GetVarNameFromCode(lineNo, code);

                        foreach (var ssnode in syncData.AddedNodes)
                        {
                            if (ssnode.Content.Contains(varName))
                            {
                                uint id = ssnode.Id;

                                retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
                                break;
                            }
                        }
                        if (retArgs.Errors.Count == 0)
                        {
                            foreach (var ssnode in syncData.ModifiedNodes)
                            {
                                if (ssnode.Content.Contains(varName))
                                {
                                    uint id = ssnode.Id;

                                    retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
                                    break;
                                }
                            }
                        }
                    }
                }
                if (runner.compileState.BuildStatus.WarningCount > 0)
                {
                    if (retArgs == null)
                        retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);

                    foreach (var warning in runner.compileState.BuildStatus.Warnings)
                    {
                        string msg = warning.msg;
                        int lineNo = warning.line;

                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
                        {
                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = 0 });
                            continue;
                        }

                        string varName = GetVarNameFromCode(lineNo, code);

                        // This array should be empty for Build errors

                        /*foreach (var ssnode in syncDataReturn.ModifiedNodes)
                        {
                            if(ssnode.Content.Contains(varName))
                            {
                                uint id = ssnode.Id;

                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
                                break;
                            }
                        }*/
                        foreach (var kvp in modifiedGuidList)
                        {
                            // Get the uid recognized by the graphIDE
                            uint guid = kvp.Key;
                            string name = kvp.Value;
                            if (name.Equals(varName))
                            {
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = runner.graphCompiler.GetRealUID(guid) });
                                break;
                            }
                        }

                        if (retArgs.Warnings.Count == 0)
                        {
                            LogWarningsFromInputNodes(retArgs, varName, msg);
                        }

                    }
                }
            }
            void LogWarningsFromInputNodes(GraphUpdateReadyEventArgs retArgs, string varName, string msg)
            {
                foreach (var ssnode in syncData.AddedNodes)
                {
                    if (ssnode.Content.Contains(varName))
                    {
                        uint id = ssnode.Id;

                        retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
                        break;
                    }
                }

                if (retArgs.Warnings.Count == 0)
                {
                    foreach (var ssnode in syncData.ModifiedNodes)
                    {
                        if (ssnode.Content.Contains(varName))
                        {
                            uint id = ssnode.Id;

                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
                            break;
                        }
                    }
                }
            }
            public override void Execute()
            {
                GraphUpdateReadyEventArgs retArgs;

                lock (runner.operationsMutex)
                {
                    try
                    {
                        string code = null;
                        runner.SynchronizeInternal(syncData, out code);

                        var modfiedGuidList = runner.GetModifiedGuidList();
                        runner.ResetModifiedSymbols();
                        var syncDataReturn = runner.CreateSynchronizeDataForGuidList(modfiedGuidList);

                        retArgs = null;

                        ReportErrors(code, syncDataReturn, modfiedGuidList, ref retArgs);

                        //ReportBuildErrorsAndWarnings(code, syncDataReturn, modfiedGuidList, ref retArgs);
                        //ReportRuntimeWarnings(code, syncDataReturn, modfiedGuidList, ref retArgs);

                        if (retArgs == null)
                            retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                    }
                    // Any exceptions that are caught here are most likely from the graph compiler
                    catch (Exception e)
                    {
                        retArgs = new GraphUpdateReadyEventArgs(syncData, EventStatus.Error, e.Message);
                    }
                }

                if (runner.GraphUpdateReady != null)
                {
                    runner.GraphUpdateReady(this, retArgs); // Notify all listeners (e.g. UI).
                }
            }
            public override void Execute()
            {
                if (!objectCreationGraphNode.propertyChanged)
                {
                    return;
                }
                objectCreationGraphNode.propertyChanged = false;
                UpdateNodeRef updateNode = objectCreationGraphNode.updateNodeRefList[0];

                GraphUpdateReadyEventArgs retArgs = null;
                lock (runner.operationsMutex)
                {
                    try
                    {
                        // @keyu: graph nodes may have been recreated caused of
                        // some update on the UI so that we have to find out
                        // new graph code that create this ffi object.
                        var graph = runner.runnerCore.DSExecutable.instrStreamList[0].dependencyGraph;
                        var graphnodes = graph.GetGraphNodesAtScope(this.objectCreationGraphNode.classIndex, this.objectCreationGraphNode.procIndex);
                        foreach (var graphnode in graphnodes)
                        {
                            if ((graphnode == objectCreationGraphNode) ||
                                (graphnode.updateNodeRefList.Count == 1 &&
                                 updateNode.IsEqual(graphnode.updateNodeRefList[0])))
                            {
                                graphnode.propertyChanged = true;
                                break;
                            }
                        }

                        runner.ResetVMForExecution();
                        runner.Execute();

                        var modfiedGuidList = runner.GetModifiedGuidList();
                        runner.ResetModifiedSymbols();
                        var syncDataReturn = runner.CreateSynchronizeDataForGuidList(modfiedGuidList);
                        retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                    }
                    catch (Exception e)
                    {
                        retArgs = new GraphUpdateReadyEventArgs(new SynchronizeData(),
                                                                EventStatus.Error,
                                                                e.Message);
                    }
                }

                if (runner.GraphUpdateReady != null)
                {
                    runner.GraphUpdateReady(this, retArgs);
                }
            }
            private void ReportErrors(string code, SynchronizeData syncDataReturn, Dictionary <uint, string> modifiedGuidList, ref GraphUpdateReadyEventArgs retArgs)
            {
                Dictionary <ulong, ProtoCore.Core.ErrorEntry> errorMap = runner.runnerCore.LocationErrorMap;

                if (errorMap.Count == 0)
                {
                    return;
                }

                retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                foreach (var kvp in errorMap)
                {
                    ProtoCore.Core.ErrorEntry err = kvp.Value;
                    string msg    = err.Message;
                    int    lineNo = err.Line;

                    // If error is a Build error
                    if (err.BuildId != ProtoCore.BuildData.WarningID.kDefault)
                    {
                        // Error comes from imported DS file
                        if (!string.IsNullOrEmpty(err.FileName))
                        {
                            msg += " At line " + err.Line + ", column " + err.Col + ", in " + Path.GetFileName(err.FileName);
                            if (err.Type == ProtoCore.Core.ErrorType.Error)
                            {
                                retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                    Message = msg, Id = 0
                                });
                            }
                            else if (err.Type == ProtoCore.Core.ErrorType.Warning)
                            {
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                    Message = msg, Id = 0
                                });
                            }
                            continue;
                        }
                    }

                    string varName = GetVarNameFromCode(lineNo, code);

                    // Errors
                    if (err.Type == ProtoCore.Core.ErrorType.Error)
                    {
                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex || varName == null)
                        {
                            retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                Message = msg, Id = 0
                            });
                            continue;
                        }

                        foreach (var pair in runner.graphCompiler.mapModifiedName)
                        {
                            string name = pair.Key;
                            if (name.Equals(varName))
                            {
                                uint guid = pair.Value;
                                retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                    Message = msg, Id = runner.graphCompiler.GetRealUID(guid)
                                });
                                break;
                            }
                        }
                    }
                    else if (err.Type == ProtoCore.Core.ErrorType.Warning) // Warnings
                    {
                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex || varName == null)
                        {
                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                Message = msg, Id = 0
                            });
                            continue;
                        }

                        foreach (var pair in modifiedGuidList)
                        {
                            // Get the uid recognized by the graphIDE
                            string name = pair.Value;
                            if (name.Equals(varName))
                            {
                                uint guid = pair.Key;
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                    Message = msg, Id = runner.graphCompiler.GetRealUID(guid)
                                });
                                break;
                            }
                        }
                        if (retArgs.Warnings.Count == 0)
                        {
                            foreach (var pair in runner.graphCompiler.mapModifiedName)
                            {
                                string name = pair.Key;
                                if (name.Equals(varName))
                                {
                                    uint guid = pair.Value;
                                    retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                        Message = msg, Id = runner.graphCompiler.GetRealUID(guid)
                                    });
                                    break;
                                }
                            }
                        }
                    }
                }
            }
Exemple #13
0
            private void ReportBuildErrorsAndWarnings(string code, SynchronizeData syncDataReturn, Dictionary <uint, string> modifiedGuidList, ref GraphUpdateReadyEventArgs retArgs)
            {
                //GraphUpdateReadyEventArgs retArgs = null;
                if (runner.compileState.BuildStatus.ErrorCount > 0)
                {
                    retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);

                    foreach (var err in runner.compileState.BuildStatus.Errors)
                    {
                        string msg    = err.Message;
                        int    lineNo = err.Line;

                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
                        {
                            retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                Message = msg, Id = 0
                            });
                            continue;
                        }

                        string varName = GetVarNameFromCode(lineNo, code);

                        foreach (var ssnode in syncData.AddedNodes)
                        {
                            if (ssnode.Content.Contains(varName))
                            {
                                uint id = ssnode.Id;

                                retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                    Message = msg, Id = id
                                });
                                break;
                            }
                        }
                        if (retArgs.Errors.Count == 0)
                        {
                            foreach (var ssnode in syncData.ModifiedNodes)
                            {
                                if (ssnode.Content.Contains(varName))
                                {
                                    uint id = ssnode.Id;

                                    retArgs.Errors.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                        Message = msg, Id = id
                                    });
                                    break;
                                }
                            }
                        }
                    }
                }
                if (runner.compileState.BuildStatus.WarningCount > 0)
                {
                    if (retArgs == null)
                    {
                        retArgs = new GraphUpdateReadyEventArgs(syncDataReturn);
                    }

                    foreach (var warning in runner.compileState.BuildStatus.Warnings)
                    {
                        string msg    = warning.msg;
                        int    lineNo = warning.line;

                        // TODO: How can the lineNo be invalid ?
                        if (lineNo == ProtoCore.DSASM.Constants.kInvalidIndex)
                        {
                            retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                Message = msg, Id = 0
                            });
                            continue;
                        }

                        string varName = GetVarNameFromCode(lineNo, code);

                        // This array should be empty for Build errors

                        /*foreach (var ssnode in syncDataReturn.ModifiedNodes)
                         * {
                         *  if(ssnode.Content.Contains(varName))
                         *  {
                         *      uint id = ssnode.Id;
                         *
                         *      retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject { Message = msg, Id = id });
                         *      break;
                         *  }
                         * }*/
                        foreach (var kvp in modifiedGuidList)
                        {
                            // Get the uid recognized by the graphIDE
                            uint   guid = kvp.Key;
                            string name = kvp.Value;
                            if (name.Equals(varName))
                            {
                                retArgs.Warnings.Add(new GraphUpdateReadyEventArgs.ErrorObject {
                                    Message = msg, Id = runner.graphCompiler.GetRealUID(guid)
                                });
                                break;
                            }
                        }

                        if (retArgs.Warnings.Count == 0)
                        {
                            LogWarningsFromInputNodes(retArgs, varName, msg);
                        }
                    }
                }
            }