예제 #1
0
            private void MatchAttributes(LNode pattern, LNode candidate)
            {
                LNode  condition;
                bool   isParams, refExistingVar;
                Symbol listVar;
                var    pAttrs = pattern.PAttrs();

                if (pAttrs.Count == 1 && (listVar = DecodeSubstitutionExpr(pAttrs[0], out condition, out isParams, out refExistingVar)) != null && isParams)
                {
                    if (listVar != __ || condition != null)
                    {
                        if (!refExistingVar)
                        {
                            AddVar(listVar, true, errAt: pattern);
                        }
                        Tests.Add(LNode.Call(CodeSymbols.OrBits, LNode.List(LNode.Call(CodeSymbols.Dot, LNode.List(LNode.Call(LNode.List(LNode.InParensTrivia), CodeSymbols.Assign, LNode.List(F.Id(listVar), LNode.Call(CodeSymbols.Dot, LNode.List(candidate, LNode.Id((Symbol)"Attrs"))).SetStyle(NodeStyle.Operator))).SetStyle(NodeStyle.Operator), LNode.Id((Symbol)"IsEmpty"))).SetStyle(NodeStyle.Operator), LNode.Literal(true))).SetStyle(NodeStyle.Operator));
                        if (condition != null)
                        {
                            Tests.Add(condition);
                        }
                    }
                }
                else if (pAttrs.Count != 0)
                {
                    Context.Sink.Error(pAttrs[0], "Currently, Attribute matching is very limited; you can only use `[$(...varName)]`");
                }
            }
예제 #2
0
			private void MatchAttributes(LNode pattern, LNode candidate)
			{
				LNode condition;
				bool isParams, refExistingVar;
				Symbol listVar;
				var pAttrs = pattern.PAttrs();
				if (pAttrs.Count == 1 && (listVar = GetSubstitutionVar(pAttrs[0], out condition, out isParams, out refExistingVar)) != null && isParams) {
					if (listVar != __ || condition != null) {
						if (!refExistingVar)
							AddVar(listVar, true, errAt: pattern);
						Tests.Add(LNode.Call(CodeSymbols.OrBits, LNode.List(LNode.Call(CodeSymbols.Dot, LNode.List(LNode.Call(LNode.List(LNode.InParensTrivia), CodeSymbols.Assign, LNode.List(F.Id(listVar), LNode.Call(CodeSymbols.Dot, LNode.List(candidate, LNode.Id((Symbol) "Attrs"))))).SetStyle(NodeStyle.Operator), LNode.Id((Symbol) "IsEmpty"))), LNode.Literal(true))).SetStyle(NodeStyle.Operator));
						if (condition != null)
							Tests.Add(condition);
					}
				} else if (pAttrs.Count != 0)
					Context.Sink.Write(Severity.Error, pAttrs[0], "Currently, Attribute matching is very limited; you can only use `[$(...varName)]`");
			}