VmValue.forVariable constructor
VmValue.forVariable({})
创建变量值
Implementation
factory VmValue.forVariable({
String identifier = '___anonymousVmVariable___',
String? initType,
dynamic initValue,
}) {
final realLogic = VmObject.readLogic(initValue, type: initType);
if (realLogic is VmValue) {
late VmMetaType metaType;
if (VmClass.smartTypeNames.contains(initType)) {
metaType = VmMetaType.externalSmart;
} else {
metaType = VmMetaType.internalAlias;
}
return VmValue._(
identifier: identifier,
metaType: metaType,
metaData: const VmMetaData(),
valueType: realLogic._valueType,
valueData: realLogic,
);
} else {
final realClass = VmObject.readClass(initValue, type: initType);
final realValue = VmObject.readValue(initValue, type: initType);
late VmMetaType metaType;
if (VmClass.smartTypeNames.contains(realClass.identifier)) {
metaType = VmMetaType.externalSmart;
} else if (realClass.isExternal) {
metaType = VmMetaType.externalValue;
} else if (realValue == null) {
metaType = VmMetaType.internalAlias;
} else {
metaType = VmMetaType.internalValue;
}
return VmValue._(
identifier: identifier,
metaType: metaType,
metaData: const VmMetaData(),
valueType: realClass,
valueData: realValue,
);
}
}