Beispiel #1
0
        public override bool VisitDeclaration(Declaration decl)
        {
            if (AlreadyVisited(decl))
                return false;

            if (decl.ExplicityIgnored)
                return true;

            if (!CheckDeclarationAccess(decl))
            {
                Log.Debug("Decl '{0}' was ignored due to invalid access",
                    decl.Name);
                decl.ExplicityIgnored = true;
                return true;
            }

            if (decl.IsDependent)
            {
                decl.ExplicityIgnored = true;
                Log.Debug("Decl '{0}' was ignored due to dependent context",
                    decl.Name);
                return true;
            }

            return true;
        }
        public override bool VisitDeclaration(Declaration decl)
        {
            if (AlreadyVisited(decl))
                return false;

            return !decl.Ignore;
        }
 private static bool IsSupportedStdType(Declaration declaration)
 {
     return declaration.Namespace != null &&
         declaration.TranslationUnit.IsSystemHeader &&
         IsNameSpaceStd(declaration.Namespace) &&
         supportedStdTypes.Contains(declaration.OriginalName);
 }
        public IntellisenseItem(Declaration dtt)
        {
            Overrides = new List<IntellisenseOverride>();
            Name = dtt.Name;
            Glyph = dtt.Glyph;

            StringBuilder docs = new StringBuilder();
            foreach (var element in dtt.DescriptionText.Item)
            {
                if (element.IsDataTipElement)
                {
                    var x = (DataTipElement.DataTipElement)element;
                    Documentation = x.Item1;
                }
                else if (element.IsDataTipElementGroup)
                {
                    foreach (var subElement in ((DataTipElement.DataTipElementGroup)element).Item)
                    {
                        docs.AppendLine(subElement.Item1);
                        Overrides.Add(new IntellisenseOverride
                        {
                            Name = subElement.Item1
                        });
                    }
                }
            }

            if (String.IsNullOrEmpty(Documentation))
            {
                Documentation = docs.ToString();
            }
        }
 public ExplicitIndexSetter(Token Source, Declaration Function, Node Object, Node Index)
     : base(Source)
 {
     this.Function = Function;
     this.Object = Object;
     this.Index = Index;
 }
Beispiel #6
0
        public override bool VisitDeclaration(Declaration decl)
        {
            if (AlreadyVisited(decl))
                return false;

            if (decl.GenerationKind == GenerationKind.None)
                return true;

            if (!CheckDeclarationAccess(decl))
            {
                Log.Debug("Decl '{0}' was ignored due to invalid access",
                    decl.Name);
                decl.GenerationKind = decl is Field ? GenerationKind.Internal : GenerationKind.None;
                return true;
            }

            if (decl.IsDependent)
            {
                decl.GenerationKind = decl is Field ? GenerationKind.Internal : GenerationKind.None;
                Log.Debug("Decl '{0}' was ignored due to dependent context",
                    decl.Name);
                return true;
            }

            return true;
        }
    public void Add(Declaration d)
    {
        if (d == null)
            return;

        decls.Add (d);
    }
 /// <summary>
 /// Initializes a new instance of the DocumentRoot class.
 /// </summary>
 /// <param name="document">
 /// The document that this element belongs to.
 /// </param>
 /// <param name="declaration">
 /// The declaration class for this element.
 /// </param>
 /// <param name="generated">
 /// Indicates whether the element contains generated code.
 /// </param>
 internal DocumentRoot(CsDocument document, Declaration declaration, bool generated)
     : base(document, null, ElementType.Root, Strings.DocumentRoot, null, null, declaration, false, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertNotNull(declaration, "declaration");
     Param.Ignore(generated);
 }
Beispiel #9
0
        public override bool VisitDeclaration(Declaration decl)
        {
            if (decl.CompleteDeclaration != null)
                return true;

            return !decl.IsIncomplete;
        }
        public override bool VisitDeclaration(Declaration decl)
        {
            if (!base.VisitDeclaration(decl))
                return false;

            // Do not clean up namespace names since it can mess up with the
            // names of anonymous or the global namespace.
            if (decl is Namespace)
                return true;

            // types with empty names are assumed to be private
            if (decl is Class && string.IsNullOrWhiteSpace(decl.Name))
            {
                decl.Name = decl.Namespace.Name == "_" ? "__" : "_";
                decl.ExplicitlyIgnore();
                return true;
            }

            Function function = decl as Function;
            if ((function == null || !function.IsOperator) && !(decl is Enumeration))
                decl.Name = CheckName(decl.Name);

            StringHelpers.CleanupText(ref decl.DebugText);
            return true;
        }
Beispiel #11
0
        public override bool VisitDeclaration(Declaration decl)
        {
            if (!base.VisitDeclaration(decl))
                return false;

            if (Driver.Options.IsCSharpGenerator)
            {
                // C# cannot have protected members in static classes.
                var @class = decl.Namespace as Class;
                if (    decl.Access == AccessSpecifier.Protected &&
                        decl.GenerationKind == GenerationKind.Generate &&
                        @class != null &&
                        @class.IsStatic)
                {
                    // By setting it to private it will appear
                    // as an internal in the final C# wrapper.
                    decl.Access = AccessSpecifier.Private;

                    // We need to explicity set the generation else the
                    // now private declaration will get filtered out later.
                    decl.GenerationKind = GenerationKind.Generate;
                }
            }

            return true;
        }
        public bool CheckDeclarationAccess(Declaration decl)
        {
            var generateNonPublicDecls = Driver.Options.IsCSharpGenerator;

            switch (decl.Access)
            {
                case AccessSpecifier.Public:
                    return true;
                case AccessSpecifier.Protected:
                    var @class = decl.Namespace as Class;
                    if (@class != null && @class.IsValueType)
                        return false;
                    return generateNonPublicDecls;
                case AccessSpecifier.Private:
                    var method = decl as Method;
                    var isOverride = false;
                    if (method != null && method.IsOverride)
                    {
                        var baseMethod = ((Class) method.Namespace).GetBaseMethod(method);
                        isOverride = baseMethod.IsGenerated;
                    }
                    return generateNonPublicDecls && (isOverride || decl.IsExplicitlyGenerated);
            }

            return true;
        }
        public override bool VisitDeclaration(Declaration decl)
        {
            if (AlreadyVisited(decl))
                return false;

            return decl.IsGenerated;
        }
Beispiel #14
0
 public static void RenderDeclaration(StringBuilder sb, Declaration decl)
 {
     sb.AppendFormat("{0}:", decl.Name);
     RenderExpression(sb, decl.Expression);
     if (decl.Important)
         sb.Append(" !important");
 }
Beispiel #15
0
 public GenericSetter(Token Source, Declaration Function, String MemberName, Node Object)
     : base(Source)
 {
     this.Function = Function;
     this.Object = Object;
     this.MemberName = MemberName;
 }
        public static AddSignatures GetMethod(Declaration dec)
        {
            switch (dec.PropertyName.Text.ToLowerInvariant())
            {
                case "margin":
                case "padding":
                case "border-width":
                case "outline-width":
                    return Margins;

                case "border-radius":
                    return Corners;

                case "border":
                    return Borders;

                case "font":
                    return Fonts;

                case "columns":
                    return Columns;
            }

            return null;
        }
Beispiel #17
0
 public Declaration Declare(Type type, string name)
 {
     _declarationCounter++;
     string declarationName = name ?? string.Format("$var{0}$", _declarationCounter);
     var declaration = new Declaration(type, declarationName, FullName);
     Add(declaration);
     return declaration;
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the EmptyElement class.
 /// </summary>
 /// <param name="document">
 /// The document that contains the element.
 /// </param>
 /// <param name="parent">
 /// The parent of the element.
 /// </param>
 /// <param name="declaration">
 /// The declaration code for this element.
 /// </param>
 /// <param name="unsafeCode">
 /// Indicates whether the element resides within a block of unsafe code.
 /// </param>
 /// <param name="generated">
 /// Indicates whether the code element was generated or written by hand.
 /// </param>
 internal EmptyElement(CsDocument document, CsElement parent, Declaration declaration, bool unsafeCode, bool generated)
     : base(document, parent, ElementType.EmptyElement, Strings.EmptyElement, null, null, declaration, unsafeCode, generated)
 {
     Param.AssertNotNull(document, "document");
     Param.AssertNotNull(parent, "parent");
     Param.AssertNotNull(declaration, "declaration");
     Param.Ignore(unsafeCode);
     Param.Ignore(generated);
 }
Beispiel #19
0
        public void add(Declaration declaration)
        {
            // an identifier cannot be declared more than once in the same scope
            if (locals.ContainsKey(declaration.identifier)) {
                throw new ScopeException(declaration.identifier.row, declaration.identifier.col, "An identifier cannot be used twice within the same scope.");
            }

            locals.Add(declaration.identifier, declaration);
        }
Beispiel #20
0
 private void IdentifyTopLevelDecl(Declaration decl)
 {
     if (decl is ClassDecl)
         IdentifyClass((ClassDecl) decl);
     else if (decl is LiteralModuleDecl) {
         var literalModule = (LiteralModuleDecl) decl;
         IdentifyModule(literalModule.ModuleDef);
     }
 }
 public void AddDeclaration(Declaration decl)
 {
     decl.IfStack = new List<string>(this.ifStack);
     if (!this.declarations.Any(d => DeclaratorsSame(d, decl)
             && IfStacksSame(d, decl)))
     {
         this.declarations.Add(decl);
     }
 }
 private static bool AccessValid(Declaration declaration)
 {
     if (declaration.Access == AccessSpecifier.Private)
     {
         var method = declaration as Method;
         return method != null && method.IsOverride;
     }
     return true;
 }
Beispiel #23
0
        public override bool VisitDeclaration(Declaration decl)
        {
            if (AlreadyVisited(decl))
                return false;

            if (decl.CompleteDeclaration != null)
                return true;

            return !decl.IsIncomplete;
        }
Beispiel #24
0
        public CLITypeReference GetTypeReference(Declaration decl)
        {
            if(typeReferences.ContainsKey(decl))
                return typeReferences[decl];

            var @ref = new CLITypeReference { Declaration = decl };
            typeReferences.Add(decl, @ref);

            return @ref;
        }
        public void ShouldBeAbleToUseAll()
        {
            declaration = new RangeDeclaration<SimpleClass>(listBuilderImpl, objectBuilder, 9, 10);

            using (mocks.Record())
                listBuilderImpl.Expect(x => x.All()).Return(declaration);

            using (mocks.Playback())
                declaration.All();
        }
        public VendorSmartTagAction(ITrackingSpan span, Declaration declaration, IEnumerable<string> prefixes)
        {
            _span = span;
            _declaration = declaration;
            _prefixes = prefixes;

            if (Icon == null)
            {
                Icon = BitmapFrame.Create(new Uri("pack://application:,,,/WebEssentials2013;component/Resources/Images/warning.png", UriKind.RelativeOrAbsolute));
            }
        }
        public VendorOrderSmartTagAction(ITrackingSpan span, Declaration lastVendor, Declaration standard)
        {
            _span = span;
            _lastVendor = lastVendor;
            _standard = standard;

            if (Icon == null)
            {
                Icon = BitmapFrame.Create(new Uri("pack://application:,,,/WebEssentials2013;component/Resources/Images/warning.png", UriKind.RelativeOrAbsolute));
            }
        }
        public MissingStandardSmartTagAction(ITrackingSpan span, Declaration declaration, string standardName)
        {
            _span = span;
            _declaration = declaration;
            _standardName = standardName;

            if (Icon == null)
            {
                Icon = BitmapFrame.Create(new Uri("pack://application:,,,/WebEssentials2013;component/Resources/Images/warning.png", UriKind.RelativeOrAbsolute));
            }
        }
Beispiel #29
0
        static Namespace GetEffectiveNamespace(Declaration decl)
        {
            if (decl == null || decl.Namespace == null)
                return null;

            var @namespace = decl.Namespace as Namespace;
            if (@namespace != null)
                return @namespace;

            return GetEffectiveNamespace(@namespace);
        }
        public string GetStandardName(Declaration dec)
        {
            string name = dec.PropertyName.Text;
            if (name.Length > 0 && name[0] == '-')
            {
                int index = name.IndexOf('-', 1) + 1;
                name = index > -1 ? name.Substring(index) : name;
            }

            return name;
        }
Beispiel #31
0
 public static void AddInlineAttribute(Declaration decl)
 {
     decl.AddAttribute("inline", new LiteralExpr(Token.NoToken, Microsoft.Basetypes.BigNum.FromInt(1)));
 }
        public void ReplaceCssImagesWithSprite(CombinatorResource resource)
        {
            Func <RuleSet, Term, bool> noSprite =
                (ruleSet, url) =>
            {
                if (url.Value.Contains("no-sprite") ||
                    ruleSet.Selectors.Any(selector => selector.SimpleSelectors.Any(simpleSelector => simpleSelector.Class == "no-sprite")))
                {
                    return(true);
                }

                // Images with a background position are not suitable for sprite generation if they aren't top-left
                if (ruleSet.Declarations.Any(declaration => declaration.Name == "background-position" &&
                                             (declaration.Expression.Terms.Count() != 2 ||
                                              !declaration.Expression.Terms.Any(term => term.Value == "top") ||
                                              !declaration.Expression.Terms.Any(term => term.Value == "left"))))
                {
                    return(true);
                }

                // Images with a background size are not suitable for sprite generation
                if (ruleSet.Declarations.Any(declaration => declaration.Name == "background-size"))
                {
                    return(true);
                }

                // Images with a background repeat are not suitable for sprite generation
                if (ruleSet.Declarations.Any(declaration => declaration.Name == "background-repeat" &&
                                             (declaration.Expression.Terms.Count() != 1 || declaration.Expression.Terms.First().Value != "no-repeat")))
                {
                    return(true);
                }

                var backgroundTerms =
                    ruleSet.Declarations
                    .Where(declaration => declaration.Name == "background")
                    .SelectMany(declaration => declaration.Expression.Terms);

                // Sized backgrounds are not suitable either
                // LineHeightTerm is filled with a value when if in the shorthand background declaration there's the background size specified, e.g.:
                // background: url(url-to-img) 300px 400px / 500px 600px no-repeat;
                // Now there will be a term for 400px, having LineHeightTerm specified for 500px.
                if (backgroundTerms.Any(term => term.LineHeightTerm != null))
                {
                    return(true);
                }

                var backgroundTermValues = backgroundTerms.Select(term => term.Value);

                // Positioned backgrounds are not suitable either, except top-left ones
                if (backgroundTerms
                    .Any(term =>
                         term.Value == "center" ||
                         term.Value == "top" ||
                         term.Value == "right" ||
                         term.Value == "bottom" ||
                         term.Unit != null) &&
                    !(backgroundTermValues.Contains("top") && backgroundTermValues.Contains("left")))
                {
                    return(true);
                }

                if (backgroundTermValues.Any(value => value == "repeat-x" || value == "repeat-y" || value == "repeat"))
                {
                    return(true);
                }

                return(false);
            };

            var images     = new Dictionary <string, CssImage>();
            var stylesheet = new StylesheetParser().Parse(resource.Content);

            ProcessImageUrls(
                resource,
                stylesheet,
                (ruleSet, urlTerm) =>
            {
                var url = urlTerm.Value;

                if (noSprite(ruleSet, urlTerm))
                {
                    return;
                }

                var imageContent = _resourceFileService.GetImageContent(InlineUriFactory(resource, url));

                if (imageContent.Length / 1024 <= 5000)
                {
                    images[url] = new CssImage {
                        Content = imageContent
                    };
                }
            });

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

            _cacheFileService.WriteSpriteStream(
                resource.Content.GetHashCode() + ".jpg",
                (stream, publicUrl) =>
            {
                using (var sprite = new Sprite(images.Values.Select(image => image.Content)))
                {
                    var imageEnumerator = images.Values.GetEnumerator();
                    foreach (var backgroundImage in sprite.Generate(stream, ImageFormat.Jpeg))
                    {
                        imageEnumerator.MoveNext();
                        imageEnumerator.Current.BackgroundImage     = backgroundImage;
                        imageEnumerator.Current.BackgroundImage.Url = InlineUriFactory(resource, publicUrl);
                    }
                }
            });

            ProcessImageUrls(
                resource,
                stylesheet,
                (ruleSet, urlTerm) =>
            {
                var url = urlTerm.Value;

                if (images.ContainsKey(url))
                {
                    var backgroundImage = images[url].BackgroundImage;

                    var imageDeclaration = new Declaration
                    {
                        Name       = "background-image",
                        Expression = new Expression
                        {
                            Terms = new List <Term>
                            {
                                new Term {
                                    Type = TermType.Url, Value = backgroundImage.Url.ToStringWithoutScheme()
                                }
                            }
                        }
                    };
                    ruleSet.Declarations.Add(imageDeclaration);

                    var bgPosition          = backgroundImage.Position;
                    var positionDeclaration = new Declaration
                    {
                        Name       = "background-position",
                        Expression = new Expression
                        {
                            Terms = new List <Term>
                            {
                                new Term {
                                    Type = TermType.Number, Value = bgPosition.X.ToString(), Unit = Unit.Px
                                },
                                new Term {
                                    Type = TermType.Number, Value = bgPosition.Y.ToString(), Unit = Unit.Px
                                }
                            }
                        }
                    };
                    ruleSet.Declarations.Add(positionDeclaration);
                }
            });

            resource.Content = stylesheet.ToString();
        }
 public override Instruction TransformDeclaration(Declaration decl)
 {
     base.TransformDeclaration(decl);
     decl.Identifier.DataType = decl.Identifier.TypeVariable.DataType;
     return(decl);
 }
Beispiel #34
0
 private void Visit(LetCoercionDefaultMemberAccessExpression expression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(expression.WrappedExpression, parent, withExpression);
 }
Beispiel #35
0
 private void Visit(TypeOfIsExpression expression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(expression.Expression, parent, withExpression);
     Visit(expression.TypeExpression, parent, withExpression);
 }
Beispiel #36
0
 public void CollectUnresolved(IBoundExpression boundExpression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(boundExpression, parent, withExpression);
 }
Beispiel #37
0
 //TODO: Specify ErrorCode as Warning
 public static AnalysisError VariableHidesAnotherOne(Declaration node) =>
 new AnalysisError(string.Format(LoadMessage("Hide"), node.Id), node.Line, node.Columns);
Beispiel #38
0
        public object Visit(Declaration obj)
        {
            _symbolTable.AddToTable(obj.IdentifierNode, obj.TypeNode.Accept(this).ToString());////TESTFIX
            string codeString = "";

            string tempSwitchString = (string)obj.TypeNode.Accept(this);

            //<Declaration> ::= <Type> Identifier
            switch (tempSwitchString.ToLower())
            {
            case "integer":
                codeString += "int " + obj.IdentifierNode + ";";
                break;

            case "decimal":
                codeString += "double " + obj.IdentifierNode + ";";
                break;

            case "string":
                codeString += "string " + obj.IdentifierNode + ";";
                break;

            case "boolean":
                codeString += "bool " + obj.IdentifierNode + ";";
                break;

            case "point":
                codeString += "Vector2 " + obj.IdentifierNode + ";";
                break;

            case "character":
                codeString += "GameObject " + obj.IdentifierNode + ";";
                if (_preVisit)
                {
                    _instantiateList.Add(obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/CharacterPrefab\"));");
                }
                else
                {
                    codeString += obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/CharacterPrefab\"));";
                }
                break;

            case "enemy":
                throw new NotImplementedException();

            case "camera":
                codeString += "GameObject " + obj.IdentifierNode + ";";
                if (_preVisit)
                {
                    _instantiateList.Add(obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/CameraPrefab\"));");
                }
                else
                {
                    codeString += obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/CameraPrefab\"));";
                }
                break;

            case "square":
                codeString += "GameObject " + obj.IdentifierNode + ";";
                if (_preVisit)
                {
                    _instantiateList.Add(obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/SquarePrefab\"));");
                }
                else
                {
                    codeString += obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/SquarePrefab\"));";
                }
                break;

            case "triangle":
                codeString += "GameObject " + obj.IdentifierNode + ";";
                if (_preVisit)
                {
                    _instantiateList.Add(obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/TrianglePrefab\"));");
                }
                else
                {
                    codeString += obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/TrianglePrefab\"));";
                }
                break;

            case "sprite":
                codeString += "GameObject " + obj.IdentifierNode + ";";
                if (_preVisit)
                {
                    _instantiateList.Add(obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/SpritePrefab\"));");
                }
                else
                {
                    codeString += obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/SpritePrefab\"));";
                }
                break;

            case "text":
                codeString += "GameObject " + obj.IdentifierNode + ";";
                if (_preVisit)
                {
                    _instantiateList.Add(obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/UITextPrefab\"));");
                }
                else
                {
                    codeString += obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/UITextPrefab\"));";
                }
                break;

            case "trigger":
                codeString += "GameObject " + obj.IdentifierNode + ";";
                if (_preVisit)
                {
                    _instantiateList.Add(obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/TriggerPrefab\"));");
                }
                else
                {
                    codeString += obj.IdentifierNode + " = (GameObject) Instantiate(Resources.Load(\"Prefabs/TriggerPrefab\"));";
                }
                break;
            }
            return(codeString);
        }
 public Assignment(Declaration decl, Immediate imm)
 {
     LValue = decl;
     RValue = imm;
 }
Beispiel #40
0
 public LocalVariable(Declaration decl) : base(Precedence.ATOMIC) => _decl = decl;
Beispiel #41
0
        public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan)
        {
            applicableToSpan = null;

            if (!EnsureTreeInitialized() || session == null || qiContent == null || qiContent.Count > 0 || !WESettings.GetBoolean(WESettings.Keys.ShowBrowserTooltip))
            {
                return;
            }

            SnapshotPoint?point = session.GetTriggerPoint(_buffer.CurrentSnapshot);

            if (!point.HasValue)
            {
                return;
            }

            ParseItem item = _tree.StyleSheet.ItemBeforePosition(point.Value.Position);

            if (item == null || !item.IsValid)
            {
                return;
            }

            ParseItem theOne = null;
            ICssCompletionListEntry entry  = null;
            ICssSchemaInstance      schema = CssSchemaManager.SchemaManager.GetSchemaForItem(_rootSchema, item);

            // Declaration
            Declaration dec = item.FindType <Declaration>();

            if (dec != null && dec.PropertyName != null && dec.PropertyName.ContainsRange(point.Value.Position, 1))
            {
                entry  = schema.GetProperty(dec.PropertyName.Text);
                theOne = dec.PropertyName;
            }
            else if (dec != null && dec.IsValid && dec.Values.TextStart <= point.Value.Position && dec.Values.TextAfterEnd >= point.Value.Position)
            {
                entry = schema.GetProperty(dec.PropertyName.Text);
                if (entry != null)
                {
                    var list = schema.GetPropertyValues(entry.DisplayText);
                    theOne = dec.StyleSheet.ItemFromRange(point.Value.Position, 0);
                    entry  = list.SingleOrDefault(r => r.DisplayText.Equals(theOne.Text, StringComparison.OrdinalIgnoreCase));
                }
            }

            // Pseudo class
            if (entry == null)
            {
                PseudoClassSelector pseudoClass = item.FindType <PseudoClassSelector>();
                if (pseudoClass != null)
                {
                    entry  = schema.GetPseudo(pseudoClass.Text);
                    theOne = pseudoClass;
                }
            }

            // Pseudo class function
            if (entry == null)
            {
                PseudoClassFunctionSelector pseudoClassFunction = item.FindType <PseudoClassFunctionSelector>();
                if (pseudoClassFunction != null)
                {
                    entry  = schema.GetPseudo(pseudoClassFunction.Text);
                    theOne = pseudoClassFunction;
                }
            }

            // Pseudo element
            if (entry == null)
            {
                PseudoElementSelector pseudoElement = item.FindType <PseudoElementSelector>();
                if (pseudoElement != null)
                {
                    entry  = schema.GetPseudo(pseudoElement.Text);
                    theOne = pseudoElement;
                }
            }

            // Pseudo element function
            if (entry == null)
            {
                PseudoElementFunctionSelector pseudoElementFunction = item.FindType <PseudoElementFunctionSelector>();
                if (pseudoElementFunction != null)
                {
                    entry  = schema.GetPseudo(pseudoElementFunction.Text);
                    theOne = pseudoElementFunction;
                }
            }

            // @-directive
            if (entry == null)
            {
                AtDirective atDirective = item.Parent as AtDirective;
                if (atDirective != null && atDirective.Keyword != null)
                {
                    entry  = schema.GetAtDirective("@" + atDirective.Keyword.Text);
                    theOne = atDirective.Keyword;
                }
            }

            if (entry != null)
            {
                applicableToSpan = _buffer.CurrentSnapshot.CreateTrackingSpan(theOne.Start, theOne.Length, SpanTrackingMode.EdgeNegative);

                string syntax = entry.GetSyntax(schema.Version);
                string b      = entry.GetAttribute("browsers");

                if (string.IsNullOrEmpty(b) && theOne.Parent != null && theOne.Parent is Declaration)
                {
                    b = schema.GetProperty(((Declaration)theOne.Parent).PropertyName.Text).GetAttribute("browsers");
                    if (string.IsNullOrEmpty(syntax))
                    {
                        syntax = theOne.Text;
                    }
                }

                if (!string.IsNullOrEmpty(syntax))
                {
                    qiContent.Add("Example: " + syntax);
                }

                Dictionary <string, string> browsers = GetBrowsers(b);
                qiContent.Add(CreateBrowserList(browsers));
            }
        }
        /// <summary>
        ///     Recursively called to transform each type of node. Will transform this
        ///     node, then all it's children.
        /// </summary>
        /// <param name="s">The current node to transform.</param>
        /// <param name="GlobalMethods"> </param>
        /// <param name="MethodArguements"> </param>
        /// <param name="scopesParent"> </param>
        /// <param name="scopeCurrent"> </param>
        private void TransformNode(SYMBOL s, Dictionary <string, string> GlobalMethods,
                                   Dictionary <string, ObjectList> MethodArguements, List <int> scopesParent,
                                   int scopeCurrent)
        {
            // make sure to put type lower in the inheritance hierarchy first
            // ie: since IdentConstant and StringConstant inherit from Constant,
            // put IdentConstant and StringConstant before Constant
            if (s is Declaration)
            {
                Declaration dec = (Declaration)s;
                dec.Datatype = m_datatypeLSL2OpenSim[dec.Datatype];
            }
            else if (s is Constant)
            {
                ((Constant)s).Type = m_datatypeLSL2OpenSim[((Constant)s).Type];
            }
            else if (s is TypecastExpression)
            {
                ((TypecastExpression)s).TypecastType = m_datatypeLSL2OpenSim[((TypecastExpression)s).TypecastType];
            }
            else if (s is GlobalFunctionDefinition)
            {
                GlobalFunctionDefinition fun = (GlobalFunctionDefinition)s;
                if ("void" == fun.ReturnType) // we don't need to translate "void"
                {
                    if (GlobalMethods != null && !GlobalMethods.ContainsKey(fun.Name))
                    {
                        GlobalMethods.Add(fun.Name, "void");
                    }
                }
                else
                {
                    fun.ReturnType =
                        m_datatypeLSL2OpenSim[fun.ReturnType];
                    if (GlobalMethods != null && !GlobalMethods.ContainsKey(fun.Name))
                    {
                        GlobalMethods.Add(fun.Name, fun.ReturnType);
                        MethodArguements.Add(fun.Name, (s).kids);
                    }
                }
                //Reset the variables, we changed events
                m_currentEvent = fun.Name;
                m_localVariableValues.Add("global_function_" + fun.Name, new Dictionary <string, SYMBOL>());
                m_localVariableValuesStr.Add("global_function_" + fun.Name, new Dictionary <string, string>());
                m_duplicatedLocalVariableValues.Add("global_function_" + fun.Name, new Dictionary <string, SYMBOL>());
                m_localVariableScope.Add("global_function_" + fun.Name, new Dictionary <string, int>());
                // this is a new function, lets clear the parent scopes and set the current scope to this
                scopesParent.Clear();
                scopeCurrent = s.pos;
                scopesParent.Add(scopeCurrent);
            }
            else if (s is State)
            {
                //Reset the variables, we changed events
                State evt = (State)s;
                m_currentState = evt.Name;
            }
            else if (s is StateEvent)
            {
                //Reset the variables, we changed events
                StateEvent evt = (StateEvent)s;
                FixEventName(m_originalScript, ref evt);
                m_currentEvent = evt.Name;
                m_localVariableValues.Add(m_currentState + "_" + evt.Name, new Dictionary <string, SYMBOL>());
                m_localVariableValuesStr.Add(m_currentState + "_" + evt.Name, new Dictionary <string, string>());
                m_duplicatedLocalVariableValues.Add(m_currentState + "_" + evt.Name, new Dictionary <string, SYMBOL>());
                m_localVariableScope.Add(m_currentState + "_" + evt.Name, new Dictionary <string, int>());
                // this is a new state event, lets clear the parent scopes and set the current scope to this
                scopesParent.Clear();
                scopeCurrent = s.pos;
                scopesParent.Add(scopeCurrent);
            }
            else if (s is ArgumentDeclarationList)
            {
                ArgumentDeclarationList adl = (ArgumentDeclarationList)s;
                foreach (SYMBOL child in adl.kids)
                {
                    Declaration d = child as Declaration;
                    if (d != null)
                    {
                        m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()][d.Id] = null;
                    }
                }
                //m_duplicatedLocalVariableValues.Add(m_currentState + "_" + evt.Name, new Dictionary<string, SYMBOL>());
            }
            else if (s is GlobalVariableDeclaration)
            {
                GlobalVariableDeclaration gvd = (GlobalVariableDeclaration)s;
                foreach (SYMBOL child in gvd.kids)
                {
                    if (child is Assignment)
                    {
                        bool   isDeclaration = false;
                        string decID         = "";
                        foreach (SYMBOL assignmentChild in child.kids)
                        {
                            if (assignmentChild is Declaration)
                            {
                                Declaration d = (Declaration)assignmentChild;
                                decID         = d.Id;
                                isDeclaration = true;
                            }
                            else if (assignmentChild is IdentExpression)
                            {
                                IdentExpression identEx = (IdentExpression)assignmentChild;
                                if (isDeclaration)
                                {
                                    if (m_globalVariableValues.ContainsKey(decID))
                                    {
                                        m_duplicatedGlobalVariableValues[decID] = identEx;
                                    }
                                    m_globalVariableValues[decID] = identEx.Name;
                                }
                            }
                            else if (assignmentChild is ListConstant)
                            {
                                ListConstant listConst = (ListConstant)assignmentChild;
                                foreach (SYMBOL listChild in listConst.kids)
                                {
                                    if (listChild is ArgumentList)
                                    {
                                        ArgumentList argList = (ArgumentList)listChild;
                                        int          i       = 0;
                                        bool         changed = false;
                                        object[]     p       = new object[argList.kids.Count];
                                        foreach (SYMBOL objChild in argList.kids)
                                        {
                                            p[i] = objChild;
                                            if (objChild is IdentExpression)
                                            {
                                                IdentExpression identEx = (IdentExpression)objChild;
                                                if (m_globalVariableValues.ContainsKey(identEx.Name))
                                                {
                                                    changed = true;
                                                    p[i]    = new IdentExpression(identEx.yyps,
                                                                                  m_globalVariableValues[identEx.Name])
                                                    {
                                                        pos      = objChild.pos,
                                                        m_dollar = objChild.m_dollar
                                                    };
                                                }
                                            }
                                            i++;
                                        }
                                        if (changed)
                                        {
                                            argList.kids = new ObjectList();
                                            foreach (object o in p)
                                            {
                                                argList.kids.Add(o);
                                            }
                                        }
                                        if (isDeclaration)
                                        {
                                            if (m_globalVariableValues.ContainsKey(decID))
                                            {
                                                m_duplicatedGlobalVariableValues[decID] = listConst;
                                            }
                                            m_globalVariableValues[decID] = listConst.Value;
                                        }
                                    }
                                }
                            }
                            else if (assignmentChild is VectorConstant || assignmentChild is RotationConstant)
                            {
                                Constant listConst = (Constant)assignmentChild;
                                int      i         = 0;
                                bool     changed   = false;
                                object[] p         = new object[listConst.kids.Count];
                                foreach (SYMBOL objChild in listConst.kids)
                                {
                                    p[i] = objChild;
                                    if (objChild is IdentExpression)
                                    {
                                        IdentExpression identEx = (IdentExpression)objChild;
                                        if (m_globalVariableValues.ContainsKey(identEx.Name))
                                        {
                                            changed = true;
                                            p[i]    = new IdentExpression(identEx.yyps,
                                                                          m_globalVariableValues[identEx.Name])
                                            {
                                                pos      = objChild.pos,
                                                m_dollar = objChild.m_dollar
                                            };
                                        }
                                    }
                                    i++;
                                }
                                if (changed)
                                {
                                    listConst.kids = new ObjectList();
                                    foreach (object o in p)
                                    {
                                        listConst.kids.Add(o);
                                    }
                                }
                                if (isDeclaration)
                                {
                                    if (m_globalVariableValues.ContainsKey(decID))
                                    {
                                        m_duplicatedGlobalVariableValues[decID] = listConst;
                                    }
                                    m_globalVariableValues[decID] = listConst.Value;
                                }
                            }
                            else if (assignmentChild is Constant)
                            {
                                Constant identEx = (Constant)assignmentChild;
                                if (isDeclaration)
                                {
                                    if (m_globalVariableValues.ContainsKey(decID))
                                    {
                                        m_duplicatedGlobalVariableValues[decID] = identEx;
                                    }
                                    m_globalVariableValues[decID] = identEx.Value;
                                }
                            }
                        }
                    }
                }
            }
            else if (s is Assignment && m_currentEvent != "")
            {
                Assignment ass           = (Assignment)s;
                bool       isDeclaration = false;
                string     decID         = "";
                foreach (SYMBOL assignmentChild in ass.kids)
                {
                    if (assignmentChild is Declaration)
                    {
                        Declaration d = (Declaration)assignmentChild;
                        decID         = d.Id;
                        isDeclaration = true;
                    }
                    else if (assignmentChild is IdentExpression)
                    {
                        IdentExpression identEx = (IdentExpression)assignmentChild;
                        if (isDeclaration)
                        {
                            if (m_localVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(decID) &&
                                !m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(decID) &&
                                scopesParent.Contains(m_localVariableScope[GetLocalVariableDictionaryKey()][decID]))
                            {
                                m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()][decID] =
                                    m_localVariableValues[GetLocalVariableDictionaryKey()][decID];
                            }
                            m_localVariableValues[GetLocalVariableDictionaryKey()][decID]    = identEx;
                            m_localVariableValuesStr[GetLocalVariableDictionaryKey()][decID] = identEx.Name;
                            m_localVariableScope[GetLocalVariableDictionaryKey()][decID]     = scopeCurrent;
                        }
                    }
                    else if (assignmentChild is ListConstant)
                    {
                        ListConstant listConst = (ListConstant)assignmentChild;
                        foreach (SYMBOL listChild in listConst.kids)
                        {
                            if (listChild is ArgumentList)
                            {
                                ArgumentList argList = (ArgumentList)listChild;
                                int          i       = 0;
                                bool         changed = false;
                                object[]     p       = new object[argList.kids.Count];
                                foreach (SYMBOL objChild in argList.kids)
                                {
                                    p[i] = objChild;
                                    if (objChild is IdentExpression)
                                    {
                                        IdentExpression identEx = (IdentExpression)objChild;
                                        if (
                                            m_localVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(
                                                identEx.Name) && m_localVariableValuesStr[GetLocalVariableDictionaryKey()][identEx.Name] != null)
                                        {
                                            changed = true;
                                            p[i]    = new IdentExpression(identEx.yyps,
                                                                          m_localVariableValuesStr[
                                                                              GetLocalVariableDictionaryKey()][identEx.Name
                                                                          ])
                                            {
                                                pos      = objChild.pos,
                                                m_dollar = objChild.m_dollar
                                            };
                                        }
                                    }
                                    i++;
                                }
                                if (changed)
                                {
                                    argList.kids = new ObjectList();
                                    foreach (object o in p)
                                    {
                                        argList.kids.Add(o);
                                    }
                                }
                                if (isDeclaration)
                                {
                                    if (m_localVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(decID) &&
                                        !m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(
                                            decID) &&
                                        scopesParent.Contains(
                                            m_localVariableScope[GetLocalVariableDictionaryKey()][decID]))
                                    {
                                        m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()][decID] =
                                            m_localVariableValues[GetLocalVariableDictionaryKey()][decID];
                                    }
                                    m_localVariableValues[GetLocalVariableDictionaryKey()][decID]    = listConst;
                                    m_localVariableValuesStr[GetLocalVariableDictionaryKey()][decID] = listConst.Value;
                                    m_localVariableScope[GetLocalVariableDictionaryKey()][decID]     = scopeCurrent;
                                }
                            }
                        }
                    }
                    else if (assignmentChild is VectorConstant || assignmentChild is RotationConstant)
                    {
                        Constant listConst = (Constant)assignmentChild;
                        int      i         = 0;
                        bool     changed   = false;
                        object[] p         = new object[listConst.kids.Count];
                        foreach (SYMBOL objChild in listConst.kids)
                        {
                            p[i] = objChild;
                            if (objChild is IdentExpression)
                            {
                                IdentExpression identEx = (IdentExpression)objChild;
                                if (m_localVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(identEx.Name))
                                {
                                    changed = true;
                                    p[i]    = new IdentExpression(identEx.yyps,
                                                                  m_localVariableValuesStr[GetLocalVariableDictionaryKey()]
                                                                  [identEx.Name])
                                    {
                                        pos      = objChild.pos,
                                        m_dollar = objChild.m_dollar
                                    };
                                }
                            }
                            i++;
                        }
                        if (changed)
                        {
                            listConst.kids = new ObjectList();
                            foreach (object o in p)
                            {
                                listConst.kids.Add(o);
                            }
                        }
                        if (isDeclaration)
                        {
                            if (m_localVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(decID) &&
                                !m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(decID) &&
                                scopesParent.Contains(m_localVariableScope[GetLocalVariableDictionaryKey()][decID]))
                            {
                                m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()][decID] =
                                    m_localVariableValues[GetLocalVariableDictionaryKey()][decID];
                            }
                            m_localVariableValues[GetLocalVariableDictionaryKey()][decID]    = listConst;
                            m_localVariableValuesStr[GetLocalVariableDictionaryKey()][decID] = listConst.Value;
                            m_localVariableScope[GetLocalVariableDictionaryKey()][decID]     = scopeCurrent;
                        }
                    }
                    else if (assignmentChild is Constant)
                    {
                        Constant identEx = (Constant)assignmentChild;
                        if (isDeclaration)
                        {
                            if (m_localVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(decID) &&
                                !m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()].ContainsKey(decID) &&
                                scopesParent.Contains(m_localVariableScope[GetLocalVariableDictionaryKey()][decID]))
                            {
                                m_duplicatedLocalVariableValues[GetLocalVariableDictionaryKey()][decID] =
                                    m_localVariableValues[GetLocalVariableDictionaryKey()][decID];
                            }
                            m_localVariableValues[GetLocalVariableDictionaryKey()][decID]    = identEx;
                            m_localVariableValuesStr[GetLocalVariableDictionaryKey()][decID] = identEx.Value;
                            m_localVariableScope[GetLocalVariableDictionaryKey()][decID]     = scopeCurrent;
                        }
                    }
                }
            }

            /*if(s is Statement)
             * {
             *  if(s.kids.Count == 1 && s.kids[0] is Assignment)
             *  {
             *      Assignment assignment = (Assignment)s.kids[0];
             *      object[] p = new object[assignment.kids.Count];
             *      int i = 0;
             *      int toRemove = -1;
             *      foreach(SYMBOL assignmentChild in assignment.kids)
             *      {
             *          p[i] = assignmentChild;
             *          if(assignmentChild is Declaration)
             *          {
             *              Declaration d = (Declaration)assignmentChild;
             *              if(m_allVariableValues.Contains(d.Id))
             *                  toRemove = i;
             *              else
             *                  m_allVariableValues.Add(d.Id);
             *          }
             *          i++;
             *      }
             *      if(toRemove != -1)
             *      {
             *          List<object> ps = new List<object>();
             *          foreach(object obj in p)
             *              ps.Add(obj);
             *          ps[toRemove] = new IDENT(null)
             *          {
             *              kids = new ObjectList(),
             *              pos = ((SYMBOL)ps[toRemove]).pos,
             *              m_dollar = ((SYMBOL)ps[toRemove]).m_dollar,
             *              yylval = ((SYMBOL)ps[toRemove]).yylval,
             *              yylx = ((SYMBOL)ps[toRemove]).yylx,
             *              yyps = ((SYMBOL)ps[toRemove]).yyps,
             *              yytext = ps[toRemove] is Declaration ?
             *              ((Declaration)ps[toRemove]).Id
             *              : ((SYMBOL)ps[toRemove]).yyname,
             *          };
             *          ((SYMBOL)s.kids[0]).kids = new ObjectList();
             *          foreach(object obj in ps)
             *              if(obj != null)
             *                  ((SYMBOL)s.kids[0]).kids.Add(obj);
             *      }
             *  }
             * }*/

            for (int i = 0; i < s.kids.Count; i++)
            {
                // It's possible that a child is null, for instance when the
                // assignment part in a for-loop is left out, ie:
                //
                //     for (; i < 10; i++)
                //     {
                //         ...
                //     }
                //
                // We need to check for that here.

                if (null == s.kids[i])
                {
                    continue;
                }
                bool scopeAdded = false;
                // we need to keep track of the scope for dulicate variables
                if ((s is IfStatement) || (s is WhileStatement) || (s is ForLoopStatement) || (s is DoWhileStatement))
                {
                    scopeCurrent = ((SYMBOL)s.kids[i]).pos;
                    scopesParent.Add(scopeCurrent);
                    scopeAdded = true;
                }

                if (!(s is Assignment || s is ArgumentDeclarationList) && s.kids[i] is Declaration)
                {
                    AddImplicitInitialization(s, i);
                }

                TransformNode((SYMBOL)s.kids[i], null, null, scopesParent, scopeCurrent);

                // we need to remove the current scope from the parent since we are no longer in that scope
                if (scopeAdded)
                {
                    scopesParent.Remove(scopeCurrent);
                }
            }
        }
 private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.AddressOfExpressionContext expression)
 {
     return(Visit(module, parent, expression.expression()));
 }
Beispiel #44
0
        private void Visit(IBoundExpression boundExpression, Declaration parent, IBoundExpression withExpression)
        {
            switch (boundExpression)
            {
            case SimpleNameExpression simpleNameExpression:
                break;

            case MemberAccessExpression memberAccessExpression:
                Visit(memberAccessExpression, parent, withExpression);
                break;

            case IndexExpression indexExpression:
                Visit(indexExpression, parent, withExpression);
                break;

            case ParenthesizedExpression parenthesizedExpression:
                Visit(parenthesizedExpression, parent, withExpression);
                break;

            case LiteralExpression literalExpression:
                break;

            case BinaryOpExpression binaryOpExpression:
                Visit(binaryOpExpression, parent, withExpression);
                break;

            case UnaryOpExpression unaryOpExpression:
                Visit(unaryOpExpression, parent, withExpression);
                break;

            case NewExpression newExpression:
                Visit(newExpression, parent, withExpression);
                break;

            case InstanceExpression instanceExpression:
                break;

            case DictionaryAccessExpression dictionaryAccessExpression:
                Visit(dictionaryAccessExpression, parent, withExpression);
                break;

            case TypeOfIsExpression typeOfIsExpression:
                Visit(typeOfIsExpression, parent, withExpression);
                break;

            case ResolutionFailedExpression resolutionFailedExpression:
                Visit(resolutionFailedExpression, parent, withExpression);
                break;

            case BuiltInTypeExpression builtInTypeExpression:
                break;

            case RecursiveDefaultMemberAccessExpression recursiveDefaultMemberAccessExpression:
                break;

            case LetCoercionDefaultMemberAccessExpression letCoercionDefaultMemberAccessExpression:
                Visit(letCoercionDefaultMemberAccessExpression, parent, withExpression);
                break;

            case ProcedureCoercionExpression procedureCoercionExpression:
                Visit(procedureCoercionExpression, parent, withExpression);
                break;

            case OutputListExpression outputListExpression:
                Visit(outputListExpression, parent, withExpression);
                break;

            case ObjectPrintExpression objectPrintExpression:
                Visit(objectPrintExpression, parent, withExpression);
                break;

            case MissingArgumentExpression missingArgumentExpression:
                break;

            default:
                throw new NotSupportedException($"Unexpected bound expression type {boundExpression.GetType()}");
            }
        }
Beispiel #45
0
 private void Visit(UnaryOpExpression expression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(expression.Expr, parent, withExpression);
 }
Beispiel #46
0
 protected override bool IsResultDeclaration(Declaration declaration, DeclarationFinder finder)
 {
     return(declaration?.Context != null &&
            !declaration.References.Any());
 }
Beispiel #47
0
 private void Visit(BinaryOpExpression expression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(expression.Left, parent, withExpression);
     Visit(expression.Right, parent, withExpression);
 }
 public ImplicitVariantReturnTypeInspectionResult(IInspection inspection, string identifierName, QualifiedContext <ParserRuleContext> qualifiedContext, Declaration target)
     : base(inspection, qualifiedContext.ModuleName, qualifiedContext.Context, target)
 {
     _identifierName = identifierName;
     _quickFixes     = new CodeInspectionQuickFix[]
     {
         new SetExplicitVariantReturnTypeQuickFix(Context, QualifiedSelection, InspectionsUI.SetExplicitVariantReturnTypeQuickFix),
         new IgnoreOnceQuickFix(Context, QualifiedSelection, Inspection.AnnotationName),
     };
 }
Beispiel #49
0
 private void Visit(ParenthesizedExpression expression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(expression.Expression, parent, withExpression);
 }
Beispiel #50
0
        private static Declaration GetTestUserTypeMember(Declaration parentDeclatation, string name)
        {
            var qualifiedVariableMemberName = new QualifiedMemberName(StubQualifiedModuleName(), name);

            return(new Declaration(qualifiedVariableMemberName, parentDeclatation, "dummy", "test", "test", false, false, Accessibility.Implicit, DeclarationType.UserDefinedTypeMember, null, null, Selection.Home, true, null));
        }
Beispiel #51
0
 private void Visit(ProcedureCoercionExpression expression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(expression.WrappedExpression, parent, withExpression);
 }
Beispiel #52
0
        private static Declaration GetTestEnum(Declaration parentDeclatation, string name, Accessibility enumAccessibility)
        {
            var qualifiedVariableMemberName = new QualifiedMemberName(StubQualifiedModuleName(), name);

            return(new Declaration(qualifiedVariableMemberName, parentDeclatation, "dummy", "test", "test", false, false, enumAccessibility, DeclarationType.Enumeration, null, null, Selection.Home, true, null));
        }
Beispiel #53
0
 private void Visit(DictionaryAccessExpression expression, Declaration parent, IBoundExpression withExpression)
 {
     Visit(expression.LExpression, parent, withExpression);
 }
Beispiel #54
0
        private static FunctionDeclaration GetTestFunction(Declaration moduleDeclatation, string name, Accessibility functionAccessibility)
        {
            var qualifiedFunctionMemberName = new QualifiedMemberName(StubQualifiedModuleName(), name);

            return(new FunctionDeclaration(qualifiedFunctionMemberName, moduleDeclatation, moduleDeclatation, "test", null, "test", functionAccessibility, null, null, Selection.Home, false, true, null, null));
        }
Beispiel #55
0
 public ObsoleteGlobalInspectionResult(IInspection inspection, QualifiedContext <ParserRuleContext> context, Declaration target)
     : base(inspection, context.ModuleName, context.Context, target)
 {
 }
Beispiel #56
0
        public INode GenerateTree(IParseTree tree, Declaration declaration)
        {
            INode node = default;

            switch (tree)
            {
            case VBAParser.ForNextStmtContext _:
            case VBAParser.ForEachStmtContext _:
            case VBAParser.WhileWendStmtContext _:
            case VBAParser.DoLoopStmtContext _:
                node = new LoopNode(tree);
                break;

            case VBAParser.IfStmtContext _:
            case VBAParser.ElseBlockContext _:
            case VBAParser.ElseIfBlockContext _:
            case VBAParser.SingleLineIfStmtContext _:
            case VBAParser.SingleLineElseClauseContext _:
            case VBAParser.CaseClauseContext _:
            case VBAParser.CaseElseClauseContext _:
                node = new BranchNode(tree);
                break;

            case VBAParser.BlockContext _:
                node = new BlockNode(tree);
                break;
            }

            if (declaration.Context == tree)
            {
                node = new DeclarationNode(tree)
                {
                    Declaration = declaration
                };
            }

            var reference = declaration.References.SingleOrDefault(w => w.Context == tree);

            if (reference != null)
            {
                if (reference.IsAssignment)
                {
                    node = new AssignmentNode(tree)
                    {
                        Reference = reference
                    };
                }
                else
                {
                    node = new ReferenceNode(tree)
                    {
                        Reference = reference
                    };
                }
            }

            if (node == null)
            {
                node = new GenericNode(tree);
            }

            var children = new List <INode>();

            for (var i = 0; i < tree.ChildCount; i++)
            {
                var nextChild = GenerateTree(tree.GetChild(i), declaration);
                nextChild.SortOrder = i;
                nextChild.Parent    = node;

                if (nextChild.Children.Any() || nextChild.GetType() != typeof(GenericNode))
                {
                    children.Add(nextChild);
                }
            }

            node.Children = children.ToImmutableList();

            return(node);
        }
        // Creates small ASTs to represent the standard types.
        // Creates small ASTs to represent "declarations" of standard types,
        // constants, procedures, functions, and operators.
        // Enters these "declarations" in the identification table.

        void EnterStdDeclaration(Terminal terminal, Declaration declaration)
        {
            _idTable.Enter(terminal, declaration);
        }
Beispiel #58
0
        public override Operation process(Decompiler d)
        {
            if (statements.Count == 1)
            {
                Statement stmt = statements[0];
                if (stmt is Assignment)
                {
                    Assignment assign = (Assignment)stmt;
                    if (assign.getArity() == 1)
                    {
                        if (branch is TestNode)
                        {
                            TestNode    node = (TestNode)branch;
                            Declaration decl = r.getDeclaration(node.test, node.line);
                            if (assign.getFirstTarget().isDeclaration(decl))
                            {
                                Expression expr;
                                if (node._invert)
                                {
                                    expr = new BinaryExpression("or", new LocalVariable(decl), assign.getFirstValue(), Expression.PRECEDENCE_OR, Expression.ASSOCIATIVITY_NONE);
                                }
                                else
                                {
                                    expr = new BinaryExpression("and", new LocalVariable(decl), assign.getFirstValue(), Expression.PRECEDENCE_AND, Expression.ASSOCIATIVITY_NONE);
                                }
                                return(new IfThenEndBlockOperation(end - 1, assign, expr));
//JAVA TO VB & C# CONVERTER TODO TASK: Anonymous inner classes are not converted to .NET:

                                /*{
                                 *
                                 *    public Statement process(Registers r, Block block)
                                 *    {
                                 *      return new Assignment(assign.getFirstTarget(), expr);
                                 *    }
                                 *
                                 * }*/
                            }
                        }
                    }
                }
            }
            else if (statements.Count == 0 && stack != null)
            {
                int test = branch.getRegister();
                if (test < 0)
                {
                    for (int reg = 0; reg < r.registers; reg++)
                    {
                        if (r.getUpdated(reg, branch.end - 1) >= branch.begin)
                        {
                            if (test >= 0)
                            {
                                test = -1;
                                break;
                            }
                            test = reg;
                        }
                    }
                }
                if (test >= 0)
                {
                    if (r.getUpdated(test, branch.end - 1) >= branch.begin)
                    {
                        Expression right = r.getValue(test, branch.end);
                        Branch     setb  = d.popSetCondition(stack, stack.peek().end);
                        setb.useExpression(right);
                        int testreg = test;
                        return(new IfThenEndBlockOperation2(end - 1, testreg, branch, setb));
//JAVA TO VB & C# CONVERTER TODO TASK: Anonymous inner classes are not converted to .NET:

                        /*{
                         *
                         *    public Statement process(Registers r, Block block)
                         *    {
                         *      r.setValue(testreg, branch.end - 1, setb.asExpression(r));
                         *      return null;
                         *    }
                         *
                         * }*/
                    }
                }
            }
            return(base.process(d));
        }
Beispiel #59
0
 private bool IsReturnStatement(Declaration declaration, IdentifierReference assignment)
 {
     return(assignment.ParentScoping.Equals(declaration) && assignment.Declaration.Equals(declaration));
 }
 private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.SimpleNameExprContext expression)
 {
     return(new SimpleNameProcedurePointerBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression));
 }