示例#1
0
        public static DefinitionToken FromNumber(double value)
        {
            if (CachedNumbers.TryGetValue(value, out var existing))
            {
                return(existing);
            }
            var newNumber = new DefinitionToken(Number, value);

            CachedNumbers.Add(value, newNumber);
            return(newNumber);
        }
示例#2
0
        public static DefinitionToken FromText(string name)
        {
            if (CachedTexts.TryGetValue(name, out var existing))
            {
                return(existing);
            }
            var newText = new DefinitionToken(Text, name);

            CachedTexts.Add(name, newText);
            return(newText);
        }
示例#3
0
        public static DefinitionToken FromIdentifier(string name)
        {
            if (CachedIdentifiers.TryGetValue(name, out var existing))
            {
                return(existing);
            }
            var newIdentifier = new DefinitionToken(IsPublicIdentifier(name)
                                ? nameof(Public)
                                : nameof(Private), name);

            CachedIdentifiers.Add(name, newIdentifier);
            return(newIdentifier);
        }