Add PrimaryEntityData marker trait.

Require this trait on the value type stored in an EntityMap to 'unlock' the
methods intended for primary entity maps that are allowed to create references
with the 'push method.

This prevents accidentally depending on these methods in secondary maps.
This commit is contained in:
Jakob Stoklund Olesen
2016-08-01 14:45:59 -07:00
parent 549a14bf96
commit f5008567c9
3 changed files with 44 additions and 21 deletions

View File

@@ -10,7 +10,7 @@ pub mod dfg;
pub mod layout;
use ir::types::{FunctionName, Signature};
use entity_map::{EntityRef, EntityMap};
use entity_map::{EntityRef, EntityMap, PrimaryEntityData};
use ir::entities::{StackSlot, JumpTable};
use ir::jumptable::JumpTableData;
use ir::dfg::DataFlowGraph;
@@ -39,6 +39,9 @@ pub struct Function {
pub layout: Layout,
}
// Tag JumpTableData as a primary entity so jump_tables above .
impl PrimaryEntityData for JumpTableData {}
impl Function {
/// Create a function with the given name and signature.
pub fn with_name_signature(name: FunctionName, sig: Signature) -> Function {