Example #1
0
        internal AST GenerateAST(TokenStream tokens)
        {
            this.tokens = tokens;

            AST ast = new AST();

            while (TokensRemain)
            {
                switch (Current.type)
                {
                    case USE:
                        var loc = Location;
                        Advance();
                        var requirePath = "";
                        while (TokensRemain)
                        {
                            string ident;
                            ExpectIdentifier(out ident, "Identifier expected for kit path.");
                            requirePath += ident;
                            if (Check(DOT))
                            {
                                requirePath += ".";
                                Advance();
                            }
                            else break;
                        }
                        var use = new NodeUse(loc, requirePath);
                        ast.nodes.Add(use);
                        continue;
                    default:
                        var expr = Expression();
                        // We hit a huge problem, probably nothing left...
                        if (expr == null)
                            break;
                        ast.nodes.Add(expr);
                        continue;
                }
            }

            return ast;
        }
Example #2
0
 internal void Accept(NodeUse use)
 {
     // Not the best solution, but it works.
     builder.currentLineNumber = use.EndLine;
     builder.OpGLoad("std");
     builder.OpFLoad("require");
     builder.OpKit();
     builder.OpSConst(use.requirePath);
     builder.OpInvoke(2);
     // TODO builder.OpPop(); // ??
 }
Example #3
0
 void ASTVisitor.Accept(NodeUse value)
 {
     Accept(value);
 }
Example #4
0
        /// <summary>
        /// NodeDuration - Sort information from the rows returned from OpenJobAllocationHistoryEnumerator
        /// </summary>
        /// <param name="rows">RowSet, allocated Core information from the job, to be resorted into node allocation</param>
        private static void NodeDuration(ISchedulerRowEnumerator rows)
        {
            if (bVerbose)
            {
                Console.WriteLine("Entering NodeDuration");
            }

            TimeSpan tsTotal = new TimeSpan(0);

            List <NodeUse> nodeList = new List <NodeUse>();

            // Convert core rowset into node list
            foreach (PropertyRow row in rows)
            {
                // Find the last item in this list that uses this node
                int iIndex = nodeList.FindLastIndex(
                    delegate(NodeUse n)
                {
                    return(n.NodeId == (int)row[(int)RowIndex.NodeId].Value);
                }
                    );

                // If this node does not yet exist, or if the current start is beyond the endtime in the list, add a new list item
                if ((iIndex < 0) || (nodeList[iIndex].EndTime < (DateTime)row[(int)RowIndex.StartTime].Value))
                {
                    if (bVerbose)
                    {
                        Console.WriteLine("Add item to Node List");
                    }

                    // If the core is still running, set the end time to maximum so all other searches will be swallowed
                    DateTime coreEndTime = (row[(int)RowIndex.EndTime].Id == AllocationProperties.EndTime) ? (DateTime)row[(int)RowIndex.EndTime].Value : DateTime.MaxValue;
                    NodeUse  nu          = new NodeUse((int)row[(int)RowIndex.NodeId].Value,
                                                       (string)row[(int)RowIndex.NodeName].Value,
                                                       (DateTime)row[(int)RowIndex.StartTime].Value,
                                                       coreEndTime);
                    nodeList.Add(nu);
                    if (bVerbose)
                    {
                        Console.WriteLine("Added Node List item for: {0}", (string)row[(int)RowIndex.NodeName].Value);
                    }
                }
                else     // A node was found in the list that overlaps this core's duration
                {
                    if (row[(int)RowIndex.EndTime].Id != AllocationProperties.EndTime)
                    {
                        // If the current core is still running, set the end time to maximum
                        nodeList[iIndex].EndTime = DateTime.MaxValue;
                    }
                    else if ((DateTime)row[(int)RowIndex.EndTime].Value > nodeList[iIndex].EndTime)
                    {
                        // If the current core endtime is greater than the list node endtime, extend the nodes duration
                        nodeList[iIndex].EndTime = (DateTime)row[(int)RowIndex.EndTime].Value;
                    }
                }
            }
            if (bVerbose)
            {
                Console.WriteLine("Node List created");
            }
            // Add all node duration and display information if appropriate
            foreach (NodeUse nodeUse in nodeList)
            {
                // Show each node only if /detailed was set
                if (bDetailed)
                {
                    Console.Write("{0} {1} Start: {2} End: ",
                                  nodeUse.NodeName,
                                  nodeUse.NodeId,
                                  nodeUse.StartTime);
                    if (nodeUse.EndTime != DateTime.MaxValue)
                    {
                        Console.WriteLine((DateTime)nodeUse.EndTime);
                    }
                    else
                    {
                        Console.WriteLine(CORERUNNING);
                    }
                }
                if (bVerbose)
                {
                    Console.WriteLine("dtCurrent:  {0}", dtCurrent);
                }

                // If the node still has a core running, set the end length to the current time
                if (nodeUse.EndTime == DateTime.MaxValue)
                {
                    nodeUse.EndTime = dtCurrent;
                }

                // Add the amount of time spent on using this node
                tsTotal += nodeUse.EndTime - nodeUse.StartTime;
            }
            iAllJobThreads += nodeList.Count;
            tsAllJobUsage  += tsTotal;

            // Round up/down to seconds
            if (tsTotal.TotalSeconds >= iRoundToSecondsMinimum)
            {
                if (tsTotal.Milliseconds >= 500)
                {
                    tsTotal = tsTotal.Add(TimeSpan.FromSeconds(1));
                }
                tsTotal = TimeSpan.FromSeconds((int)tsTotal.TotalSeconds);
            }

            Console.WriteLine("Total nodes: {0} Total node usage: {1}", nodeList.Count, tsTotal);
            return;
        }