mirror of
https://github.com/fluencelabs/marine-rs-sdk-test
synced 2024-12-04 15:20:18 +00:00
reexport to_raw_args
This commit is contained in:
parent
cc2b8249fc
commit
d33872aa5e
@ -43,3 +43,4 @@ pub use parsed_type::ParsedType;
|
||||
pub use token_stream_generator::GENERATED_FUNC_PREFIX;
|
||||
pub use token_stream_generator::GENERATED_SECTION_PREFIX;
|
||||
pub use token_stream_generator::GENERATED_GLOBAL_PREFIX;
|
||||
pub use wasm_type::WasmType;
|
||||
|
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use super::ParseMacroInput;
|
||||
use crate::{fce_ast_types, AstRecordField};
|
||||
use crate::fce_ast_types::FCEAst;
|
||||
|
@ -21,6 +21,8 @@ mod foreign_mod_arg;
|
||||
mod foreign_mod_epilog;
|
||||
mod foreign_mod_prolog;
|
||||
|
||||
use crate::wasm_type::WasmType;
|
||||
|
||||
pub(crate) use fn_arg::*;
|
||||
pub(crate) use fn_epilog::*;
|
||||
pub(crate) use fn_prolog::*;
|
||||
@ -208,4 +210,22 @@ impl ParsedType {
|
||||
ParsedType::Utf8String | ParsedType::ByteVector | ParsedType::Record(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_raw_types(&self) -> Vec<WasmType> {
|
||||
match self {
|
||||
ParsedType::Boolean
|
||||
| ParsedType::I8
|
||||
| ParsedType::I16
|
||||
| ParsedType::I32
|
||||
| ParsedType::U8
|
||||
| ParsedType::U16
|
||||
| ParsedType::U32 => vec![WasmType::I32],
|
||||
ParsedType::I64 | ParsedType::U64 => vec![WasmType::I64],
|
||||
ParsedType::F32 => vec![WasmType::F32],
|
||||
ParsedType::F64 => vec![WasmType::F64],
|
||||
ParsedType::Utf8String | ParsedType::ByteVector | ParsedType::Record(_) => {
|
||||
vec![WasmType::I32, WasmType::I32]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2020 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use super::ParsedType;
|
||||
use crate::wasm_type::WasmType;
|
||||
|
||||
@ -8,21 +24,6 @@ pub(crate) trait FnArgGlueCodeGenerator {
|
||||
|
||||
impl FnArgGlueCodeGenerator for ParsedType {
|
||||
fn generate_arguments(&self) -> Vec<WasmType> {
|
||||
// TODO: investigate possible issues in conversion between signed and unsigned types
|
||||
match self {
|
||||
ParsedType::Boolean
|
||||
| ParsedType::I8
|
||||
| ParsedType::I16
|
||||
| ParsedType::I32
|
||||
| ParsedType::U8
|
||||
| ParsedType::U16
|
||||
| ParsedType::U32 => vec![WasmType::I32],
|
||||
ParsedType::I64 | ParsedType::U64 => vec![WasmType::I64],
|
||||
ParsedType::F32 => vec![WasmType::F32],
|
||||
ParsedType::F64 => vec![WasmType::F64],
|
||||
ParsedType::Utf8String | ParsedType::ByteVector | ParsedType::Record(_) => {
|
||||
vec![WasmType::I32, WasmType::I32]
|
||||
}
|
||||
}
|
||||
self.to_raw_types()
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
/// Raw Wasm types according to the spec except i128.
|
||||
pub(crate) enum WasmType {
|
||||
pub enum WasmType {
|
||||
I32,
|
||||
I64,
|
||||
F32,
|
||||
|
Loading…
Reference in New Issue
Block a user