/
EvilBeaver
/
OneScript
Обзор
Документация
Войти
/
EvilBeaver
/
OneScript
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
v2.0.0
src/OneScript.Native/Compiler/BuiltInFunctionsCache.cs
36 строк
1 KB
EvilBeaver
Новый документер для нового сайта
30 апр 2025, 00:08
30 апр 2025, 00:08
d0d65e0
Код
Авторство
О чём код?
/*---------------------------------------------------------- This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. ----------------------------------------------------------*/ using System.Reflection; using OneScript.Contexts; using OneScript.Language; using OneScript.Native.Runtime; namespace OneScript.Native.Compiler { public class BuiltInFunctionsCache { private readonly IdentifiersTrie<MethodInfo> _cache = new IdentifiersTrie<MethodInfo>(); public BuiltInFunctionsCache() { var publicMethods = typeof(BuiltInFunctions).GetMethods(); foreach (var methodInfo in publicMethods) { var markup = methodInfo.GetCustomAttribute<ContextMethodAttribute>(); if (markup == null) continue; _cache.Add(markup.Name, methodInfo); if(markup.Alias != null) _cache.Add(markup.Alias, methodInfo); } } public MethodInfo GetMethod(string name) => _cache[name]; } }