Ejemplo n.º 1
0
        private static void GetFilteredParametersAndSuffixedMatcherName(
            LGSPRulePattern rulePattern, PatternGraph patternGraph, int index,
            out String[] paramTypesArray, out String[] paramNamesArray, out String suffixedMatcherName)
        {
            List <String> paramTypes   = new List <String>();
            List <String> paramNames   = new List <String>();
            List <String> removedNames = new List <String>();

            for (int i = 0; i < rulePattern.Inputs.Length; ++i)
            {
                String inputName = rulePattern.InputNames[i];
                if (patternGraph.availabilityOfMaybeNullElements[index].ContainsKey(inputName) &&
                    !patternGraph.availabilityOfMaybeNullElements[index][inputName])
                {
                    removedNames.Add(rulePattern.InputNames[i]);
                }
                else
                {
                    paramTypes.Add(TypesHelper.TypeName(rulePattern.Inputs[i]));
                    paramNames.Add(rulePattern.InputNames[i]);
                }
            }
            paramTypesArray = new String[paramTypes.Count];
            paramNamesArray = new String[paramNames.Count];
            for (int i = 0; i < paramTypes.Count; ++i)
            {
                paramTypesArray[i] = paramTypes[i];
                paramNamesArray[i] = paramNames[i];
            }
            suffixedMatcherName = "myMatch";
            foreach (String removedName in removedNames)
            {
                suffixedMatcherName += "_MissingPreset_" + removedName;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inserts declarations for variables extracted from parameters
        /// </summary>
        private static SearchProgramOperation insertVariableDeclarations(SearchProgramOperation insertionPoint, PatternGraph patternGraph)
        {
            foreach (PatternVariable var in patternGraph.variablesPlusInlined)
            {
                if (!var.defToBeYieldedTo) // def variables are handled with the schedule, must come after the presets
                {
                    // inlined variables are handled later, cause they may depend on elements matched
                    if (var.originalVariable == null || !patternGraph.WasInlinedHere(var.originalSubpatternEmbedding))
                    {
                        insertionPoint = insertionPoint.Append(
                            new ExtractVariable(TypesHelper.TypeName(var.type), var.Name)
                            );
                    }
                }
            }

            return(insertionPoint);
        }