MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / loadValType

Method loadValType

lib/loader/ast/type.cpp:123–158  ·  view source on GitHub ↗

Load binary and decode ValType. See "include/loader/loader.h".

Source from the content-addressed store, hash-verified

121
122// Load binary and decode ValType. See "include/loader/loader.h".
123Expect<ValType> Loader::loadValType(ASTNodeAttr From, bool IsStorageType) {
124 // Peek the valtype code.
125 auto B = FMgr.peekByte();
126 if (unlikely(!B)) {
127 return logLoadError(B.error(), FMgr.getLastOffset(), From);
128 }
129
130 // Check the first byte for value type cases.
131 TypeCode Code = static_cast<TypeCode>(*B);
132 switch (Code) {
133 case TypeCode::V128:
134 if (!Conf.hasProposal(Proposal::SIMD)) {
135 return logNeedProposal(ErrCode::Value::MalformedValType, Proposal::SIMD,
136 FMgr.getLastOffset(), From);
137 }
138 [[fallthrough]];
139 case TypeCode::I32:
140 case TypeCode::I64:
141 case TypeCode::F32:
142 case TypeCode::F64:
143 FMgr.readByte();
144 return ValType(Code);
145 case TypeCode::I8:
146 case TypeCode::I16:
147 // Packed types are for GC proposal. The proposal checking should be handled
148 // in the parent scope.
149 if (!IsStorageType) {
150 return logLoadError(ErrCode::Value::MalformedValType, FMgr.getOffset(),
151 From);
152 }
153 FMgr.readByte();
154 return ValType(Code);
155 default:
156 return loadRefType(From);
157 }
158}
159
160Expect<ValMut> Loader::loadMutability(ASTNodeAttr From) {
161 // Read the mutability byte.

Callers

nothing calls this directly

Calls 7

unlikelyFunction · 0.85
ValTypeClass · 0.85
peekByteMethod · 0.80
getLastOffsetMethod · 0.80
hasProposalMethod · 0.80
readByteMethod · 0.80
getOffsetMethod · 0.45

Tested by

no test coverage detected