setValue method
设置对象的原生数据值 或 逻辑处理值
Implementation
@override
dynamic setValue(value) {
switch (metaType) {
case VmMetaType.externalValue:
return _valueData = VmObject.readValue(value, type: _valueType.identifier); //保存原生值
case VmMetaType.externalSmart:
//与VmValue.forVariable的处理流程是一致的
final realLogic = VmObject.readLogic(value);
if (realLogic is VmValue) {
_valueType = realLogic._valueType;
return _valueData = realLogic;
} else {
final realClass = VmObject.readClass(value);
final realValue = VmObject.readValue(value);
_valueType = realClass;
return _valueData = realValue;
}
case VmMetaType.externalSuper:
final targeLayzer = _valueData() as VmLazyer;
return targeLayzer.setValue(VmObject.readValue(value)); //保存超类值
case VmMetaType.internalValue:
return _valueData = VmObject.readValue(value, type: _valueType.identifier); //保存VmSuper值
// throw ('Unsuppport setValue operator for internalValue: $identifier'); //非方法没有影响,允许修改
case VmMetaType.internalApply:
if (metaData.isSetter) return runFunction([value], null);
throw ('Unsuppport setValue operator for internalApply: $identifier'); //必涉及到作用域,禁止修改
case VmMetaType.internalAlias:
return _valueData = VmObject.readLogic(value, type: _valueType.identifier); //保存逻辑值
}
}