public BVE5Resolver(BVE5Compilation compilation, SimpleTypeResolveContext context, Dictionary<string, ResolveResult> nameLookupCache, ImmutableStack<IVariable> stack)
 {
     this.compilation = compilation;
     this.context = context;
     user_defined_name_lookup_cache = nameLookupCache;
     local_variable_stack = stack;
 }
		private State GetOrCreateStateForLabel(string labelName, ImmutableStack<Tuple<int, string>> finallyStack) {
			State result;
			if (_labelStates.TryGetValue(labelName, out result))
				return result;
			_labelStates[labelName] = result = CreateNewStateValue(finallyStack);
			return result;
		}
		public RemainingBlock(ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State stateValue, State returnState) {
			Stack = stack;
			BreakStack = breakStack;
			ContinueStack = continueStack;
			StateValue = stateValue;
			ReturnState = returnState;
		}
		private State CreateNewStateValue(ImmutableStack<Tuple<int, string>> finallyStack, string finallyHandlerToPush = null) {
			int value = _nextStateIndex++;
			finallyStack = finallyHandlerToPush != null ? finallyStack.Push(Tuple.Create(value, finallyHandlerToPush)) : finallyStack;
			var result = new State(_currentLoopLabel, value, finallyStack);
			_allStates.Add(result);
			return result;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="ActivationRecord"/> class.
 /// </summary>
 /// <param name="type">
 /// The routine type.
 /// </param>
 /// <param name="programCounter">
 /// The program counter.
 /// </param>
 /// <param name="argumentCount">
 /// The argument count.
 /// </param>
 /// <param name="localVariables">
 /// The local variables.
 /// </param>
 /// <param name="evaluationStack">
 /// The evaluation stack.
 /// </param>
 public ActivationRecord(RoutineType type, int programCounter, byte argumentCount, ImmutableArray<int> localVariables, ImmutableStack<int> evaluationStack)
 {
     this.argumentCount = argumentCount;
     this.type = type;
     this.localVariables = localVariables;
     this.programCounter = programCounter;
     this.evaluationStack = evaluationStack;
 }
Beispiel #6
0
 public static IMarkdownContext SetFilePathStack(this IMarkdownContext context, ImmutableStack<string> filePathStack)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     return context.CreateContext(context.Variables.SetItem(FilePathStackKey, filePathStack));
 }
Beispiel #7
0
 public Turtle(Vector pos, double angle, ImmutableStack<TurtleState> stack, Action<int, int, int, int, Color> drawLine, Color c)
 {
     this.Position = pos;
     this.Angle = angle;
     this.Stack = stack;
     this.DrawLine = drawLine;
     this.DrawColor = c;
 }
        public void Dispose()
        {
            foreach (var item in _disposables)
            {
                item.Dispose();
            }

            _disposables = ImmutableStack<IDisposable>.Empty;
        }
        public void Add(IDisposable disposable)
        {
            if (disposable == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(disposable));
            }

            _disposables = _disposables.Push(disposable);
        }
        public void Add(Action action)
        {
            if (action == null)
            {
                throw Logger.Fatal.ArgumentNull(nameof(action));
            }

            _disposables = _disposables.Push(new HarshDisposableAction(action));
        }
        public static void Start(ActivityScope scope)
        {
            var parent = ActivityStack.Any() ? ActivityStack.Peek() : null;

            if (parent != null)
                scope.ParentId = parent.Id;

            ActivityStack = ActivityStack.Push(scope);
        }
 private void Enqueue(ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State stateValue, State returnState)
 {
     if (_processedStates.Contains(stateValue))
         throw new InvalidOperationException("Duplicate enqueueing of " + stateValue);
     _processedStates.Add(stateValue);
     if (stack.IsEmpty)
         throw new InvalidOperationException("Empty stack for state " + stateValue);
     _remainingBlocks.Enqueue(new RemainingBlock(stack, breakStack, continueStack, stateValue, returnState));
 }
Beispiel #13
0
 public Reader(Blender blender)
 {
     this.lexer = blender.lexer;
     this.oldTreeCursor = blender.oldTreeCursor;
     this.changes = blender.changes;
     this.newPosition = blender.newPosition;
     this.changeDelta = blender.changeDelta;
     this.newDirectives = blender.newDirectives;
     this.oldDirectives = blender.oldDirectives;
     this.newLexerDrivenMode = blender.newLexerDrivenMode;
 }
Beispiel #14
0
 internal string InternalMarkup(string src, ImmutableStack<string> parents, HashSet<string> dependency)
 {
     using (GetFileScope(parents))
     {
         return InternalMarkup(
             src,
             Context
                 .SetFilePathStack(parents)
                 .SetDependency(dependency));
     }
 }
Beispiel #15
0
		private CppResolver(ICompilation compilation, Conversions conversions, CppTypeResolveContext context, bool checkForOverflow, bool isWithinLambdaExpression, TypeDefinitionCache currentTypeDefinitionCache, ImmutableStack<IVariable> localVariableStack, ObjectInitializerContext objectInitializerStack)
		{
			this.compilation = compilation;
			this.conversions = conversions;
			this.context = context;
			this.checkForOverflow = checkForOverflow;
			this.isWithinLambdaExpression = isWithinLambdaExpression;
			this.currentTypeDefinitionCache = currentTypeDefinitionCache;
			this.localVariableStack = localVariableStack;
			this.objectInitializerStack = objectInitializerStack;
		}
Beispiel #16
0
 public Reader(Blender blender)
 {
     _lexer = blender._lexer;
     _oldTreeCursor = blender._oldTreeCursor;
     _changes = blender._changes;
     _newPosition = blender._newPosition;
     _changeDelta = blender._changeDelta;
     _newDirectives = blender._newDirectives;
     _oldDirectives = blender._oldDirectives;
     _newLexerDrivenMode = blender._newLexerDrivenMode;
 }
Beispiel #17
0
 public static PositionedUnit PositionNewUnit(int width, ImmutableStack<Unit> nextUnits)
 {
     if (nextUnits.IsEmpty) return PositionedUnit.Null;
     var u = nextUnits.Peek();
     var topmostY = u.Displacements[0].Min(m => m.ToMap().Y);
     var pos = new PositionedUnit(u, 0, new Point(0, -topmostY));
     var leftMargin = pos.Members.Min(m => m.X);
     var rightMargin = width - 1 - pos.Members.Max(m => m.X);
     var newX = (rightMargin - leftMargin) / 2;
     return new PositionedUnit(u, 0, new Point(newX, -topmostY));
 }
Beispiel #18
0
 public Map(int id, bool[,] filled, PositionedUnit unit, ImmutableStack<Unit> nextUnits, ImmutableHashSet<PositionedUnit> usedPositions, Scores scores, bool died = false)
 {
     Id = id;
     NextUnits = nextUnits;
     Width = filled.GetLength(0);
     Height = filled.GetLength(1);
     Filled = filled;
     Unit = IsValidPosition(unit) ? unit : PositionedUnit.Null;
     UsedPositions = usedPositions.Add(Unit);
     Scores = scores;
     Died = died;
 }
Beispiel #19
0
        private static LoggerFileScope GetFileScope(ImmutableStack<string> parents)
        {
            if (!parents.IsEmpty)
            {
                var path = StringExtension.ToDisplayPath(parents.Peek());

                if (!string.IsNullOrEmpty(path))
                {
                    return new LoggerFileScope(path);
                }
            }

            return null;
        }
        public static void End(ActivityScope scope)
        {
            if (Current == null)
                return;

            if (ActivityStack.All(scopeOnTheStack => scope.Id != scopeOnTheStack.Id))
                return;

            ActivityScope currentScope;
            ActivityStack = ActivityStack.Pop(out currentScope);

            while(ActivityStack.Any() && currentScope.Id != scope.Id) {
                ActivityStack = ActivityStack.Pop(out currentScope);
            }
        }
Beispiel #21
0
        public Blender(Lexer lexer, CSharp.CSharpSyntaxNode oldTree, IEnumerable<TextChangeRange> changes)
        {
            Debug.Assert(lexer != null);
            _lexer = lexer;
            _changes = ImmutableStack.Create<TextChangeRange>();

            if (changes != null)
            {
                // TODO: Consider implementing NormalizedChangeCollection for TextSpan. the real
                // reason why we are collapsing is because we want to extend change ranges and
                // cannot allow them to overlap. This does not seem to be a big deal since multiple
                // changes are infrequent and typically close to each other. However if we have
                // NormalizedChangeCollection for TextSpan we can have both - we can extend ranges
                // and not require collapsing them. NormalizedChangeCollection would also ensure
                // that changes are always normalized.

                // TODO: this is a temporary measure to prevent individual change spans from
                // overlapping after they are widened to effective width (+1 token at the start).
                // once we have normalized collection for TextSpan we will not need to collapse all
                // the change spans.

                var collapsed = TextChangeRange.Collapse(changes);

                // extend the change to its affected range. This will make it easier 
                // to filter out affected nodes since we will be able simply check 
                // if node intersects with a change.
                var affectedRange = ExtendToAffectedRange(oldTree, collapsed);
                _changes = _changes.Push(affectedRange);
            }

            if (oldTree == null)
            {
                // start at lexer current position if no nodes specified
                _oldTreeCursor = new Cursor();
                _newPosition = lexer.TextWindow.Position;
            }
            else
            {
                _oldTreeCursor = Cursor.FromRoot(oldTree).MoveToFirstChild();
                _newPosition = 0;
            }

            _changeDelta = 0;
            _newDirectives = default(DirectiveStack);
            _oldDirectives = default(DirectiveStack);
            _newLexerDrivenMode = 0;
        }
     RecEnumerateOutcomes(
     ImmutableStack<Func<DiscriminatedUnionCaseParameter, DestructureMethodParameter>> results,
     Func<DiscriminatedUnionCaseParameter, DestructureMethodParameter>[] resultTypes,
     int numIterations)
 {
     if (results.Count() >= numIterations)
     {
         yield return results;
     }
     else
     {
         foreach (var resultType in resultTypes)
         {
             foreach (var a in RecEnumerateOutcomes(results.Push(resultType), resultTypes, numIterations))
             {
                 yield return a;
             }
         }
     }
 }
Beispiel #23
0
        /// <summary>
        /// Appends an abbreviation to the given zscii text.
        /// </summary>
        /// <param name="zcharacter">
        /// The zcharacter.
        /// </param>
        /// <param name="calledRecursively">
        /// A value which indicates whether the method was called recursively.
        /// </param>
        /// <param name="zcharacters">
        /// The zcharacters.
        /// </param>
        /// <param name="zsciiText">
        /// The zscii text.
        /// </param>
        protected void AppendAbbreviation(byte zcharacter, bool calledRecursively, ref ImmutableStack<byte> zcharacters, ref ImmutableStack<Zscii> zsciiText)
        {
            if (calledRecursively)
            {
                this.FrontEnd.ErrorNotification(ErrorCondition.NestedAbbreviation, "Nested abbreviation detected.");
                return;
            }

            if (zcharacters != null)
            {
                var abbreviationNumber = ((zcharacter - 1) * 32) + zcharacters.Top;
                zcharacters = zcharacters.Tail;
                var abbreviationsTableAddress = this.Memory.ReadWord(24);
                var abbreviationAddress = 2 * this.Memory.ReadWord(abbreviationsTableAddress + (2 * abbreviationNumber));
                var abbreviation = this.ZCharactersToZscii(true, this.EncodedTextToZCharacters(ref abbreviationAddress));
                foreach (var zsciiCharacter in abbreviation.Enumerable())
                {
                    zsciiText = zsciiText.Add(zsciiCharacter);
                }
            }
        }
Beispiel #24
0
 private Blender(
     Lexer lexer,
     Cursor oldTreeCursor,
     ImmutableStack<TextChangeRange> changes,
     int newPosition,
     int changeDelta,
     DirectiveStack newDirectives,
     DirectiveStack oldDirectives,
     LexerMode newLexerDrivenMode)
 {
     Debug.Assert(lexer != null);
     Debug.Assert(changes != null);
     Debug.Assert(newPosition >= 0);
     _lexer = lexer;
     _oldTreeCursor = oldTreeCursor;
     _changes = changes;
     _newPosition = newPosition;
     _changeDelta = changeDelta;
     _newDirectives = newDirectives;
     _oldDirectives = oldDirectives;
     _newLexerDrivenMode = newLexerDrivenMode & (LexerMode.MaskXmlDocCommentLocation | LexerMode.MaskXmlDocCommentStyle);
 }
Beispiel #25
0
        public string InternalMarkup(string src, ImmutableStack <string> parents)
        {
            DfmEngine engine = new DfmEngine(Context, Rewriter, Renderer, Options);

            return(Mark(Normalize(src), Context.SetFilePathStack(parents)).ToString());
        }
Beispiel #26
0
 public static T PeekOrDefault <T>(this ImmutableStack <T> stack)
 {
     return(stack.IsEmpty ? default(T) : stack.Peek());
 }
 public void Add(OpenTagStack openTags, ImmutableStack <InternalObject> document, uint cost)
 {
     Add(new Configuration(openTags, document, cost));
 }
 public Configuration(OpenTagStack openTags, ImmutableStack <InternalObject> document, uint cost)
 {
     this.OpenTags = openTags;
     this.Document = document;
     this.Cost     = cost;
 }
Beispiel #29
0
		/// <summary>
		/// Pushes an input handler onto the list of stacked input handlers.
		/// </summary>
		/// <remarks><inheritdoc cref="ITextAreaInputHandler"/></remarks>
		public void PushStackedInputHandler(TextAreaStackedInputHandler inputHandler)
		{
			if (inputHandler == null)
				throw new ArgumentNullException("inputHandler");
			stackedInputHandlers = stackedInputHandlers.Push(inputHandler);
			inputHandler.Attach();
		}
        List <InternalObject> CreateElements(ref ImmutableStack <InternalObject> inputObjects)
        {
            List <InternalObject> objects = new List <InternalObject>();

            while (!inputObjects.IsEmpty)
            {
                var obj = inputObjects.Peek();
                var tag = obj as InternalTag;
                if (tag != null && tag.IsStartTag)
                {
                    break;
                }
                inputObjects = inputObjects.Pop();
                if (tag != null && tag.IsEndTag)
                {
                    if (inputObjects.Peek() == StartTagPlaceholder)
                    {
                        objects.Add(tag.AddSyntaxError("Matching opening tag was not found"));
                        inputObjects = inputObjects.Pop();
                    }
                    else
                    {
                        var childElements = CreateElements(ref inputObjects);
                        var startTag      = (InternalTag)inputObjects.Peek();
                        inputObjects = inputObjects.Pop();
                        childElements.Add(startTag);
                        childElements.Reverse();
                        if (tag != EndTagPlaceholder)
                        {
                            // add end tag
                            if (startTag.Name != tag.Name)
                            {
                                childElements.Add(tag.AddSyntaxError("Expected '</" + startTag.Name + ">'. End tag must have same name as start tag."));
                            }
                            else
                            {
                                childElements.Add(tag);
                            }
                        }
                        InternalElement e = new InternalElement(startTag);
                        e.HasEndTag     = (tag != EndTagPlaceholder);
                        e.NestedObjects = new InternalObject[childElements.Count];
                        int pos = 0;
                        for (int i = 0; i < childElements.Count; i++)
                        {
                            e.NestedObjects[i] = childElements[i].SetStartRelativeToParent(pos);
                            pos += e.NestedObjects[i].Length;
                        }
                        e.Length = pos;
                        if (tag == EndTagPlaceholder)
                        {
                            e.SyntaxErrors = new [] { new InternalSyntaxError(pos, pos, "Missing '</" + startTag.Name + ">'") };
                        }
                        objects.Add(e);
                    }
                }
                else
                {
                    objects.Add(obj);
                }
            }
            return(objects);
        }
        internal static ThrownExceptionInfo CreateDefaultInfoForExceptionsPathAnalysis(BasicBlock block, WellKnownTypeProvider wellKnownTypeProvider, ImmutableStack <IOperation>?interproceduralCallStackOpt)
        {
            var exceptionNamedType = wellKnownTypeProvider.GetOrCreateTypeByMetadataName(WellKnownTypeNames.SystemException);

            RoslynDebug.Assert(exceptionNamedType != null);
            return(new ThrownExceptionInfo(block, exceptionNamedType, interproceduralCallStackOpt, isDefaultExceptionForExceptionsPathAnalysis: true));
        }
Beispiel #32
0
 /// <summary>
 /// Closes the current scope for local variables; removing all variables in that scope.
 /// </summary>
 public void PopBlock()
 {
     IVariable removedVar;
     do {
         removedVar = localVariableStack.Peek();
         localVariableStack = localVariableStack.Pop();
     } while (removedVar != null);
 }
Beispiel #33
0
 protected override IImmutableStack <T> Complete(T[] intermediateCollection)
 {
     return(ImmutableStack.CreateRange(intermediateCollection));
 }
Beispiel #34
0
 public ExtractMemberAccessVisitor()
 {
     Members = ImmutableStack.Create <MemberInfo>();
 }
Beispiel #35
0
        public static CompositionConfiguration Create(ComposableCatalog catalog)
        {
            Requires.NotNull(catalog, nameof(catalog));

            // We consider all the parts in the catalog, plus the specially synthesized ones
            // that should always be applied.
            var customizedCatalog = catalog.AddParts(AlwaysBundledParts);

            // Construct our part builders, initialized with all their imports satisfied.
            // We explicitly use reference equality because ComposablePartDefinition.Equals is too slow, and unnecessary for this.
            var partBuilders = new Dictionary <ComposablePartDefinition, PartBuilder>(ReferenceEquality <ComposablePartDefinition> .Default);

            foreach (ComposablePartDefinition partDefinition in customizedCatalog.Parts)
            {
                var satisfyingImports = partDefinition.Imports.ToImmutableDictionary(i => i, i => customizedCatalog.GetExports(i.ImportDefinition));
                partBuilders.Add(partDefinition, new PartBuilder(partDefinition, satisfyingImports));
            }

            // Create a lookup table that gets all immediate importers for each part.
            foreach (PartBuilder partBuilder in partBuilders.Values)
            {
                // We want to understand who imports each part so we can properly propagate sharing boundaries
                // for MEFv1 attributed parts. ExportFactory's that create sharing boundaries are an exception
                // because if a part has a factory that creates new sharing boundaries, the requirement for
                // that sharing boundary of the child scope shouldn't be interpreted as a requirement for that
                // same boundary by the parent part.
                // However, if the ExportFactory does not create sharing boundaries, it does in fact need all
                // the same sharing boundaries as the parts it constructs.
                var importedPartsExcludingFactoriesWithSharingBoundaries =
                    (from entry in partBuilder.SatisfyingExports
                     where !entry.Key.IsExportFactory || entry.Key.ImportDefinition.ExportFactorySharingBoundaries.Count == 0
                     from export in entry.Value
                     select export.PartDefinition).Distinct(ReferenceEquality <ComposablePartDefinition> .Default);
                foreach (var importedPartDefinition in importedPartsExcludingFactoriesWithSharingBoundaries)
                {
                    var importedPartBuilder = partBuilders[importedPartDefinition];
                    importedPartBuilder.ReportImportingPart(partBuilder);
                }
            }

            // Propagate sharing boundaries defined on parts to all importers (transitive closure).
            foreach (PartBuilder partBuilder in partBuilders.Values)
            {
                partBuilder.ApplySharingBoundary();
            }

            var sharingBoundaryOverrides = ComputeInferredSharingBoundaries(partBuilders.Values);

            // Build up our set of composed parts.
            var partsBuilder = ImmutableHashSet.CreateBuilder <ComposedPart>();

            foreach (var partBuilder in partBuilders.Values)
            {
                var composedPart = new ComposedPart(partBuilder.PartDefinition, partBuilder.SatisfyingExports, partBuilder.RequiredSharingBoundaries.ToImmutableHashSet());
                partsBuilder.Add(composedPart);
            }

            var parts = partsBuilder.ToImmutable();

            // Determine which metadata views to use for each applicable import.
            var metadataViewsAndProviders = GetMetadataViewProvidersMap(customizedCatalog);

            // Validate configuration.
            var errors = new List <ComposedPartDiagnostic>();

            foreach (var part in parts)
            {
                errors.AddRange(part.Validate(metadataViewsAndProviders));
            }

            // Detect loops of all non-shared parts.
            errors.AddRange(FindLoops(parts));

            if (errors.Count > 0)
            {
                var invalidParts = ImmutableHashSet.CreateRange(errors.SelectMany(error => error.Parts).Select(p => p.Definition));
                if (invalidParts.IsEmpty)
                {
                    // If we can't identify the faulty parts but we still have errors, we have to just throw.
                    throw new CompositionFailedException(Strings.FailStableComposition, ImmutableStack.Create <IReadOnlyCollection <ComposedPartDiagnostic> >(errors));
                }

                var salvagedParts   = catalog.Parts.Except(invalidParts);
                var salvagedCatalog = ComposableCatalog.Create(catalog.Resolver).AddParts(salvagedParts);
                var configuration   = Create(salvagedCatalog);
                return(configuration.WithErrors(errors));
            }

            return(new CompositionConfiguration(
                       catalog,
                       parts,
                       metadataViewsAndProviders,
                       ImmutableStack <IReadOnlyCollection <ComposedPartDiagnostic> > .Empty,
                       sharingBoundaryOverrides));
        }
 internal static AbstractLocation CreateAllocationLocation(IOperation creation, ITypeSymbol locationType, ImmutableStack <IOperation> callStackOpt)
 => Create(creation, callStackOpt, analysisEntityOpt: null, symbolOpt: null, captureIdOpt: null, locationType: locationType);
Beispiel #37
0
 public MemberMetadataInfo()
 {
     Kind      = MemberKind.Type;
     Names     = new List <string>();
     Modifiers = ImmutableStack.Create <MemberModifiedMetadata>();
 }
Beispiel #38
0
 private Map(int id, bool[,] filled, PositionedUnit unit, ImmutableStack<Unit> nextUnits, Scores scores)
     : this(id, filled,
            unit,
            nextUnits, ImmutableHashSet<PositionedUnit>.Empty.Add(unit), scores)
 {
 }
Beispiel #39
0
 public static IMarkdownContext SetFilePathStack(this IMarkdownContext context, ImmutableStack <string> filePathStack)
 {
     if (context == null)
     {
         throw new ArgumentNullException(nameof(context));
     }
     return(context.CreateContext(context.Variables.SetItem(FilePathStackKey, filePathStack)));
 }
 public static AbstractLocation CreateFlowCaptureLocation(InterproceduralCaptureId captureId, ITypeSymbol locationType, ImmutableStack <IOperation> creationCallStackOpt)
 => Create(creationOpt: null, creationCallStackOpt: creationCallStackOpt, analysisEntityOpt: null, symbolOpt: null, captureIdOpt: captureId, locationType: locationType);
 public static AbstractLocation CreateThisOrMeLocation(INamedTypeSymbol namedTypeSymbol, ImmutableStack <IOperation> creationCallStackOpt)
 => Create(creationOpt: null, creationCallStackOpt: creationCallStackOpt, analysisEntityOpt: null, symbolOpt: namedTypeSymbol, captureIdOpt: null, locationType: namedTypeSymbol);
        public void Initialize()
        {
            MyInt16          = 1;
            MyInt32          = 2;
            MyInt64          = 3;
            MyUInt16         = 4;
            MyUInt32         = 5;
            MyUInt64         = 6;
            MyByte           = 7;
            MySByte          = 8;
            MyChar           = 'a';
            MyString         = "Hello";
            MyBooleanTrue    = true;
            MyBooleanFalse   = false;
            MySingle         = 1.1f;
            MyDouble         = 2.2d;
            MyDecimal        = 3.3m;
            MyDateTime       = new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc);
            MyDateTimeOffset = new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0));
            MyGuid           = new Guid("1B33498A-7B7D-4DDA-9C13-F6AA4AB449A6");
            MyUri            = new Uri("https://github.com/dotnet/corefx");
            MyEnum           = SampleEnum.Two;

            MyInt16Array          = new short[] { 1 };
            MyInt32Array          = new int[] { 2 };
            MyInt64Array          = new long[] { 3 };
            MyUInt16Array         = new ushort[] { 4 };
            MyUInt32Array         = new uint[] { 5 };
            MyUInt64Array         = new ulong[] { 6 };
            MyByteArray           = new byte[] { 7 };
            MySByteArray          = new sbyte[] { 8 };
            MyCharArray           = new char[] { 'a' };
            MyStringArray         = new string[] { "Hello" };
            MyBooleanTrueArray    = new bool[] { true };
            MyBooleanFalseArray   = new bool[] { false };
            MySingleArray         = new float[] { 1.1f };
            MyDoubleArray         = new double[] { 2.2d };
            MyDecimalArray        = new decimal[] { 3.3m };
            MyDateTimeArray       = new DateTime[] { new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc) };
            MyDateTimeOffsetArray = new DateTimeOffset[] { new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0)) };
            MyGuidArray           = new Guid[] { new Guid("1B33498A-7B7D-4DDA-9C13-F6AA4AB449A6") };
            MyUriArray            = new Uri[] { new Uri("https://github.com/dotnet/corefx") };
            MyEnumArray           = new SampleEnum[] { SampleEnum.Two };

            MyInt16TwoDimensionArray    = new int[2][];
            MyInt16TwoDimensionArray[0] = new int[] { 10, 11 };
            MyInt16TwoDimensionArray[1] = new int[] { 20, 21 };

            MyInt16TwoDimensionList = new List <List <int> >();
            MyInt16TwoDimensionList.Add(new List <int> {
                10, 11
            });
            MyInt16TwoDimensionList.Add(new List <int> {
                20, 21
            });

            MyInt16ThreeDimensionArray       = new int[2][][];
            MyInt16ThreeDimensionArray[0]    = new int[2][];
            MyInt16ThreeDimensionArray[1]    = new int[2][];
            MyInt16ThreeDimensionArray[0][0] = new int[] { 11, 12 };
            MyInt16ThreeDimensionArray[0][1] = new int[] { 13, 14 };
            MyInt16ThreeDimensionArray[1][0] = new int[] { 21, 22 };
            MyInt16ThreeDimensionArray[1][1] = new int[] { 23, 24 };

            MyInt16ThreeDimensionList = new List <List <List <int> > >();
            var list1 = new List <List <int> >();

            MyInt16ThreeDimensionList.Add(list1);
            list1.Add(new List <int> {
                11, 12
            });
            list1.Add(new List <int> {
                13, 14
            });
            var list2 = new List <List <int> >();

            MyInt16ThreeDimensionList.Add(list2);
            list2.Add(new List <int> {
                21, 22
            });
            list2.Add(new List <int> {
                23, 24
            });

            MyStringList = new List <string>()
            {
                "Hello"
            };

            MyStringIEnumerable = new string[] { "Hello" };
            MyStringIList       = new string[] { "Hello" };
            MyStringICollection = new string[] { "Hello" };

            MyStringIEnumerableT         = new string[] { "Hello" };
            MyStringIListT               = new string[] { "Hello" };
            MyStringICollectionT         = new string[] { "Hello" };
            MyStringIReadOnlyCollectionT = new string[] { "Hello" };
            MyStringIReadOnlyListT       = new string[] { "Hello" };
            MyStringISetT = new HashSet <string> {
                "Hello"
            };

            //MyStringToStringKeyValuePair = new KeyValuePair<string, string>("myKey", "myValue");
            MyStringToStringIDict = new Dictionary <string, string> {
                { "key", "value" }
            };

            MyStringToStringGenericDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringGenericIDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringGenericIReadOnlyDict = new Dictionary <string, string> {
                { "key", "value" }
            };

            MyStringToStringImmutableDict       = ImmutableDictionary.CreateRange(MyStringToStringGenericDict);
            MyStringToStringIImmutableDict      = ImmutableDictionary.CreateRange(MyStringToStringGenericDict);
            MyStringToStringImmutableSortedDict = ImmutableSortedDictionary.CreateRange(MyStringToStringGenericDict);

            MyStringStackT = new Stack <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringQueueT = new Queue <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringHashSetT = new HashSet <string>(new List <string>()
            {
                "Hello"
            });
            MyStringLinkedListT = new LinkedList <string>(new List <string>()
            {
                "Hello"
            });
            MyStringSortedSetT = new SortedSet <string>(new List <string>()
            {
                "Hello"
            });

            MyStringIImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableHashSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutablQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableSortedSetT = ImmutableSortedSet.CreateRange(new List <string> {
                "Hello"
            });

            MyListOfNullString = new List <string> {
                null
            };
        }
 internal static ThrownExceptionInfo Create(BasicBlock block, INamedTypeSymbol exceptionType, ImmutableStack <IOperation>?interproceduralCallStackOpt)
 {
     return(new ThrownExceptionInfo(block, exceptionType, interproceduralCallStackOpt, isDefaultExceptionForExceptionsPathAnalysis: false));
 }
 internal ThrownExceptionInfo With(BasicBlock block, ImmutableStack <IOperation>?interproceduralCallStackOpt)
 {
     Debug.Assert(interproceduralCallStackOpt != InterproceduralCallStack);
     return(new ThrownExceptionInfo(block, ExceptionType, interproceduralCallStackOpt, IsDefaultExceptionForExceptionsPathAnalysis));
 }
 public static AbstractLocation CreateSymbolLocation(ISymbol symbol, ImmutableStack <IOperation> creationCallStackOpt)
 => Create(creationOpt: null, creationCallStackOpt: creationCallStackOpt, analysisEntityOpt: null, symbolOpt: symbol, captureIdOpt: null, locationType: symbol.GetMemberOrLocalOrParameterType());
Beispiel #46
0
 /// <summary>
 /// Initializes a new <see cref="Verifier"/>.
 /// </summary>
 /// <param name="context">The context stack to include.</param>
 private Verifier(ImmutableStack <String> context) => Context = context;
        public void Initialize()
        {
            MyInt16          = 1;
            MyInt32          = 2;
            MyInt64          = 3;
            MyUInt16         = 4;
            MyUInt32         = 5;
            MyUInt64         = 6;
            MyByte           = 7;
            MySByte          = 8;
            MyChar           = 'a';
            MyString         = "Hello";
            MyBooleanTrue    = true;
            MyBooleanFalse   = false;
            MySingle         = 1.1f;
            MyDouble         = 2.2d;
            MyDecimal        = 3.3m;
            MyDateTime       = new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc);
            MyDateTimeOffset = new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0));
            MyEnum           = SampleEnum.Two;

            MyInt16Array          = new short[] { 1 };
            MyInt32Array          = new int[] { 2 };
            MyInt64Array          = new long[] { 3 };
            MyUInt16Array         = new ushort[] { 4 };
            MyUInt32Array         = new uint[] { 5 };
            MyUInt64Array         = new ulong[] { 6 };
            MyByteArray           = new byte[] { 7 };
            MySByteArray          = new sbyte[] { 8 };
            MyCharArray           = new char[] { 'a' };
            MyStringArray         = new string[] { "Hello" };
            MyBooleanTrueArray    = new bool[] { true };
            MyBooleanFalseArray   = new bool[] { false };
            MySingleArray         = new float[] { 1.1f };
            MyDoubleArray         = new double[] { 2.2d };
            MyDecimalArray        = new decimal[] { 3.3m };
            MyDateTimeArray       = new DateTime[] { new DateTime(2019, 1, 30, 12, 1, 2, DateTimeKind.Utc) };
            MyDateTimeOffsetArray = new DateTimeOffset[] { new DateTimeOffset(2019, 1, 30, 12, 1, 2, new TimeSpan(1, 0, 0)) };
            MyEnumArray           = new SampleEnum[] { SampleEnum.Two };

            MyStringList = new List <string>()
            {
                "Hello"
            };
            MyStringIEnumerableT         = new string[] { "Hello" };
            MyStringIListT               = new string[] { "Hello" };
            MyStringICollectionT         = new string[] { "Hello" };
            MyStringIReadOnlyCollectionT = new string[] { "Hello" };
            MyStringIReadOnlyListT       = new string[] { "Hello" };

            MyStringToStringDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringIDict = new Dictionary <string, string> {
                { "key", "value" }
            };
            MyStringToStringIReadOnlyDict = new Dictionary <string, string> {
                { "key", "value" }
            };

            MyStringStackT = new Stack <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringQueueT = new Queue <string>(new List <string>()
            {
                "Hello", "World"
            });
            MyStringHashSetT = new HashSet <string>(new List <string>()
            {
                "Hello"
            });
            MyStringLinkedListT = new LinkedList <string>(new List <string>()
            {
                "Hello"
            });
            MyStringSortedSetT = new SortedSet <string>(new List <string>()
            {
                "Hello"
            });

            MyStringIImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringIImmutableSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableHashSetT = ImmutableHashSet.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableListT = ImmutableList.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableStackT = ImmutableStack.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutablQueueT = ImmutableQueue.CreateRange(new List <string> {
                "Hello"
            });
            MyStringImmutableSortedSetT = ImmutableSortedSet.CreateRange(new List <string> {
                "Hello"
            });

            MyListOfNullString = new List <string> {
                null
            };
        }
Beispiel #48
0
		/// <summary>
		/// Pops the stacked input handler (and all input handlers above it).
		/// If <paramref name="inputHandler"/> is not found in the currently stacked input handlers, or is null, this method
		/// does nothing.
		/// </summary>
		/// <remarks><inheritdoc cref="ITextAreaInputHandler"/></remarks>
		public void PopStackedInputHandler(TextAreaStackedInputHandler inputHandler)
		{
			if (stackedInputHandlers.Any(i => i == inputHandler)) {
				ITextAreaInputHandler oldHandler;
				do {
					oldHandler = stackedInputHandlers.Peek();
					stackedInputHandlers = stackedInputHandlers.Pop();
					oldHandler.Detach();
				} while (oldHandler != inputHandler);
			}
		}
Beispiel #49
0
        public static void ArrayAsRootObject()
        {
            const string ExpectedJson         = @"[1,true,{""City"":""MyCity""},null,""foo""]";
            const string ReversedExpectedJson = @"[""foo"",null,{""City"":""MyCity""},true,1]";

            string[] expectedObjects = { @"""foo""", @"null", @"{""City"":""MyCity""}", @"true", @"1" };

            var address = new Address();

            address.Initialize();

            var    array = new object[] { 1, true, address, null, "foo" };
            string json  = JsonSerializer.Serialize(array);

            Assert.Equal(ExpectedJson, json);

            var dictionary = new Dictionary <string, string> {
                { "City", "MyCity" }
            };
            var arrayWithDictionary = new object[] { 1, true, dictionary, null, "foo" };

            json = JsonSerializer.Serialize(arrayWithDictionary);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(array);
            Assert.Equal(ExpectedJson, json);

            List <object> list = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(list);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(list);
            Assert.Equal(ExpectedJson, json);

            IEnumerable ienumerable = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(ienumerable);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(ienumerable);
            Assert.Equal(ExpectedJson, json);

            IList ilist = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(ilist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(ilist);
            Assert.Equal(ExpectedJson, json);

            ICollection icollection = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(icollection);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(icollection);
            Assert.Equal(ExpectedJson, json);

            IEnumerable <object> genericIEnumerable = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIEnumerable);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIEnumerable);
            Assert.Equal(ExpectedJson, json);

            IList <object> genericIList = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIList);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIList);
            Assert.Equal(ExpectedJson, json);

            ICollection <object> genericICollection = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericICollection);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericICollection);
            Assert.Equal(ExpectedJson, json);

            IReadOnlyCollection <object> genericIReadOnlyCollection = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIReadOnlyCollection);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIReadOnlyCollection);
            Assert.Equal(ExpectedJson, json);

            IReadOnlyList <object> genericIReadonlyList = new List <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(genericIReadonlyList);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(genericIReadonlyList);
            Assert.Equal(ExpectedJson, json);

            ISet <object> iset = new HashSet <object> {
                1, true, address, null, "foo"
            };

            json = JsonSerializer.Serialize(iset);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iset);
            Assert.Equal(ExpectedJson, json);

            Stack <object> stack = new Stack <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(stack);
            Assert.Equal(ReversedExpectedJson, json);

            json = JsonSerializer.Serialize <object>(stack);
            Assert.Equal(ReversedExpectedJson, json);

            Queue <object> queue = new Queue <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(queue);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(queue);
            Assert.Equal(ExpectedJson, json);

            HashSet <object> hashset = new HashSet <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(hashset);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(hashset);
            Assert.Equal(ExpectedJson, json);

            LinkedList <object> linkedlist = new LinkedList <object>(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(linkedlist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(linkedlist);
            Assert.Equal(ExpectedJson, json);

            ImmutableArray <object> immutablearray = ImmutableArray.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablearray);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(immutablearray);
            Assert.Equal(ExpectedJson, json);

            IImmutableList <object> iimmutablelist = ImmutableList.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutablelist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iimmutablelist);
            Assert.Equal(ExpectedJson, json);

            IImmutableStack <object> iimmutablestack = ImmutableStack.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iimmutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            IImmutableQueue <object> iimmutablequeue = ImmutableQueue.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutablequeue);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(iimmutablequeue);
            Assert.Equal(ExpectedJson, json);

            IImmutableSet <object> iimmutableset = ImmutableHashSet.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(iimmutableset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            json = JsonSerializer.Serialize <object>(iimmutableset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            ImmutableHashSet <object> immutablehashset = ImmutableHashSet.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablehashset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            json = JsonSerializer.Serialize <object>(immutablehashset);
            foreach (string obj in expectedObjects)
            {
                Assert.Contains(obj, json);
            }

            ImmutableList <object> immutablelist = ImmutableList.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablelist);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(immutablelist);
            Assert.Equal(ExpectedJson, json);

            ImmutableStack <object> immutablestack = ImmutableStack.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            json = JsonSerializer.Serialize <object>(immutablestack);
            Assert.Equal(ReversedExpectedJson, json);

            ImmutableQueue <object> immutablequeue = ImmutableQueue.CreateRange(new List <object> {
                1, true, address, null, "foo"
            });

            json = JsonSerializer.Serialize(immutablequeue);
            Assert.Equal(ExpectedJson, json);

            json = JsonSerializer.Serialize <object>(immutablequeue);
            Assert.Equal(ExpectedJson, json);
        }
Beispiel #50
0
 /// <summary>
 /// Adds a new variable or lambda parameter to the current block.
 /// </summary>
 public void AddVariable(IVariable variable)
 {
     if (variable == null)
         throw new ArgumentNullException("variable");
     localVariableStack = localVariableStack.Push(variable);
 }
Beispiel #51
0
 public void Push(ActionQueue actionQueue)
 {
     _callStack = _callStack.Push(actionQueue);
 }
Beispiel #52
0
 /// <summary>
 /// Opens a new scope for local variables.
 /// </summary>
 public void PushBlock()
 {
     localVariableStack = localVariableStack.Push(null);
 }
 public FluentAssertionsCSharpSyntaxVisitor(params MemberValidator[] members)
 {
     AllMembers = ImmutableStack.Create(members);
     Members    = AllMembers;
 }