コード例 #1
0
        public override ResultSentence <string> GetPL1UniverseIdentifier(IWorldPL1Structure pL1WorldStructure, Dictionary <string, string> dictVariables)
        {
            PL1Structure       pl1Structure = pL1WorldStructure.GetPl1Structure();
            ConstDictionary    constDict    = pl1Structure.GetConsts();
            FunctionDictionary funcDict     = pl1Structure.GetFunctions();
            ResultSentence <List <string> > universeIdentifier = GetUniverseIdentifier(Arguments, pL1WorldStructure, dictVariables);
            ListDictionary listDict = funcDict.TryGetValue(Name);

            if (pL1WorldStructure is IWorldSignature worldSignature)
            {
                Signature signature = worldSignature.GetSignature();
                if (!signature.Functions.Any(elem => elem.Item1 == Name && elem.Item2 == Arguments.Count))
                {
                    return(ResultSentence <string> .CreateResult(EValidationResult.UnknownSymbol, false, "", "Function " + Name + " not found in signature."));
                }
            }

            if (!universeIdentifier.IsValid)
            {
                return(ResultSentence <string> .CreateResult(universeIdentifier.ValidationResult, false, universeIdentifier.Value.FirstOrDefault(), universeIdentifier.ErrorMessage));
            }

            string result = listDict.TryGetValue(universeIdentifier.Value);

            return(ResultSentence <string> .CreateResult(true, result));
        }
コード例 #2
0
        internal void AddFunctions(string function, List <string> arguments, string resultArgument)
        {
            FunctionDictionary functions                 = _modelDataStructure.Functions;
            List <string>      unviverseIdentifier       = CreateUniverseConsts(arguments.ToArray());
            List <string>      unviverseIdentifierResult = CreateUniverseConsts(resultArgument);

            if (functions.ContainsKey(function))
            {
                AddFunctionKeyToDictionary(functions[function], function, unviverseIdentifier, unviverseIdentifierResult.First());
            }
            else
            {
                functions.Add(function, new ListDictionary());
                AddFunctionKeyToDictionary(functions[function], function, unviverseIdentifier, unviverseIdentifierResult.First());
            }
        }
コード例 #3
0
        public string GetWorldConstant(IWorldPL1Structure pL1WorldStructure, Dictionary <string, string> dictVariables)
        {
            PL1Structure            pl1Structure       = pL1WorldStructure.GetPl1Structure();
            ConstDictionary         constDict          = pl1Structure.GetConsts();
            FunctionDictionary      funcDict           = pl1Structure.GetFunctions();
            Result <List <string> > universeIdentifier = GetUniverseIdentifier(Arguments, pL1WorldStructure, dictVariables);
            ListDictionary          listDict           = funcDict.TryGetValue(Name);

            string result = listDict.TryGetValue(universeIdentifier.Value);

            foreach (KeyValuePair <string, string> valuePair in constDict)
            {
                if (result == valuePair.Value)
                {
                    return(valuePair.Key);
                }
            }

            return("WorldConstant not found");
        }