fromMap static method
Implementation
static IValue fromMap(map) {
final typeCode = map['typeCode'];
final data = map['data'];
switch (typeCode) {
case typeCodeNull:
return optionalNull();
case typeCodeTensor:
return from(Tensor.fromMap(data));
case typeCodeBool:
case typeCodeLong:
case typeCodeDouble:
case typeCodeString:
return from(data);
case typeCodeTuple:
return tupleFrom(data.map(fromMap).toList().cast<IValue>());
case typeCodeBoolList:
case typeCodeLongList:
case typeCodeDoubleList:
return listFrom(data);
case typeCodeTensorList:
return listFrom(data.map(Tensor.fromMap).toList().cast<Tensor>());
case typeCodeList:
return listFrom(data.map(fromMap).toList().cast<IValue>());
case typeCodeDictStringKey:
final Map<String, IValue> valueMap = {};
data.forEach((key, value) {
valueMap[key] = fromMap(value);
});
return dictStringKeyFrom(valueMap);
case typeCodeDictLongKey:
final Map<int, IValue> valueMap = {};
data.forEach((key, value) {
valueMap[key] = fromMap(value);
});
return dictLongKeyFrom(valueMap);
default:
throw ArgumentError("Unsupported type $typeCode");
}
}