コード例 #1
0
        /// <summary>
        /// Creates "withQualifier: typeof qualifier"
        /// </summary>
        private static NodeArray <IParameterDeclaration> CreateWithQualifierParameters(int pos, ISourceFile sourceFile)
        {
            var qualifier = CreateInjectedNode <ParameterDeclaration>(SyntaxKind.Parameter, pos, sourceFile);

            qualifier.Name = new IdentifierOrBindingPattern(CreateIdentifier(Names.WithQualifierParameter, pos, sourceFile));

            // this generates "typeof qualifier | {}" which allows the ommision of some of the fields while retaining
            // full ide auto complete support. This relaxes the type checker for invalidly typed fields
            // ideally we want to duplicate the actual declared qualifier type and make the members optional, but unfortunatley
            // at this point in time we don't have access. This will change the error to be a runtime evaluation error when using
            // a wrong qualifier key. Note the qualifier values are still properly type checked.
            qualifier.Type = new UnionOrIntersectionTypeNode()
            {
                Kind  = SyntaxKind.UnionType,
                Types = new NodeArray <ITypeNode>(
                    CreateTypeOfExpression(Names.CurrentQualifier, pos, sourceFile),
                    new TypeLiteralNode()
                    ),
            };

            var result = new NodeArray <IParameterDeclaration>(qualifier);

            result.Pos = qualifier.Pos;
            result.End = qualifier.End;

            return(result);
        }
コード例 #2
0
ファイル: BasicBlocks.cs プロジェクト: PlumpMath/cilpe-1
            public BasicBlockStub(Variable var, BasicBlock block)
            {
                prev = new ArrayList();
                next = new ArrayList();

                isEmpty = true;
                foreach (ManageVar node in var.UsersArray)
                {
                    isEmpty &= (node.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock) != block;
                }

                usageArray = new NodeArray();
                if (!isEmpty)
                {
                    foreach (Node node in block.Body)
                    {
                        if (node is ManageVar)
                        {
                            ManageVar usage = node as ManageVar;
                            if (usage.Var == var)
                            {
                                usageArray.Add(usage);
                            }
                        }
                    }
                }
            }
コード例 #3
0
 private void AnalyzeTypeArguments([CanBeNull] NodeArray <ITypeNode> typeArguments)
 {
     foreach (var t in typeArguments.AsStructEnumerable())
     {
         AnalyzeTypeReference(t);
     }
 }
コード例 #4
0
ファイル: PathFindingGrid.cs プロジェクト: EthanBerk/MIAG
        public void Visualize(float time)
        {
            for (int row = 0; row < NodeArray.GetLength(0); row++)
            {
                var startPoint = NodeArray[row, 0].WorldPos;
                var endPoint   = new Vector2(NodeArray[row, NodeArray.GetLength(1) - 1].WorldPos.x + CellSize, NodeArray[row, 0].WorldPos.y);
                Debug.DrawLine(startPoint, endPoint, Color.blue, time);
            }
            for (int col = 0; col < NodeArray.GetLength(1); col++)
            {
                var startPoint = NodeArray[0, col].WorldPos;
                var endPoint   = new Vector2(startPoint.x, NodeArray[NodeArray.GetLength(0) - 1, col].WorldPos.y - CellSize);
                Debug.DrawLine(startPoint, endPoint, Color.red, time);
            }
            var startNode = NodeArray[NodeArray.GetLength(0) - 1, 0];
            var start     = new Vector2(startNode.WorldPos.x, startNode.WorldPos.y - CellSize);
            var endNode   = NodeArray[NodeArray.GetLength(0) - 1, NodeArray.GetLength(1) - 1];
            var end       = new Vector2(endNode.WorldPos.x + CellSize, start.y);

            Debug.DrawLine(start, end, Color.blue, time);

            startNode = NodeArray[0, NodeArray.GetLength(1) - 1];
            start     = new Vector2(startNode.WorldPos.x + CellSize, startNode.WorldPos.y);
            Debug.DrawLine(start, end, Color.red, time);
        }
コード例 #5
0
ファイル: BasicBlocks.cs プロジェクト: PlumpMath/cilpe-1
 public BasicBlock()
 {
     prev  = new BasicBlockArray();
     next  = new BasicBlockArray();
     links = new BasicBlockArray();
     body  = new NodeArray();
 }
コード例 #6
0
        public void ParallelArray2d()
        {
            var alength = 16384;
            var cpl     = 0.00001;

            var randy = new ThreadSafeRandom();

            var sw = new Stopwatch();

            var nodeArray = new NodeArray(
                Enumerable.Range(0, alength)
                .Select(i => randy.NextDouble() * 2 - 1.0)
                .ToArray());

            for (var k = 0; k < 3; k++)
            {
                sw.Start();
                for (var s = 0; s < 40; s++)
                {
                    var noise = 0.1 - 0.002 * s;
                    for (var q = 0; q < 50; q++)
                    {
                        nodeArray = NodeArray.UpdateStar(nodeArray, cpl, noise, randy);
                        nodeArray = NodeArray.UpdateStar(nodeArray, cpl, noise, randy);
                    }
                    // Debug.WriteLine("{0}\t{1}\t{2}", s, noise, Correlo(nodeArray.Current.ToArray()));
                }

                sw.Stop();
                Debug.WriteLine("Elapsed={0}", sw.Elapsed);
                sw.Reset();
            }
        }
コード例 #7
0
ファイル: QualifierUtilities.cs プロジェクト: socat/BuildXL
        /// <summary>
        /// Creates a type literal with shape {}
        /// </summary>
        private static TypeLiteralNode CreateEmptyTypeLiteral(int pos, ISourceFile sourceFile)
        {
            var emptyTypeLiteral = CreateInjectedNode <TypeLiteralNode>(SyntaxKind.TypeLiteral, pos, sourceFile);

            emptyTypeLiteral.Members = NodeArray.Empty <ITypeElement>();
            return(emptyTypeLiteral);
        }
コード例 #8
0
        private async void DoStart()
        {
            _cancellationTokenSource = new CancellationTokenSource();
            _isRunning = true;
            CommandManager.InvalidateRequerySuggested();

            await Task.Run(() =>
            {
                _stopwatch.Start();

                for (var i = 0; _isRunning; i++)
                {
                    NodeArray = NodeArray.UpdateStar(NodeArray, StepSizeVm.Value, NoiseLevelVm.Value, Randy);

                    if (_cancellationTokenSource.IsCancellationRequested)
                    {
                        _isRunning = false;
                        _stopwatch.Stop();
                        CommandManager.InvalidateRequerySuggested();
                    }

                    if (i % (int)DisplayFrequencySliderVm.Value == 0)
                    {
                        Application.Current.Dispatcher.Invoke
                        (
                            UpdateUi,
                            DispatcherPriority.Background
                        );
                    }
                }
            }, _cancellationTokenSource.Token);
        }
コード例 #9
0
        private static void BuildArrayTree(NodeArray nodeArray, INode node, int binary, int bits)
        {
            switch (node)
            {
            case Node n:
                if (bits < nodeArray.Bits)
                {
                    BuildArrayTree(nodeArray, n.Child0, binary, bits + 1);
                    BuildArrayTree(nodeArray, n.Child1, binary | (1 << bits), bits + 1);
                }
                else
                {
                    nodeArray.Nodes[binary] = BuildArrayTree(n);
                }
                break;

            case Terminal t:
                t.Bits = bits;
                int paddingCount = 1 << (nodeArray.Bits - bits);
                for (int padding = 0; padding < paddingCount; padding++)
                {
                    nodeArray.Nodes[(padding << bits) | binary] = node;
                }
                break;
            }
        }
コード例 #10
0
 private void AnalyzeParameters(NodeArray <IParameterDeclaration> parameters)
 {
     foreach (var parameterDeclaration in parameters.AsStructEnumerable())
     {
         AddOrCreateReferencedSymbol(SymbolKind.ParameterDeclaration, parameterDeclaration.Name.GetName());
         AnalyzeTypeReference(parameterDeclaration.Type);
     }
 }
コード例 #11
0
ファイル: NewExpr.cs プロジェクト: vaginessa/SharpDemangler
 public NewExpr(NodeArray exprList, Node type, NodeArray initList, bool isGlobal, bool isArray) : base(ItaniumDemangleNodeType.NewExpr)
 {
     this.exprList = exprList;
     this.type     = type;
     this.initList = initList;
     this.isGlobal = isGlobal;
     this.isArray  = isArray;
 }
コード例 #12
0
        public int AddNode(Vector2 position, float movementPenalty = 1f)
        {
            var index          = NodeArray.Length;
            var definitionNode = new DefinitionNode(position, movementPenalty);

            NodeArray = NodeArray.Append(definitionNode);
            return(index);
        }
コード例 #13
0
 /// <summary>
 /// Removes the subnode with the given key. Can only be called on array nodes.
 /// </summary>
 /// <param name="key">Key of the subnode to remove</param>
 /// <returns>True if node was removed, false if not found</returns>
 public bool RemoveSubnode(string key)
 {
     if (NodeType != ValueType.Array)
     {
         return(false);
     }
     return(NodeArray.Remove(key));
 }
コード例 #14
0
 private void AnalyzeTypeParameters(NodeArray <ITypeParameterDeclaration> typeParameters)
 {
     foreach (var t in typeParameters.AsStructEnumerable())
     {
         // Parameters are not part of the declaration fingerprint.
         AddOrCreateReferencedSymbol(SymbolKind.TypeParameter, t.Name.Text);
         AnalyzeTypeReference(t.Constraint);
     }
 }
コード例 #15
0
ファイル: Program.cs プロジェクト: JeffreyMante/Learning
        static void Main(string[] args)
        {
            IArray array = new NodeArray();

            Console.WriteLine(array.ToString());

            array.AddAtPosition(1, 0);
            Console.WriteLine(array.ToString());

            array.AddAtPosition(2, 0);
            Console.WriteLine(array.ToString());

            array.AddAtPosition(3, 0);
            Console.WriteLine(array.ToString());

            array.AddAtPosition(4, 1);
            Console.WriteLine(array.ToString());

            array.AddAtPosition(5, 3);
            Console.WriteLine(array.ToString());

            array.AddAtPosition(6, 4);
            Console.WriteLine(array.ToString());

            array.AddAtPosition(0, 6);
            Console.WriteLine(array.ToString());

            array.Add(1);
            array.Add(6);
            array.Add(5);
            array.Add(2);
            array.Add(4);
            array.Add(3);
            Console.WriteLine(array.ToString());

            array.Remove(10);
            Console.WriteLine(array.ToString());

            array.Remove(1);
            Console.WriteLine(array.ToString());

            array.RemoveAtPosition(6);
            Console.WriteLine(array.ToString());

            array.Clear();
            Console.WriteLine(array.ToString());

            array.Add(1);
            array.Add(2);
            array.Add(3);
            array.Add(4);
            array.Add(5);
            Console.WriteLine(array.ToString());

            array.Reverse();
            Console.WriteLine(array.ToString());
        }
コード例 #16
0
        private void AnalyzeDeclarationStatements(NodeArray <IStatement> statements)
        {
            int idx = 0;

            foreach (var statement in statements.AsStructEnumerable())
            {
                AnalyzeDeclarationStatement(statement, idx);
                idx++;
            }
        }
コード例 #17
0
        private void AnalyzeStatements([CanBeNull] NodeArray <IStatement> statements)
        {
            int i = 0;

            foreach (var statement in statements.AsStructEnumerable())
            {
                AnalyzeStatement(statement, i);
                i++;
            }
        }
コード例 #18
0
ファイル: PathFindingGrid.cs プロジェクト: EthanBerk/MIAG
 public void UpdateNodes()
 {
     for (int row = 0; row < NodeArray.GetLength(0); row++)
     {
         for (int col = 0; col < NodeArray.GetLength(1); col++)
         {
             NodeArray[row, col].UpdateNodeState(_collisionsMask);
         }
     }
 }
コード例 #19
0
        public void AddTest()
        {
            var array = new NodeArray <IExpression>();

            array.Add(new LiteralExpression("original-1"));
            array.Add(new LiteralExpression("original-2"));

            Assert.Equal(2, array.Length);
            Assert.Equal("original-1", array[0].Cast <LiteralExpression>().Text);
            Assert.Equal("original-2", array[1].Cast <LiteralExpression>().Text);
        }
コード例 #20
0
        public static List <CodeItem> MapFunction(Node function, NodeArray <ParameterDeclaration> parameters, string id, ICodeViewUserControl control)
        {
            if (function == null)
            {
                return(null);
            }

            List <CodeItem> children;

            try
            {
                children = function.Children
                           .FirstOrDefault(c => c.Kind == SyntaxKind.Block)?.Children
                           .SelectMany(SyntaxMapperJS.MapMember)
                           .ToList();
            }
            catch (NullReferenceException)
            {
                return(new List <CodeItem>());
            }

            if (children != null && children.Any())
            {
                SyntaxMapper.FilterNullItems(children);

                var item = BaseMapperJS.MapBase <CodeClassItem>(function, id, control);

                item.BorderColor = Colors.DarkGray;

                item.Kind       = CodeItemKindEnum.Method;
                item.Parameters = $"({string.Join(", ", parameters.Select(p => p.IdentifierStr))})";
                item.Tooltip    = TooltipMapper.Map(item.Access, null, item.Name, item.Parameters);
                item.Id         = IdMapper.MapId(item.FullName, parameters);
                item.Moniker    = IconMapper.MapMoniker(item.Kind, item.Access);

                item.Members = children;

                return(new List <CodeItem> {
                    item
                });
            }

            CodeFunctionItem functionItem = BaseMapperJS.MapBase <CodeFunctionItem>(function, id, control);

            functionItem.Kind       = CodeItemKindEnum.Method;
            functionItem.Parameters = $"({string.Join(", ", parameters.Select(p => p.IdentifierStr))})";
            functionItem.Tooltip    = TooltipMapper.Map(functionItem.Access, null, functionItem.Name, functionItem.Parameters);
            functionItem.Id         = IdMapper.MapId(functionItem.FullName, parameters);
            functionItem.Moniker    = IconMapper.MapMoniker(functionItem.Kind, functionItem.Access);

            return(new List <CodeItem> {
                functionItem
            });
        }
コード例 #21
0
 private void AppendInferredArgumentsOrParameters(NodeArray <IParameterDeclaration> nodeParameters)
 {
     AppendList(
         nodeParameters,
         separatorToken: ScriptWriter.SeparateArgumentsToken,
         startBlockToken: ScriptWriter.StartArgumentsToken,
         endBlockToken: ScriptWriter.EndArgumentsToken,
         placeSeparatorOnLastElement: false,
         minimumCountBeforeNewLines: 5,
         printTrailingComments: true,
         visitItem: n => VisitInferredParameterDeclaration(n.Cast <ParameterDeclaration>()));
 }
コード例 #22
0
 public FunctionType(
     Node ret, NodeArray fparams,
     Qualifiers cvQuals, FunctionRefQual refQual,
     Node exceptionSpec
     ) : base(ItaniumDemangleNodeType.FunctionType, Cache.Yes, Cache.No, Cache.Yes)
 {
     this.ret           = ret;
     this.fparams       = fparams;
     this.cvQuals       = cvQuals;
     this.refQual       = refQual;
     this.exceptionSpec = exceptionSpec;
 }
コード例 #23
0
 public FunctionEncoding(
     Node ret, Node name,
     NodeArray fparams, Node attrs,
     Qualifiers cvQuals, FunctionRefQual refQual
     ) : base(ItaniumDemangleNodeType.FunctionEncoding, Cache.Yes, Cache.No, Cache.Yes)
 {
     this.ReturnType = ret;
     this.Name       = name;
     this.Params     = fparams;
     this.attrs      = attrs;
     this.CVQuals    = cvQuals;
     this.RefQual    = refQual;
 }
コード例 #24
0
        private static int GetOriginalPositionFromPositionDecorator(NodeArray <IDecorator> decorators)
        {
            Contract.Assert(decorators.Count > 0, "A public surface file should have a decorator here");

            var positionDecorator = decorators[0];
            var stringPosition    = positionDecorator.Expression.Cast <ILiteralExpression>().Text;

            int position;
            var result = int.TryParse(stringPosition, out position);

            Contract.Assert(result, "The first decorator is expected to be a position");
            return(position);
        }
コード例 #25
0
        private static NodeArray <IDecorator> RemovePositionDecorator(NodeArray <IDecorator> decorators)
        {
            Contract.Assert(decorators.Count > 0);

            var originalDecorators = new IDecorator[decorators.Count - 1];

            if (originalDecorators.Length > 0)
            {
                decorators.CopyTo(1, originalDecorators, 0, decorators.Count - 1);
            }

            return(new NodeArray <IDecorator>(originalDecorators));
        }
コード例 #26
0
ファイル: QualifierUtilities.cs プロジェクト: socat/BuildXL
        /// <summary>
        /// Creates "withQualifier: typeof qualifier"
        /// </summary>
        private static NodeArray <IParameterDeclaration> CreateWithQualifierParameters(int pos, ISourceFile sourceFile)
        {
            var qualifier = CreateInjectedNode <ParameterDeclaration>(SyntaxKind.Parameter, pos, sourceFile);

            qualifier.Name = new IdentifierOrBindingPattern(CreateIdentifier(Names.WithQualifierParameter, pos, sourceFile));
            qualifier.Type = CreateTypeOfExpression(Names.CurrentQualifier, pos, sourceFile);

            var result = new NodeArray <IParameterDeclaration>(qualifier);

            result.Pos = qualifier.Pos;
            result.End = qualifier.End;

            return(result);
        }
コード例 #27
0
ファイル: BasicBlocks.cs プロジェクト: PlumpMath/cilpe-1
        private bool performVariableAliasesRemoval()
        {
            bool result = false;

            foreach (Variable v in mbb.Variables)
            {
                if (v.UsersArray.Count == 1)
                {
                    Node varUseNode = v.UsersArray[0];
                    if (varUseNode is LoadVar)
                    {
                        BasicBlock block    = varUseNode.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock;
                        Node       nextNode = varUseNode.Next;
                        while (nextNode is DuplicateStackTop &&
                               nextNode.Options[BasicBlock.BASIC_BLOCK_OPTION] == block)
                        {
                            nextNode = nextNode.Next;
                        }

                        if (nextNode is StoreVar &&
                            nextNode.Options[BasicBlock.BASIC_BLOCK_OPTION] == block)
                        {
                            LoadVar  ldNode = varUseNode as LoadVar;
                            StoreVar stNode = nextNode as StoreVar;
                            Variable var = ldNode.Var, alias = stNode.Var;

                            if (var != alias && var.Type.Equals(alias.Type))
                            {
                                result = true;
                                replaceNodeByPop(stNode);
                                stNode.RemoveFromGraph();

                                NodeArray aliasUsageList = new NodeArray();
                                foreach (Node node in alias.UsersArray)
                                {
                                    aliasUsageList.Add(node);
                                }

                                foreach (ManageVar node in aliasUsageList)
                                {
                                    node.Var = var;
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
コード例 #28
0
        /// <nodoc />
        public static List <TResult> Map <T, TResult>(NodeArray <T> array, Func <T, TResult> f)
        {
            List <TResult> result = null;

            if (array != null)
            {
                result = new List <TResult>(array.Count);
                foreach (var v in array)
                {
                    result.Add(f(v));
                }
            }

            return(result);
        }
コード例 #29
0
        /// <nodoc />
        public static int IndexOf <T>(NodeArray <T> array, T value, IEqualityComparer <T> comparer)
        {
            if (array != null)
            {
                for (var i = 0; i < array.Length; i++)
                {
                    if (comparer.Equals(array[i], value))
                    {
                        return(i);
                    }
                }
            }

            return(-1);
        }
コード例 #30
0
        private static NodeArray BuildArrayTree(Node node)
        {
            NodeArray result;

            if (node.Depth <= MaxArrayBits)
            {
                result = new NodeArray(node.Depth);
            }
            else
            {
                result = new NodeArray(Math.Max((int)Math.Log(node.TerminalCount, 2), MaxArrayBits));
            }
            BuildArrayTree(result, node, 0, 0);
            return(result);
        }