Define a "table" concept.
"Table" is to WebAssembly tables as "Heap" is to WebAssembly linear memories.
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
//! to parser clients.
|
||||
|
||||
use cranelift_codegen::ir::entities::AnyEntity;
|
||||
use cranelift_codegen::ir::{Ebb, FuncRef, GlobalValue, Heap, JumpTable, SigRef, StackSlot, Value};
|
||||
use cranelift_codegen::ir::{
|
||||
Ebb, FuncRef, GlobalValue, Heap, JumpTable, SigRef, StackSlot, Table, Value,
|
||||
};
|
||||
use error::{Location, ParseResult};
|
||||
use lexer::split_entity_name;
|
||||
use std::collections::HashMap;
|
||||
@@ -46,6 +48,11 @@ impl SourceMap {
|
||||
self.locations.contains_key(&heap.into())
|
||||
}
|
||||
|
||||
/// Look up a table entity.
|
||||
pub fn contains_table(&self, table: Table) -> bool {
|
||||
self.locations.contains_key(&table.into())
|
||||
}
|
||||
|
||||
/// Look up a signature entity.
|
||||
pub fn contains_sig(&self, sig: SigRef) -> bool {
|
||||
self.locations.contains_key(&sig.into())
|
||||
@@ -100,6 +107,13 @@ impl SourceMap {
|
||||
Some(heap.into())
|
||||
}
|
||||
}),
|
||||
"table" => Table::with_number(num).and_then(|table| {
|
||||
if !self.contains_table(table) {
|
||||
None
|
||||
} else {
|
||||
Some(table.into())
|
||||
}
|
||||
}),
|
||||
"sig" => SigRef::with_number(num).and_then(|sig| {
|
||||
if !self.contains_sig(sig) {
|
||||
None
|
||||
@@ -164,6 +178,11 @@ impl SourceMap {
|
||||
self.def_entity(entity.into(), loc)
|
||||
}
|
||||
|
||||
/// Define the table `entity`.
|
||||
pub fn def_table(&mut self, entity: Table, loc: Location) -> ParseResult<()> {
|
||||
self.def_entity(entity.into(), loc)
|
||||
}
|
||||
|
||||
/// Define the signature `entity`.
|
||||
pub fn def_sig(&mut self, entity: SigRef, loc: Location) -> ParseResult<()> {
|
||||
self.def_entity(entity.into(), loc)
|
||||
|
||||
Reference in New Issue
Block a user