示例#1
0
        public override void EnterPropertyBinding(PropertyBinding ctx)
        {
            // find, from SymTab of the type of the current pattern match, the property that the binding relates to
            // parent node should be the DestructuringParamDecl, that will link to the type defining the properties
            var enclosingScope = ctx.NearestScope();

            if (ctx.ParentNode is DestructuringParamDecl dpd)
            {
                var baseTypeForPatternMatch = PatternMatcherTid.Lookup() as UserDefinedType;
                if (baseTypeForPatternMatch.Definition.TryResolve(ctx.BoundPropertyName, out var boundPropSte))
                {
                    ctx.BoundProperty = boundPropSte.Context as PropertyDefinition;
                    // now we know what the binding relates to, we can create an ste in the scope, to record the relationship
                    enclosingScope.Declare(ctx.BoundVariableName, SymbolKind.PatternBinding, ctx);
                }
            }
        }