/
smwwiki
/
OneScript_fork
Обзор
Документация
Войти
/
smwwiki
/
OneScript_fork
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/ScriptEngine/Machine/Contexts/PropertyNameIndexAccessor.cs
63 строки
2 KB
EvilBeaver
Выделена отдельная папка для инфраструктуры исключений
24 июл 2023, 22:46
24 июл 2023, 22:46
d1c2e94
Код
Авторство
О чём код?
/*---------------------------------------------------------- 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 OneScript.Exceptions; using OneScript.Types; namespace ScriptEngine.Machine.Contexts { public abstract class PropertyNameIndexAccessor : ContextIValueImpl { protected PropertyNameIndexAccessor() { } protected PropertyNameIndexAccessor(TypeDescriptor type):base(type) { } public override bool IsIndexed => true; public override bool IsPropReadable(int propNum) { return false; } public override bool IsPropWritable(int propNum) { return false; } public override IValue GetIndexedValue(IValue index) { if (index.SystemType != BasicTypes.String) { throw RuntimeException.InvalidArgumentType(); } var n = GetPropertyNumber(index.AsString()); if (IsPropReadable(n)) return GetPropValue(n); else throw PropertyAccessException.PropIsNotReadableException(index.AsString()); } public override void SetIndexedValue(IValue index, IValue val) { if (index.SystemType != BasicTypes.String) { throw RuntimeException.InvalidArgumentType(); } var n = GetPropertyNumber(index.AsString()); if (IsPropWritable(n)) SetPropValue(n, val); else throw PropertyAccessException.PropIsNotWritableException(index.AsString()); } } }