Inter Data Types -
diff --git a/docs/final-module/2-cg.html b/docs/final-module/2-cg.html
index b805d16dc..318d686cf 100644
--- a/docs/final-module/2-cg.html
+++ b/docs/final-module/2-cg.html
@@ -568,7 +568,7 @@ extracted from some Inter instruction.
text_stream * OUT = CodeGen::current ( gen );
if ( val1 == LITERAL_IVAL ) {
Generators::compile_literal_number ( gen , val2 , FALSE );
- } else if ( Inter::Types::pair_holds_symbol ( val1 , val2 )) {
+ } else if ( InterValuePairs::holds_symbol ( val1 , val2 )) {
inter_symbol * s = InterSymbolsTable::symbol_from_data_pair ( val1 , val2 , T );
if ( s == NULL ) internal_error ( "bad symbol in Inter pair" );
Generators::compile_literal_symbol ( gen , s );
diff --git a/docs/final-module/2-vc.html b/docs/final-module/2-vc.html
index d68789bd6..514498220 100644
--- a/docs/final-module/2-vc.html
+++ b/docs/final-module/2-vc.html
@@ -315,7 +315,7 @@ that, it will have to make other arrangements.
}
int bracket = TRUE ;
if (( P -> W . instruction [ i ] == LITERAL_IVAL ) ||
- ( Inter::Types::pair_holds_symbol ( P -> W . instruction [ i ], P -> W . instruction [ i +1]))) bracket = FALSE ;
+ ( InterValuePairs::holds_symbol ( P -> W . instruction [ i ], P -> W . instruction [ i +1]))) bracket = FALSE ;
if ( bracket ) WRITE ( "(" );
CodeGen::pair ( gen , P , P -> W . instruction [ i ], P -> W . instruction [ i +1]);
if ( bracket ) WRITE ( ")" );
diff --git a/docs/final-module/2-vc2.html b/docs/final-module/2-vc2.html
index 858b636e8..e5dca8ff5 100644
--- a/docs/final-module/2-vc2.html
+++ b/docs/final-module/2-vc2.html
@@ -208,7 +208,7 @@ a variable here.
void VanillaCode::val_or_ref ( code_generation * gen , inter_tree_node * P , int ref ) {
inter_ti val1 = P -> W . instruction [ VAL1_VAL_IFLD ];
inter_ti val2 = P -> W . instruction [ VAL2_VAL_IFLD ];
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 )) {
+ if ( InterValuePairs::holds_symbol ( val1 , val2 )) {
inter_package * pack = InterPackage::container ( P );
inter_symbol * named_s =
InterSymbolsTable::symbol_from_ID_in_package ( pack , val2 );
diff --git a/docs/final-module/2-vf.html b/docs/final-module/2-vf.html
index 9506d57b7..207bc2c20 100644
--- a/docs/final-module/2-vf.html
+++ b/docs/final-module/2-vf.html
@@ -231,7 +231,7 @@ in some way by the generator. (As indeed the C generator does, mangling this to
( D -> W . instruction [ FORMAT_CONST_IFLD ] == CONSTANT_DIRECT )) {
inter_ti val1 = D -> W . instruction [ DATA_CONST_IFLD ];
inter_ti val2 = D -> W . instruction [ DATA_CONST_IFLD + 1 ];
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 )) {
+ if ( InterValuePairs::holds_symbol ( val1 , val2 )) {
inter_symbol * S = InterSymbolsTable::symbol_from_data_pair (
val1 , val2 , InterPackage::scope_of ( D ));
if ( S ) fn_s = S ;
diff --git a/docs/final-module/2-vi.html b/docs/final-module/2-vi.html
index 2690c3f6a..47e072625 100644
--- a/docs/final-module/2-vi.html
+++ b/docs/final-module/2-vi.html
@@ -569,7 +569,7 @@ The opening byte gives some metadata bits, and then there's a word.
inter_symbol * VanillaIF::get_symbol ( code_generation * gen , inter_tree_node * P ,
inter_ti val1 , inter_ti val2 ) {
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 )) {
+ if ( InterValuePairs::holds_symbol ( val1 , val2 )) {
inter_symbol * S =
InterSymbolsTable::symbol_from_data_pair ( val1 , val2 ,
InterPackage::scope_of ( P ));
diff --git a/docs/final-module/2-vo.html b/docs/final-module/2-vo.html
index 66ef2c02e..2f8fedb04 100644
--- a/docs/final-module/2-vo.html
+++ b/docs/final-module/2-vo.html
@@ -701,7 +701,7 @@ news for, say, the C generator.
inter_symbol * object_kind = RunningPipelines::get_symbol ( gen -> from_step , object_kind_RPSYM );
if ( object_kind == NULL ) return FALSE ;
if ( kind_s == object_kind ) return FALSE ;
- if ( Inter::Kind::data_type ( kind_s ) == unchecked_idt ) return FALSE ;
+ if ( InterTypes::is_untyped ( InterTypes::from_type_name ( kind_s ))) return FALSE ;
if ( Inter::Kind::is_a ( kind_s , object_kind )) return TRUE ;
return FALSE ;
}
diff --git a/docs/final-module/4-i6c.html b/docs/final-module/4-i6c.html
index 34a3df645..c2a1a90a5 100644
--- a/docs/final-module/4-i6c.html
+++ b/docs/final-module/4-i6c.html
@@ -250,7 +250,7 @@ they were any other arrays. Here goes:
for ( int i = DATA_CONST_IFLD ; i <P-> W . extent ; i = i +2) {
WRITE ( " " );
inter_ti val1 = P -> W . instruction [ i ], val2 = P -> W . instruction [ i +1];
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 )) {
+ if ( InterValuePairs::holds_symbol ( val1 , val2 )) {
inter_symbol * A = InterSymbolsTable::symbol_from_data_pair (
val1 , val2 , InterPackage::scope_of ( P ));
if ( A == NULL ) internal_error ( "bad aliased symbol" );
diff --git a/docs/final-module/4-i6c2.html b/docs/final-module/4-i6c2.html
index 0bc80c4d3..06c9309a8 100644
--- a/docs/final-module/4-i6c2.html
+++ b/docs/final-module/4-i6c2.html
@@ -987,7 +987,7 @@ See Vanilla Objects for more on inner n
if ( prop_node -> W . instruction [ ID_IFLD ] == VAL_IST ) {
inter_ti val1 = prop_node -> W . instruction [ VAL1_VAL_IFLD ];
inter_ti val2 = prop_node -> W . instruction [ VAL2_VAL_IFLD ];
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 ))
+ if ( InterValuePairs::holds_symbol ( val1 , val2 ))
prop_symbol =
InterSymbolsTable::symbol_from_ID ( InterPackage::scope_of ( prop_node ), val2 );
}
@@ -1028,7 +1028,7 @@ and the property is stored in a VM-property;
if ( kind_node -> W . instruction [ ID_IFLD ] == VAL_IST ) {
inter_ti val1 = kind_node -> W . instruction [ VAL1_VAL_IFLD ];
inter_ti val2 = kind_node -> W . instruction [ VAL2_VAL_IFLD ];
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 ))
+ if ( InterValuePairs::holds_symbol ( val1 , val2 ))
kind_symbol =
InterSymbolsTable::symbol_from_ID ( InterPackage::scope_of ( kind_node ), val2 );
}
@@ -1039,7 +1039,7 @@ and the property is stored in a VM-property;
if ( prop_node -> W . instruction [ ID_IFLD ] == VAL_IST ) {
inter_ti val1 = prop_node -> W . instruction [ VAL1_VAL_IFLD ];
inter_ti val2 = prop_node -> W . instruction [ VAL2_VAL_IFLD ];
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 ))
+ if ( InterValuePairs::holds_symbol ( val1 , val2 ))
prop_symbol =
InterSymbolsTable::symbol_from_ID ( InterPackage::scope_of ( prop_node ), val2 );
}
diff --git a/docs/final-module/4-i6o.html b/docs/final-module/4-i6o.html
index 17200ac69..c88ca4e88 100644
--- a/docs/final-module/4-i6o.html
+++ b/docs/final-module/4-i6o.html
@@ -577,7 +577,7 @@ we must use the pecualiar I6 syntax here to get the right outcome.
TEMPORARY_TEXT ( val )
CodeGen::select_temporary ( gen , val );
int inline_this = FALSE ;
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 )) {
+ if ( InterValuePairs::holds_symbol ( val1 , val2 )) {
inter_symbol * S = InterSymbolsTable::symbol_from_data_pair_at_node ( val1 , val2 , X );
if (( S ) && ( SymbolAnnotation::get_b ( S , INLINE_ARRAY_IANN ))) {
inter_tree_node * P = InterSymbol::definition ( S );
diff --git a/docs/final-module/5-com.html b/docs/final-module/5-com.html
index 9ff326d1b..5bfa037f0 100644
--- a/docs/final-module/5-com.html
+++ b/docs/final-module/5-com.html
@@ -667,7 +667,7 @@ first entry at all. We'll simply zero it.
inter_symbol * prop_name , inter_ti val1 , inter_ti val2 , inter_tree_node * X ) {
int inline_this = FALSE ;
- if ( Inter::Types::pair_holds_symbol ( val1 , val2 )) {
+ if ( InterValuePairs::holds_symbol ( val1 , val2 )) {
inter_symbol * S = InterSymbolsTable::symbol_from_data_pair_at_node ( val1 , val2 , X );
if (( S ) && ( SymbolAnnotation::get_b ( S , INLINE_ARRAY_IANN )))
inline_this = TRUE ;
diff --git a/docs/pipeline-module/2-ns.html b/docs/pipeline-module/2-ns.html
index 4d8922598..04c0b4c17 100644
--- a/docs/pipeline-module/2-ns.html
+++ b/docs/pipeline-module/2-ns.html
@@ -156,7 +156,7 @@ base data type matches this".
InterBookmark::scope (& in_generic_kinds ), I "K_unchecked" );
Inter::Kind::new (& in_generic_kinds ,
InterSymbolsTable::id_from_symbol ( I , generic_kinds_p , unchecked_kind_symbol ),
- UNCHECKED_IDT , 0 , 0 , NULL ,
+ UNCHECKED_ITCONC , 0 , 0 , NULL ,
( inter_ti ) InterBookmark::baseline (& in_generic_kinds ) + 1 , NULL );
@@ -177,7 +177,7 @@ base data type matches this".
InterBookmark::scope (& in_generic_kinds ), I "K_unchecked_function" );
Inter::Kind::new (& in_generic_kinds ,
InterSymbolsTable::id_from_symbol ( I , generic_kinds_p , unchecked_function_symbol ),
- FUNCTION_IDT , 0 , 2 , operands ,
+ FUNCTION_ITCONC , 0 , 2 , operands ,
( inter_ti ) InterBookmark::baseline (& in_generic_kinds ) + 1 , NULL );
@@ -198,7 +198,7 @@ base data type matches this".
InterBookmark::scope (& in_generic_kinds ), I "K_unchecked_list" );
Inter::Kind::new (& in_generic_kinds ,
InterSymbolsTable::id_from_symbol ( I , generic_kinds_p , unchecked_list_symbol ),
- LIST_IDT , 0 , 1 , operands ,
+ LIST_ITCONC , 0 , 1 , operands ,
( inter_ti ) InterBookmark::baseline (& in_generic_kinds ) + 1 , NULL );
@@ -216,7 +216,7 @@ end up being basically the same thing.)
InterBookmark::scope (& in_generic_kinds ), I "K_int32" );
Inter::Kind::new (& in_generic_kinds ,
InterSymbolsTable::id_from_symbol ( I , generic_kinds_p , integer_kind_symbol ),
- INT32_IDT , 0 , 0 , NULL ,
+ INT32_ITCONC , 0 , 0 , NULL ,
( inter_ti ) InterBookmark::baseline (& in_generic_kinds ) + 1 , NULL );
@@ -229,7 +229,7 @@ end up being basically the same thing.)
InterBookmark::scope (& in_generic_kinds ), I "K_int2" );
Inter::Kind::new (& in_generic_kinds ,
InterSymbolsTable::id_from_symbol ( I , generic_kinds_p , boolean_kind_symbol ),
- INT2_IDT , 0 , 0 , NULL ,
+ INT2_ITCONC , 0 , 0 , NULL ,
( inter_ti ) InterBookmark::baseline (& in_generic_kinds ) + 1 , NULL );
@@ -242,7 +242,7 @@ end up being basically the same thing.)
InterBookmark::scope (& in_generic_kinds ), I "K_string" );
Inter::Kind::new (& in_generic_kinds ,
InterSymbolsTable::id_from_symbol ( I , generic_kinds_p , string_kind_symbol ),
- TEXT_IDT , 0 , 0 , NULL ,
+ TEXT_ITCONC , 0 , 0 , NULL ,
( inter_ti ) InterBookmark::baseline (& in_generic_kinds ) + 1 , NULL );
diff --git a/docs/pipeline-module/3-css.html b/docs/pipeline-module/3-css.html
index 8f520855b..ff8c7c15d 100644
--- a/docs/pipeline-module/3-css.html
+++ b/docs/pipeline-module/3-css.html
@@ -522,7 +522,7 @@ not already there.
inter_ti B = ( inter_ti ) InterBookmark::baseline ( IBM ) + 1 ;
inter_ti v1 = 0 , v2 = 0 ;
Assimilate a value 3.1.3.1.4.1.1 ;
- Produce::guard ( Inter::Variable::new ( IBM , MID , Inter::Types::untyped (), v1 , v2 , B , NULL ));
+ Produce::guard ( Inter::Variable::new ( IBM , MID , InterTypes::untyped (), v1 , v2 , B , NULL ));
This code is used in §3.1.3.1.4 .
inter_ti MID = InterSymbolsTable::id_from_symbol ( I , InterBookmark::package ( IBM ), made_s );
inter_ti B = ( inter_ti ) InterBookmark::baseline ( IBM ) + 1 ;
- Produce::guard ( Inter::Property::new ( IBM , MID , Inter::Types::untyped (), B , NULL ));
+ Produce::guard ( Inter::Property::new ( IBM , MID , InterTypes::untyped (), B , NULL ));
This code is used in §3.1.3.1.4 .
This code is used in §3.1.3.1.4 .
@@ -978,7 +978,7 @@ which contains the actual code.
InterSymbolsTable::create_with_unique_name ( InterPackage::scope ( IP ), value );
InterSymbol::make_local ( loc_name );
inter_ti B = ( inter_ti ) InterBookmark::baseline ( IBM ) + 1 ;
- Produce::guard ( Inter::Local::new ( IBM , loc_name , Inter::Types::untyped (), B , NULL ));
+ Produce::guard ( Inter::Local::new ( IBM , loc_name , InterTypes::untyped (), B , NULL ));
DISCARD_TEXT ( value )
}
@@ -1239,59 +1239,59 @@ from command parser grammar: slightly different syntax applies there.
if ( Str::eq ( S , I "*" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_divider_RPSYM , I "VERB_DIRECTIVE_DIVIDER" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "->" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_result_RPSYM , I "VERB_DIRECTIVE_RESULT" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "reverse" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_reverse_RPSYM , I "VERB_DIRECTIVE_REVERSE" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "/" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_slash_RPSYM , I "VERB_DIRECTIVE_SLASH" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "special" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_special_RPSYM , I "VERB_DIRECTIVE_SPECIAL" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "number" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_number_RPSYM , I "VERB_DIRECTIVE_NUMBER" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "noun" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_noun_RPSYM , I "VERB_DIRECTIVE_NOUN" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "multi" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_multi_RPSYM , I "VERB_DIRECTIVE_MULTI" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "multiinside" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_multiinside_RPSYM , I "VERB_DIRECTIVE_MULTIINSIDE" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "multiheld" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_multiheld_RPSYM , I "VERB_DIRECTIVE_MULTIHELD" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "held" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_held_RPSYM , I "VERB_DIRECTIVE_HELD" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "creature" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_creature_RPSYM , I "VERB_DIRECTIVE_CREATURE" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "topic" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_topic_RPSYM , I "VERB_DIRECTIVE_TOPIC" ), val1 , val2 ); return ;
}
if ( Str::eq ( S , I "multiexcept" )) {
- Inter::Types::symbol_to_pair ( I , pack , RunningPipelines::ensure_symbol ( step ,
+ InterValuePairs::from_symbol ( I , pack , RunningPipelines::ensure_symbol ( step ,
verb_directive_multiexcept_RPSYM , I "VERB_DIRECTIVE_MULTIEXCEPT" ), val1 , val2 ); return ;
}
match_results mr = Regexp::create_mr ();
@@ -1300,7 +1300,7 @@ from command parser grammar: slightly different syntax applies there.
if ( symb ) {
if ( SymbolAnnotation::get_b ( symb , SCOPE_FILTER_IANN ) == FALSE )
SymbolAnnotation::set_b ( symb , SCOPE_FILTER_IANN , TRUE );
- Inter::Types::symbol_to_pair ( I , pack , symb , val1 , val2 ); return ;
+ InterValuePairs::from_symbol ( I , pack , symb , val1 , val2 ); return ;
}
}
if ( Regexp::match (& mr , S , L "noun=(%i+)" )) {
@@ -1308,7 +1308,7 @@ from command parser grammar: slightly different syntax applies there.
if ( symb ) {
if ( SymbolAnnotation::get_b ( symb , NOUN_FILTER_IANN ) == FALSE )
SymbolAnnotation::set_b ( symb , NOUN_FILTER_IANN , TRUE );
- Inter::Types::symbol_to_pair ( I , pack , symb , val1 , val2 ); return ;
+ InterValuePairs::from_symbol ( I , pack , symb , val1 , val2 ); return ;
}
}
@@ -1319,7 +1319,7 @@ from command parser grammar: slightly different syntax applies there.
inter_symbol * symb = Wiring::find_socket ( I , S );
if ( symb ) {
- Inter::Types::symbol_to_pair ( I , pack , symb , val1 , val2 ); return ;
+ InterValuePairs::from_symbol ( I , pack , symb , val1 , val2 ); return ;
}
@@ -1357,7 +1357,7 @@ before they are needed.
CompileSplatsStage::compute_r ( step , IBM , sch -> node_tree );
if ( result_s == NULL )
PipelineErrors::kit_error ( "Inform 6 constant in kit too complex" , S );
- Inter::Types::symbol_to_pair ( I , pack , result_s , val1 , val2 );
+ InterValuePairs::from_symbol ( I , pack , result_s , val1 , val2 );
inter_bookmark IBM = InterBookmark::first_child_of ( F );
inter_ti val1 = 0 , val2 = 0 ;
- Inter::Types::symbol_to_pair ( InterBookmark::tree (& IBM ),
+ InterValuePairs::from_symbol ( InterBookmark::tree (& IBM ),
InterBookmark::package (& IBM ), var , & val1 , & val2 );
- Inter::Val::new (& IBM , Inter::Types::untyped (),
+ Inter::Val::new (& IBM , InterTypes::untyped (),
( int ) F -> W . instruction [ LEVEL_IFLD ] + 1 , val1 , val2 , NULL );
This code is used in §2.1 .
diff --git a/docs/pipeline-module/5-lt.html b/docs/pipeline-module/5-lt.html
index 748f45243..42bb8975a 100644
--- a/docs/pipeline-module/5-lt.html
+++ b/docs/pipeline-module/5-lt.html
@@ -171,7 +171,7 @@ in .
Wiring::wire_to ( ref_s , latest_s );
inter_ti val1 = 0 , val2 = 0 ;
- Inter::Types::symbol_to_pair ( I , InterPackage::container ( P ), ref_s , & val1 , & val2 );
+ InterValuePairs::from_symbol ( I , InterPackage::container ( P ), ref_s , & val1 , & val2 );
P -> W . instruction [ FORMAT_CONST_IFLD ] = CONSTANT_DIRECT ;
P -> W . instruction [ DATA_CONST_IFLD ] = val1 ;
P -> W . instruction [ DATA_CONST_IFLD +1] = val2 ;
diff --git a/docs/pipeline-module/5-su.html b/docs/pipeline-module/5-su.html
index a649169a7..b5367ffe4 100644
--- a/docs/pipeline-module/5-su.html
+++ b/docs/pipeline-module/5-su.html
@@ -209,7 +209,7 @@ does exist, it must have a definition, and we return that.
InterPackage::scope ( pack ), InterSymbol::identifier ( S ));
Wiring::wire_to ( local_S , S );
inter_ti val1 = 0 , val2 = 0 ;
- Inter::Types::symbol_to_pair ( InterPackage::tree ( pack ), pack , local_S , & val1 , & val2 );
+ InterValuePairs::from_symbol ( InterPackage::tree ( pack ), pack , local_S , & val1 , & val2 );
synoptic_array_node -> W . instruction [ synoptic_array_node -> W . extent -2] = ALIAS_IVAL ;
synoptic_array_node -> W . instruction [ synoptic_array_node -> W . extent -1] = val2 ;
}
diff --git a/docs/runtime-module/2-dv.html b/docs/runtime-module/2-dv.html
index 58bc93c0e..dab3474f2 100644
--- a/docs/runtime-module/2-dv.html
+++ b/docs/runtime-module/2-dv.html
@@ -409,7 +409,7 @@ names are not.
inter_ti val1 = 0 , val2 = 0 ;
- if ( Inter::Types::read_int_in_I6_notation ( textual_description , & val1 , & val2 ) == TRUE ) {
+ if ( InterValuePairs::read_int_in_I6_notation ( textual_description , & val1 , & val2 ) == TRUE ) {
* v1 = val1 ; * v2 = val2 ; return ;
}
diff --git a/docs/runtime-module/2-emt.html b/docs/runtime-module/2-emt.html
index 989aae75e..fde7f4ada 100644
--- a/docs/runtime-module/2-emt.html
+++ b/docs/runtime-module/2-emt.html
@@ -163,7 +163,7 @@ what package it belongs to, the "context" referred to below:
void Emit::stvp_inner ( inter_symbol * S , inter_ti * v1 , inter_ti * v2 ,
inter_package * pack ) {
if ( S ) {
- Inter::Types::symbol_to_pair ( InterPackage::tree ( pack ), pack , S , v1 , v2 );
+ InterValuePairs::from_symbol ( InterPackage::tree ( pack ), pack , S , v1 , v2 );
return ;
}
* v1 = LITERAL_IVAL ; * v2 = 0 ;
@@ -195,7 +195,7 @@ again to return to where we were.
packaging_state save = Packaging::enter_home_of ( KU );
unchecked_interk = InterNames::to_symbol ( KU );
Emit::kind_inner ( Emit::symbol_id ( unchecked_interk ), 0 ,
- UNCHECKED_IDT , 0 , NULL );
+ UNCHECKED_ITCONC , 0 , NULL );
Packaging::exit ( Emit::tree (), save );
inter_name * KUF = Hierarchy::find ( K_UNCHECKED_FUNCTION_HL );
@@ -205,7 +205,7 @@ again to return to where we were.
operands [0] = Emit::symbol_id ( unchecked_interk );
operands [1] = Emit::symbol_id ( unchecked_interk );
Emit::kind_inner ( Emit::symbol_id ( unchecked_function_interk ), 0 ,
- FUNCTION_IDT , 2 , operands );
+ FUNCTION_ITCONC , 2 , operands );
Packaging::exit ( Emit::tree (), save );
inter_name * KLF = Hierarchy::find ( K_UNCHECKED_LIST_HL );
@@ -213,25 +213,25 @@ again to return to where we were.
unchecked_list_interk = InterNames::to_symbol ( KLF );
operands [0] = Emit::symbol_id ( unchecked_interk );
Emit::kind_inner ( Emit::symbol_id ( unchecked_list_interk ), 0 ,
- LIST_IDT , 1 , operands );
+ LIST_ITCONC , 1 , operands );
Packaging::exit ( Emit::tree (), save );
inter_name * KTI = Hierarchy::find ( K_INT32_HL );
save = Packaging::enter_home_of ( KTI );
int_interk = InterNames::to_symbol ( KTI );
- Emit::kind_inner ( Emit::symbol_id ( int_interk ), 0 , INT32_IDT , 0 , NULL );
+ Emit::kind_inner ( Emit::symbol_id ( int_interk ), 0 , INT32_ITCONC , 0 , NULL );
Packaging::exit ( Emit::tree (), save );
inter_name * KTB = Hierarchy::find ( K_INT2_HL );
save = Packaging::enter_home_of ( KTB );
boolean_interk = InterNames::to_symbol ( KTB );
- Emit::kind_inner ( Emit::symbol_id ( boolean_interk ), 0 , INT2_IDT , 0 , NULL );
+ Emit::kind_inner ( Emit::symbol_id ( boolean_interk ), 0 , INT2_ITCONC , 0 , NULL );
Packaging::exit ( Emit::tree (), save );
inter_name * KTS = Hierarchy::find ( K_STRING_HL );
save = Packaging::enter_home_of ( KTS );
string_interk = InterNames::to_symbol ( KTS );
- Emit::kind_inner ( Emit::symbol_id ( string_interk ), 0 , TEXT_IDT , 0 , NULL );
+ Emit::kind_inner ( Emit::symbol_id ( string_interk ), 0 , TEXT_ITCONC , 0 , NULL );
Packaging::exit ( Emit::tree (), save );
}
@@ -464,8 +464,8 @@ of a "variable" and define it as a constant:
inter_symbol * Emit::variable ( inter_name * var_iname , kind * K , inter_ti v1 , inter_ti v2 ) {
packaging_state save = Packaging::enter_home_of ( var_iname );
inter_symbol * var_s = InterNames::to_symbol ( var_iname );
- inter_type it = Inter::Types::untyped ();
- if (( K ) && ( K != K_value )) it = Inter::Types::from_symbol ( Produce::kind_to_symbol ( K ));
+ inter_type it = InterTypes::untyped ();
+ if (( K ) && ( K != K_value )) it = InterTypes::from_type_name ( Produce::kind_to_symbol ( K ));
Produce::guard ( Inter::Variable::new ( Emit::at (),
Emit::symbol_id ( var_s ), it , v1 , v2 , Emit::baseline (), NULL ));
Packaging::exit ( Emit::tree (), save );
@@ -478,8 +478,8 @@ of a "variable" and define it as a constant:
void Emit::property ( inter_name * prop_iname , kind * K ) {
packaging_state save = Packaging::enter_home_of ( prop_iname );
inter_symbol * prop_s = InterNames::to_symbol ( prop_iname );
- inter_type it = Inter::Types::untyped ();
- if (( K ) && ( K != K_value )) it = Inter::Types::from_symbol ( Produce::kind_to_symbol ( K ));
+ inter_type it = InterTypes::untyped ();
+ if (( K ) && ( K != K_value )) it = InterTypes::from_type_name ( Produce::kind_to_symbol ( K ));
Produce::guard ( Inter::Property::new ( Emit::at (),
Emit::symbol_id ( prop_s ), it , Emit::baseline (), NULL ));
Packaging::exit ( Emit::tree (), save );
diff --git a/docs/runtime-module/2-kd.html b/docs/runtime-module/2-kd.html
index b93f0f2ad..cc294e914 100644
--- a/docs/runtime-module/2-kd.html
+++ b/docs/runtime-module/2-kd.html
@@ -215,17 +215,17 @@ source text.
void RTKindDeclarations::declare_base_kind ( kind * K ) {
if ( K == NULL ) internal_error ( "tried to emit null kind" );
if ( InterNames::is_defined ( RTKindDeclarations::iname ( K ))) return ;
- inter_ti dt = INT32_IDT ;
- if ( K == K_object ) dt = ENUM_IDT ;
- if ( Kinds::Behaviour::is_an_enumeration ( K )) dt = ENUM_IDT ;
- if ( K == K_truth_state ) dt = INT2_IDT ;
- if ( K == K_text ) dt = TEXT_IDT ;
- if ( K == K_table ) dt = TABLE_IDT ;
+ inter_ti dt = INT32_ITCONC ;
+ if ( K == K_object ) dt = ENUM_ITCONC ;
+ if ( Kinds::Behaviour::is_an_enumeration ( K )) dt = ENUM_ITCONC ;
+ if ( K == K_truth_state ) dt = INT2_ITCONC ;
+ if ( K == K_text ) dt = TEXT_ITCONC ;
+ if ( K == K_table ) dt = TABLE_ITCONC ;
kind * S = Latticework::super ( K );
if (( S ) && ( Kinds::conforms_to ( S , K_object ) == FALSE )) S = NULL ;
if ( S ) {
RTKindDeclarations::declare_base_kind ( S );
- dt = ENUM_IDT ;
+ dt = ENUM_ITCONC ;
}
Emit::kind ( RTKindDeclarations::iname ( K ), S ? RTKindDeclarations::iname ( S ): NULL ,
dt , 0 , NULL );
@@ -265,7 +265,7 @@ source text.
arity = 1 ;
operands [0] = Kinds::unary_construction_material ( K );
- icon = LIST_IDT ;
+ icon = LIST_ITCONC ;
arity = 1 ;
operands [0] = Kinds::unary_construction_material ( K );
- icon = DESCRIPTION_IDT ;
+ icon = DESCRIPTION_ITCONC ;
arity = 1 ;
operands [0] = Kinds::unary_construction_material ( K );
- icon = COLUMN_IDT ;
+ icon = COLUMN_ITCONC ;
arity = 2 ;
Kinds::binary_construction_material ( K , & operands [0], & operands [1]);
- icon = RELATION_IDT ;
+ icon = RELATION_ITCONC ;
- icon = FUNCTION_IDT ;
+ icon = FUNCTION_ITCONC ;
kind * X = NULL , * result = NULL ;
Kinds::binary_construction_material ( K , & X , & result );
while ( Kinds::get_construct ( X ) == CON_TUPLE_ENTRY ) {
@@ -319,7 +319,7 @@ source text.
arity = 2 ;
Kinds::binary_construction_material ( K , & operands [0], & operands [1]);
- icon = RULE_IDT ;
+ icon = RULE_ITCONC ;
diff --git a/inform7/Figures/memory-diagnostics.txt b/inform7/Figures/memory-diagnostics.txt
index 1df022235..537f51706 100644
--- a/inform7/Figures/memory-diagnostics.txt
+++ b/inform7/Figures/memory-diagnostics.txt
@@ -1,18 +1,19 @@
-Total memory consumption was 412507K = 403 MB
+Total memory consumption was 418902K = 409 MB
-65.5% was used for 2097224 objects, in 398983 frames in 338 x 800K = 270400K = 264 MB:
+66.0% was used for 2116838 objects, in 418597 frames in 346 x 800K = 276800K = 270 MB:
- 10.4% linked_list 78564 objects, 43995840 bytes
- 9.8% inter_tree_node_array 58 x 8192 = 475136 objects, 41813824 bytes
- 6.8% text_stream_array 5174 x 100 = 517400 objects, 29139968 bytes
- 4.0% inter_symbol_array 161 x 1024 = 164864 objects, 17151008 bytes
+ 10.2% linked_list 78564 objects, 43995840 bytes
+ 9.7% inter_tree_node_array 58 x 8192 = 475136 objects, 41813824 bytes
+ 6.7% text_stream_array 5174 x 100 = 517400 objects, 29139968 bytes
+ 3.9% inter_symbol_array 161 x 1024 = 164864 objects, 17151008 bytes
2.4% parse_node 129462 objects, 10356960 bytes
1.7% verb_conjugation 160 objects, 7425280 bytes
- 1.3% parse_node_annotation_array 345 x 500 = 172500 objects, 5531040 bytes
- 0.8% pcalc_prop_array 25 x 1000 = 25000 objects, 3400800 bytes
+ 1.2% parse_node_annotation_array 345 x 500 = 172500 objects, 5531040 bytes
+ 0.7% pcalc_prop_array 25 x 1000 = 25000 objects, 3400800 bytes
0.7% inter_name_array 69 x 1000 = 69000 objects, 3314208 bytes
+ 0.7% inter_error_stash 19904 objects, 3025408 bytes
0.6% kind_array 68 x 1000 = 68000 objects, 2722176 bytes
- 0.5% inter_name_generator_array 53 x 1000 = 53000 objects, 2121696 bytes
+ 0.4% inter_name_generator_array 53 x 1000 = 53000 objects, 2121696 bytes
0.4% inter_schema_token 13926 objects, 2005344 bytes
0.4% package_request 21138 objects, 1860144 bytes
0.4% vocabulary_entry_array 161 x 100 = 16100 objects, 1808352 bytes
@@ -20,7 +21,7 @@ Total memory consumption was 412507K = 403 MB
0.3% inter_symbols_table 26578 objects, 1488368 bytes
0.3% dict_entry_array 442 x 100 = 44200 objects, 1428544 bytes
0.3% i6_schema_array 23 x 100 = 2300 objects, 1380736 bytes
- 0.3% inter_package 26578 objects, 1275744 bytes
+ 0.2% inter_package 26578 objects, 1275744 bytes
0.2% map_data 670 objects, 1125600 bytes
0.2% id_body 941 objects, 1076504 bytes
0.2% adjective_meaning 202 objects, 1000304 bytes
@@ -29,12 +30,12 @@ Total memory consumption was 412507K = 403 MB
0.2% ptoken 8382 objects, 871728 bytes
0.2% grammatical_usage 3611 objects, 866640 bytes
0.2% individual_form 2561 objects, 860496 bytes
- 0.2% inter_schema_node 8891 objects, 853536 bytes
+ 0.1% inter_schema_node 8891 objects, 853536 bytes
0.1% inter_annotation_array 6 x 8192 = 49152 objects, 786624 bytes
0.1% unary_predicate_array 16 x 1000 = 16000 objects, 640512 bytes
0.1% scan_directory 112 objects, 462336 bytes
0.1% local_variable_array 47 x 100 = 4700 objects, 452704 bytes
- ---- dictionary 8257 objects, 396336 bytes
+ ---- dictionary 8256 objects, 396288 bytes
---- verb_usage 1128 objects, 388032 bytes
---- rule 469 objects, 367696 bytes
---- verb_form 386 objects, 345856 bytes
@@ -76,7 +77,6 @@ Total memory consumption was 412507K = 403 MB
---- response_message 407 objects, 52096 bytes
---- ap_clause_array 2 x 400 = 800 objects, 51264 bytes
---- text_substitution 436 objects, 41856 bytes
- ---- inter_error_stash 273 objects, 41496 bytes
---- activity_list_array 1 x 1000 objects, 40032 bytes
---- anl_clause_array 1 x 1000 objects, 40032 bytes
---- to_family_data 497 objects, 39760 bytes
@@ -84,8 +84,8 @@ Total memory consumption was 412507K = 403 MB
---- parsing_data 670 objects, 37520 bytes
---- heading 198 objects, 36432 bytes
---- production_list 617 objects, 34552 bytes
- ---- regions_data 670 objects, 32160 bytes
---- counting_data 670 objects, 32160 bytes
+ ---- regions_data 670 objects, 32160 bytes
---- linked_list_item_array 2 x 1000 = 2000 objects, 32064 bytes
---- HTML_tag_array 1 x 1000 objects, 32032 bytes
---- property_permission 96 objects, 31488 bytes
@@ -133,20 +133,20 @@ Total memory consumption was 412507K = 403 MB
---- value_property_data 84 objects, 4704 bytes
---- parsing_pp_data 96 objects, 4608 bytes
---- compatibility_specification 86 objects, 4128 bytes
- ---- activity 35 objects, 3920 bytes
---- command_line_switch 49 objects, 3920 bytes
+ ---- activity 35 objects, 3920 bytes
---- submodule_request 94 objects, 3760 bytes
---- parse_node_annotation_type 114 objects, 3648 bytes
- ---- property_setting_bp_data 84 objects, 3360 bytes
---- method_set 105 objects, 3360 bytes
+ ---- property_setting_bp_data 84 objects, 3360 bytes
---- kind_constructor_comparison_schema_array 1 x 100 objects, 3232 bytes
---- inform_extension 19 objects, 3192 bytes
---- definition 44 objects, 3168 bytes
---- semver_range 29 objects, 3016 bytes
---- either_or_property_data 62 objects, 2976 bytes
---- use_option 29 objects, 2552 bytes
- ---- part_of_inference_data 79 objects, 2528 bytes
---- parentage_inference_data 79 objects, 2528 bytes
+ ---- part_of_inference_data 79 objects, 2528 bytes
---- kind_constructor_instance_array 1 x 100 objects, 2432 bytes
---- kind_constructor_casting_rule_array 1 x 100 objects, 2432 bytes
---- equation_symbol 30 objects, 2400 bytes
@@ -159,8 +159,8 @@ Total memory consumption was 412507K = 403 MB
---- cached_kind_declaration 38 objects, 1520 bytes
---- noun_filter_token 22 objects, 1408 bytes
---- inter_node_array 34 objects, 1360 bytes
- ---- inter_annotation_form 33 objects, 1320 bytes
---- special_meaning_holder 33 objects, 1320 bytes
+ ---- inter_annotation_form 33 objects, 1320 bytes
---- constant_phrase 20 objects, 1280 bytes
---- table_column 16 objects, 1280 bytes
---- invocation_options_array 1 x 100 objects, 1224 bytes
@@ -173,20 +173,19 @@ Total memory consumption was 412507K = 403 MB
---- submodule_identity 31 objects, 992 bytes
---- named_rulebook_outcome 15 objects, 960 bytes
---- pipeline_stage 19 objects, 912 bytes
- ---- inter_data_type 16 objects, 896 bytes
---- control_structure_phrase 12 objects, 864 bytes
---- cached_understanding 21 objects, 840 bytes
---- phrase_option_array 1 x 100 objects, 824 bytes
- ---- internal_test 15 objects, 720 bytes
---- inbuild_search_result 18 objects, 720 bytes
+ ---- internal_test 15 objects, 720 bytes
---- inform_language 6 objects, 672 bytes
---- relation_guard 5 objects, 640 bytes
---- code_generation 1 object, 576 bytes
---- inter_warehouse_room 10 objects, 560 bytes
---- rulebook_outcome 17 objects, 544 bytes
---- small_word_set 11 objects, 528 bytes
- ---- inform_kit 5 objects, 520 bytes
---- implication 13 objects, 520 bytes
+ ---- inform_kit 5 objects, 520 bytes
---- equation 4 objects, 480 bytes
---- i6_memory_setting 14 objects, 448 bytes
---- inference_family 11 objects, 440 bytes
@@ -195,53 +194,53 @@ Total memory consumption was 412507K = 403 MB
---- source_file 5 objects, 360 bytes
---- inbuild_genre 7 objects, 336 bytes
---- module_request 8 objects, 320 bytes
- ---- grammatical_category 8 objects, 320 bytes
- ---- pronoun 8 objects, 320 bytes
---- door_dir_notice 5 objects, 320 bytes
+ ---- pronoun 8 objects, 320 bytes
+ ---- grammatical_category 8 objects, 320 bytes
---- tree_inventory 1 object, 312 bytes
---- up_family 9 objects, 288 bytes
---- build_step 4 objects, 288 bytes
---- compilation_unit 5 objects, 280 bytes
- ---- contents_entry 7 objects, 280 bytes
---- explicit_bp_data 5 objects, 280 bytes
+ ---- contents_entry 7 objects, 280 bytes
---- door_to_notice 5 objects, 280 bytes
---- verb_usage_tier 5 objects, 240 bytes
---- inter_pipeline 1 object, 232 bytes
---- adjective_meaning_family 7 objects, 224 bytes
---- test_scenario 1 object, 216 bytes
---- release_instructions 1 object, 208 bytes
- ---- build_skill 5 objects, 200 bytes
---- code_generator 5 objects, 200 bytes
+ ---- build_skill 5 objects, 200 bytes
---- inform_project 1 object, 192 bytes
---- kit_dependency 4 objects, 192 bytes
---- plural_dictionary_entry 4 objects, 192 bytes
- ---- inference_subject_family 5 objects, 160 bytes
- ---- inter_architecture 4 objects, 160 bytes
- ---- imperative_defn_family 4 objects, 160 bytes
---- attachment_instruction 4 objects, 160 bytes
+ ---- inference_subject_family 5 objects, 160 bytes
+ ---- imperative_defn_family 4 objects, 160 bytes
+ ---- inter_architecture 4 objects, 160 bytes
---- element_activation 4 objects, 128 bytes
---- inbuild_nest 3 objects, 120 bytes
---- local_block_value 2 objects, 112 bytes
---- inform_kit_ittt 2 objects, 96 bytes
- ---- compile_task_data 1 object, 80 bytes
---- article 2 objects, 80 bytes
---- group_together_function 2 objects, 80 bytes
- ---- inter_warehouse 1 object, 56 bytes
+ ---- compile_task_data 1 object, 80 bytes
---- figures_data 1 object, 56 bytes
+ ---- inter_warehouse 1 object, 56 bytes
---- build_methodology 1 object, 56 bytes
---- HTML_file_state 1 object, 48 bytes
---- star_invention 1 object, 48 bytes
- ---- I6_generation_data 1 object, 40 bytes
- ---- loop_over_scope 1 object, 40 bytes
---- kind_template_definition 1 object, 40 bytes
---- by_function_bp_data 1 object, 40 bytes
+ ---- I6_generation_data 1 object, 40 bytes
+ ---- loop_over_scope 1 object, 40 bytes
-34.4% was used for memory not allocated for objects:
+33.9% was used for memory not allocated for objects:
- 20.3% text stream storage 85803220 bytes in 535370 claims
- 1.2% dictionary storage 5402624 bytes in 8257 claims
+ 20.0% text stream storage 85802744 bytes in 535358 claims
+ 1.2% dictionary storage 5398528 bytes in 8256 claims
---- sorting 736 bytes in 3 claims
- 1.7% source text 7200000 bytes in 3 claims
+ 1.6% source text 7200000 bytes in 3 claims
2.5% source text details 10800000 bytes in 2 claims
---- documentation fragments 262144 bytes in 1 claim
---- linguistic stock array 81920 bytes in 2 claims
@@ -250,11 +249,11 @@ Total memory consumption was 412507K = 403 MB
3.9% inter bytecode storage 16768548 bytes in 14 claims
2.9% inter links storage 12448896 bytes in 12 claims
---- inter tree location list storage 191232 bytes in 32 claims
- 0.4% instance-of-kind counting 1695204 bytes in 1 claim
+ 0.3% instance-of-kind counting 1695204 bytes in 1 claim
---- compilation workspace for objects 21856 bytes in 25 claims
---- lists for type-checking invocations 16000 bytes in 1 claim
---- code generation workspace for objects 1336 bytes in 4 claims
---- emitter array storage 161792 bytes in 2062 claims
-18.8% was overhead - 79701160 bytes = 77833K = 76 MB
+19.4% was overhead - 83271792 bytes = 81320K = 79 MB
diff --git a/inform7/Figures/timings-diagnostics.txt b/inform7/Figures/timings-diagnostics.txt
index ef317f3b3..420f4cb24 100644
--- a/inform7/Figures/timings-diagnostics.txt
+++ b/inform7/Figures/timings-diagnostics.txt
@@ -1,11 +1,11 @@
100.0% in inform7 run
- 56.1% in compilation to Inter
- 40.6% in //Sequence::undertake_queued_tasks//
- 3.5% in //MajorNodes::pre_pass//
- 2.5% in //MajorNodes::pass_1//
- 2.0% in //RTPhrasebook::compile_entries//
+ 56.6% in compilation to Inter
+ 40.8% in //Sequence::undertake_queued_tasks//
+ 3.6% in //MajorNodes::pre_pass//
+ 2.6% in //MajorNodes::pass_1//
+ 2.1% in //RTPhrasebook::compile_entries//
1.3% in //ImperativeDefinitions::assess_all//
- 1.1% in //RTKindConstructors::compile//
+ 1.2% in //RTKindConstructors::compile//
0.4% in //ImperativeDefinitions::compile_first_block//
0.4% in //MajorNodes::pass_2//
0.4% in //Sequence::undertake_queued_tasks//
@@ -15,19 +15,20 @@
0.1% in //InferenceSubjects::emit_all//
0.1% in //RTKindConstructors::compile_permissions//
0.1% in //Task::make_built_in_kind_constructors//
- 2.0% not specifically accounted for
- 41.9% in running Inter pipeline
+ 0.1% in //World::stages_II_and_III//
+ 1.7% not specifically accounted for
+ 41.3% in running Inter pipeline
12.7% in step preparation
- 10.4% in inter step 6/14: make-synoptic-module
- 8.3% in inter step 14/14: generate inform6 -> auto.inf
- 3.8% in inter step 5/14: load-binary-kits
- 2.6% in inter step 9/14: make-identifiers-unique
- 0.4% in inter step 12/14: eliminate-redundant-operations
- 0.2% in inter step 4/14: compile-splats
- 0.2% in inter step 7/14: shorten-wiring
+ 10.1% in inter step 6/14: make-synoptic-module
+ 7.8% in inter step 14/14: generate inform6 -> auto.inf
+ 4.1% in inter step 5/14: load-binary-kits
+ 2.7% in inter step 9/14: make-identifiers-unique
+ 0.3% in inter step 12/14: eliminate-redundant-operations
+ 0.3% in inter step 4/14: compile-splats
+ 0.3% in inter step 7/14: shorten-wiring
0.1% in inter step 10/14: reconcile-verbs
0.1% in inter step 11/14: eliminate-redundant-labels
0.1% in inter step 8/14: detect-indirect-calls
- 2.4% not specifically accounted for
+ 2.5% not specifically accounted for
1.6% in supervisor
- 0.3% not specifically accounted for
+ 0.4% not specifically accounted for
diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb
index 49c32167f..f026617c7 100644
Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-16.interb differ
diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb
index 9cc3f9729..5103c1951 100644
Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-16d.interb differ
diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb
index 4655ac941..4122a15ec 100644
Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-32.interb differ
diff --git a/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb b/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb
index 2f8e538ec..0b528bd7f 100644
Binary files a/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb and b/inform7/Internal/Inter/EnglishLanguageKit/arch-32d.interb differ
diff --git a/inform7/Tests/Test Makes/Eg4-C/textual.txt b/inform7/Tests/Test Makes/Eg4-C/textual.txt
index 2e009d007..73f686035 100644
--- a/inform7/Tests/Test Makes/Eg4-C/textual.txt
+++ b/inform7/Tests/Test Makes/Eg4-C/textual.txt
@@ -27993,7 +27993,7 @@ package main _plain
constant (/main/generic/kinds/K_int32) KIT_CONFIGURATION_BITMAP = 0
constant (/main/generic/kinds/K_int32) KIT_CONFIGURATION_LOOKMODE = 2
constant (/main/generic/kinds/K_string) I7_VERSION_NUMBER = "10.1.0"
- constant (/main/generic/kinds/K_string) I7_FULL_VERSION_NUMBER = "10.1.0-alpha.1+6U36"
+ constant (/main/generic/kinds/K_string) I7_FULL_VERSION_NUMBER = "10.1.0-alpha.1+6U37"
constant (/main/generic/kinds/K_string) ^virtual_machine = "C/32d/v1/no-main"
constant (/main/generic/kinds/K_string) ^virtual_machine_icon = "vm_glulx.png"
constant (/main/generic/kinds/K_string) ^language_elements_used = "core, naming, instance counting, glulx external files"
diff --git a/inform7/runtime-module/Chapter 2/Default Values.w b/inform7/runtime-module/Chapter 2/Default Values.w
index 97e253c99..060a85071 100644
--- a/inform7/runtime-module/Chapter 2/Default Values.w
+++ b/inform7/runtime-module/Chapter 2/Default Values.w
@@ -261,7 +261,7 @@ names are not.
@
=
inter_ti val1 = 0, val2 = 0;
- if (Inter::Types::read_int_in_I6_notation(textual_description, &val1, &val2) == TRUE) {
+ if (InterValuePairs::read_int_in_I6_notation(textual_description, &val1, &val2) == TRUE) {
*v1 = val1; *v2 = val2; return;
}
diff --git a/inform7/runtime-module/Chapter 2/Emit.w b/inform7/runtime-module/Chapter 2/Emit.w
index 7367110df..2ebcd21eb 100644
--- a/inform7/runtime-module/Chapter 2/Emit.w
+++ b/inform7/runtime-module/Chapter 2/Emit.w
@@ -89,7 +89,7 @@ void Emit::to_value_pair_in_context(inter_name *context, inter_ti *v1, inter_ti
void Emit::stvp_inner(inter_symbol *S, inter_ti *v1, inter_ti *v2,
inter_package *pack) {
if (S) {
- Inter::Types::symbol_to_pair(InterPackage::tree(pack), pack, S, v1, v2);
+ InterValuePairs::from_symbol(InterPackage::tree(pack), pack, S, v1, v2);
return;
}
*v1 = LITERAL_IVAL; *v2 = 0;
@@ -120,7 +120,7 @@ void Emit::rudimentary_kinds(void) {
packaging_state save = Packaging::enter_home_of(KU);
unchecked_interk = InterNames::to_symbol(KU);
Emit::kind_inner(Emit::symbol_id(unchecked_interk), 0,
- UNCHECKED_IDT, 0, NULL);
+ UNCHECKED_ITCONC, 0, NULL);
Packaging::exit(Emit::tree(), save);
inter_name *KUF = Hierarchy::find(K_UNCHECKED_FUNCTION_HL);
@@ -130,7 +130,7 @@ void Emit::rudimentary_kinds(void) {
operands[0] = Emit::symbol_id(unchecked_interk);
operands[1] = Emit::symbol_id(unchecked_interk);
Emit::kind_inner(Emit::symbol_id(unchecked_function_interk), 0,
- FUNCTION_IDT, 2, operands);
+ FUNCTION_ITCONC, 2, operands);
Packaging::exit(Emit::tree(), save);
inter_name *KLF = Hierarchy::find(K_UNCHECKED_LIST_HL);
@@ -138,25 +138,25 @@ void Emit::rudimentary_kinds(void) {
unchecked_list_interk = InterNames::to_symbol(KLF);
operands[0] = Emit::symbol_id(unchecked_interk);
Emit::kind_inner(Emit::symbol_id(unchecked_list_interk), 0,
- LIST_IDT, 1, operands);
+ LIST_ITCONC, 1, operands);
Packaging::exit(Emit::tree(), save);
inter_name *KTI = Hierarchy::find(K_INT32_HL);
save = Packaging::enter_home_of(KTI);
int_interk = InterNames::to_symbol(KTI);
- Emit::kind_inner(Emit::symbol_id(int_interk), 0, INT32_IDT, 0, NULL);
+ Emit::kind_inner(Emit::symbol_id(int_interk), 0, INT32_ITCONC, 0, NULL);
Packaging::exit(Emit::tree(), save);
inter_name *KTB = Hierarchy::find(K_INT2_HL);
save = Packaging::enter_home_of(KTB);
boolean_interk = InterNames::to_symbol(KTB);
- Emit::kind_inner(Emit::symbol_id(boolean_interk), 0, INT2_IDT, 0, NULL);
+ Emit::kind_inner(Emit::symbol_id(boolean_interk), 0, INT2_ITCONC, 0, NULL);
Packaging::exit(Emit::tree(), save);
inter_name *KTS = Hierarchy::find(K_STRING_HL);
save = Packaging::enter_home_of(KTS);
string_interk = InterNames::to_symbol(KTS);
- Emit::kind_inner(Emit::symbol_id(string_interk), 0, TEXT_IDT, 0, NULL);
+ Emit::kind_inner(Emit::symbol_id(string_interk), 0, TEXT_ITCONC, 0, NULL);
Packaging::exit(Emit::tree(), save);
}
@@ -381,8 +381,8 @@ void Emit::instance(inter_name *inst_iname, kind *K, int v) {
inter_symbol *Emit::variable(inter_name *var_iname, kind *K, inter_ti v1, inter_ti v2) {
packaging_state save = Packaging::enter_home_of(var_iname);
inter_symbol *var_s = InterNames::to_symbol(var_iname);
- inter_type it = Inter::Types::untyped();
- if ((K) && (K != K_value)) it = Inter::Types::from_symbol(Produce::kind_to_symbol(K));
+ inter_type it = InterTypes::untyped();
+ if ((K) && (K != K_value)) it = InterTypes::from_type_name(Produce::kind_to_symbol(K));
Produce::guard(Inter::Variable::new(Emit::at(),
Emit::symbol_id(var_s), it, v1, v2, Emit::baseline(), NULL));
Packaging::exit(Emit::tree(), save);
@@ -395,8 +395,8 @@ inter_symbol *Emit::variable(inter_name *var_iname, kind *K, inter_ti v1, inter_
void Emit::property(inter_name *prop_iname, kind *K) {
packaging_state save = Packaging::enter_home_of(prop_iname);
inter_symbol *prop_s = InterNames::to_symbol(prop_iname);
- inter_type it = Inter::Types::untyped();
- if ((K) && (K != K_value)) it = Inter::Types::from_symbol(Produce::kind_to_symbol(K));
+ inter_type it = InterTypes::untyped();
+ if ((K) && (K != K_value)) it = InterTypes::from_type_name(Produce::kind_to_symbol(K));
Produce::guard(Inter::Property::new(Emit::at(),
Emit::symbol_id(prop_s), it, Emit::baseline(), NULL));
Packaging::exit(Emit::tree(), save);
diff --git a/inform7/runtime-module/Chapter 2/Kind Declarations.w b/inform7/runtime-module/Chapter 2/Kind Declarations.w
index 92fdac8b4..ed8ef1519 100644
--- a/inform7/runtime-module/Chapter 2/Kind Declarations.w
+++ b/inform7/runtime-module/Chapter 2/Kind Declarations.w
@@ -131,17 +131,17 @@ source text.
void RTKindDeclarations::declare_base_kind(kind *K) {
if (K == NULL) internal_error("tried to emit null kind");
if (InterNames::is_defined(RTKindDeclarations::iname(K))) return;
- inter_ti dt = INT32_IDT;
- if (K == K_object) dt = ENUM_IDT;
- if (Kinds::Behaviour::is_an_enumeration(K)) dt = ENUM_IDT;
- if (K == K_truth_state) dt = INT2_IDT;
- if (K == K_text) dt = TEXT_IDT;
- if (K == K_table) dt = TABLE_IDT;
+ inter_ti dt = INT32_ITCONC;
+ if (K == K_object) dt = ENUM_ITCONC;
+ if (Kinds::Behaviour::is_an_enumeration(K)) dt = ENUM_ITCONC;
+ if (K == K_truth_state) dt = INT2_ITCONC;
+ if (K == K_text) dt = TEXT_ITCONC;
+ if (K == K_table) dt = TABLE_ITCONC;
kind *S = Latticework::super(K);
if ((S) && (Kinds::conforms_to(S, K_object) == FALSE)) S = NULL;
if (S) {
RTKindDeclarations::declare_base_kind(S);
- dt = ENUM_IDT;
+ dt = ENUM_ITCONC;
}
Emit::kind(RTKindDeclarations::iname(K), S?RTKindDeclarations::iname(S):NULL,
dt, 0, NULL);
@@ -177,25 +177,25 @@ void RTKindDeclarations::declare_constructed_kind(cached_kind_declaration *dec)
@ =
arity = 1;
operands[0] = Kinds::unary_construction_material(K);
- icon = LIST_IDT;
+ icon = LIST_ITCONC;
@ =
arity = 1;
operands[0] = Kinds::unary_construction_material(K);
- icon = DESCRIPTION_IDT;
+ icon = DESCRIPTION_ITCONC;
@ =
arity = 1;
operands[0] = Kinds::unary_construction_material(K);
- icon = COLUMN_IDT;
+ icon = COLUMN_ITCONC;
@ =
arity = 2;
Kinds::binary_construction_material(K, &operands[0], &operands[1]);
- icon = RELATION_IDT;
+ icon = RELATION_ITCONC;
@ =
- icon = FUNCTION_IDT;
+ icon = FUNCTION_ITCONC;
kind *X = NULL, *result = NULL;
Kinds::binary_construction_material(K, &X, &result);
while (Kinds::get_construct(X) == CON_TUPLE_ENTRY) {
@@ -211,11 +211,11 @@ void RTKindDeclarations::declare_constructed_kind(cached_kind_declaration *dec)
@ =
arity = 2;
Kinds::binary_construction_material(K, &operands[0], &operands[1]);
- icon = RULE_IDT;
+ icon = RULE_ITCONC;
@ =
arity = 1;
kind *X = NULL, *Y = NULL;
Kinds::binary_construction_material(K, &X, &Y);
operands[0] = Kinds::binary_con(CON_phrase, X, Y);
- icon = RULEBOOK_IDT;
+ icon = RULEBOOK_ITCONC;
diff --git a/inter/Tests/Invalid/_Results_Ideal/miscol.txt b/inter/Tests/Invalid/_Results_Ideal/miscol.txt
index c3e9fc4e3..871820ead 100644
--- a/inter/Tests/Invalid/_Results_Ideal/miscol.txt
+++ b/inter/Tests/Invalid/_Results_Ideal/miscol.txt
@@ -2,6 +2,6 @@ inter: inter/Tests/Invalid/miscol.intert, line 6: no such symbol: 'K_number'
>--> kind K_column_of_number column of K_number
inter: inter/Tests/Invalid/miscol.intert, line 7: no such symbol: 'K_colour'
>--> kind K_column_of_colour column of K_colour
-inter: inter/Tests/Invalid/miscol.intert, line 8: not a list: 'K_column_of_number'
-inter: inter/Tests/Invalid/miscol.intert, line 9: not a list: 'K_column_of_colour'
+inter: inter/Tests/Invalid/miscol.intert, line 8: not a list
+inter: inter/Tests/Invalid/miscol.intert, line 9: not a list
inter: inter/Tests/Invalid/miscol.intert, line 4: symbol undefined in package: 'C_complaint'
diff --git a/inter/Tests/Invalid/_Results_Ideal/mistype.txt b/inter/Tests/Invalid/_Results_Ideal/mistype.txt
index 13fdb011f..f2d4853b2 100644
--- a/inter/Tests/Invalid/_Results_Ideal/mistype.txt
+++ b/inter/Tests/Invalid/_Results_Ideal/mistype.txt
@@ -1,2 +1,2 @@
-inter: inter/Tests/Invalid/mistype.intert, line 5: no such data type: 'int32768'
+inter: inter/Tests/Invalid/mistype.intert, line 5: no such symbol: 'int32768'
>--> kind K_number int32768
diff --git a/inter/Tests/Invalid/_Results_Ideal/misvar.txt b/inter/Tests/Invalid/_Results_Ideal/misvar.txt
index 5faec9525..0e4410b03 100644
--- a/inter/Tests/Invalid/_Results_Ideal/misvar.txt
+++ b/inter/Tests/Invalid/_Results_Ideal/misvar.txt
@@ -1,5 +1,3 @@
inter: inter/Tests/Invalid/misvar.intert, line 7: symbol already exists: 'V_apple'
>--> variable V_apple = 2
-inter: inter/Tests/Invalid/misvar.intert, line 8: no such symbol: 'int32'
->--> variable (int32) V_peach = 12
inter: inter/Tests/Invalid/misvar.intert, line 4: symbol undefined in package: 'khglkl'
diff --git a/inter/building-module/Chapter 2/Emitting Inter Schemas.w b/inter/building-module/Chapter 2/Emitting Inter Schemas.w
index e14c8e2e7..b39a8097a 100644
--- a/inter/building-module/Chapter 2/Emitting Inter Schemas.w
+++ b/inter/building-module/Chapter 2/Emitting Inter Schemas.w
@@ -603,7 +603,7 @@ parsing the schema.)
if (t->constant_number >= 0) {
v1 = LITERAL_IVAL; v2 = (inter_ti) t->constant_number;
} else {
- if (Inter::Types::read_int_in_I6_notation(t->material, &v1, &v2) == FALSE) {
+ if (InterValuePairs::read_int_in_I6_notation(t->material, &v1, &v2) == FALSE) {
TEMPORARY_TEXT(msg)
WRITE_TO(msg, "malformed literal number '%S'", t->material);
InterSchemas::throw_error(node, msg);
diff --git a/inter/building-module/Chapter 3/Produce.w b/inter/building-module/Chapter 3/Produce.w
index 790ba9131..04c188e79 100644
--- a/inter/building-module/Chapter 3/Produce.w
+++ b/inter/building-module/Chapter 3/Produce.w
@@ -337,7 +337,7 @@ inter_name *Produce::symbol_constant(inter_tree *I, inter_name *con_iname, kind
inter_symbol *con_s = InterNames::to_symbol(con_iname);
inter_ti v1 = 0, v2 = 0;
inter_package *pack = InterBookmark::package(IBM);
- Inter::Types::symbol_to_pair(InterPackage::tree(pack), pack, val_s, &v1, &v2);
+ InterValuePairs::from_symbol(InterPackage::tree(pack), pack, val_s, &v1, &v2);
Produce::guard(Inter::Constant::new_numerical(IBM,
InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_s),
InterSymbolsTable::id_from_symbol_at_bookmark(IBM, Produce::kind_to_symbol(K)),
@@ -487,7 +487,7 @@ void Produce::val_iname(inter_tree *I, kind *K, inter_name *iname) {
void Produce::val_symbol(inter_tree *I, kind *K, inter_symbol *s) {
inter_ti val1 = 0, val2 = 0;
inter_bookmark *IBM = Packaging::at(I);
- Inter::Types::symbol_to_pair(InterBookmark::tree(IBM),
+ InterValuePairs::from_symbol(InterBookmark::tree(IBM),
InterBookmark::package(IBM), s, &val1, &val2);
Produce::val(I, K, val1, val2);
}
@@ -502,7 +502,7 @@ void Produce::val(inter_tree *I, kind *K, inter_ti val1, inter_ti val2) {
val_kind = Produce::kind_to_symbol(K);
if (val_kind == NULL) internal_error("no kind for val");
}
- Produce::guard(Inter::Val::new(Produce::at(I), Inter::Types::from_symbol(val_kind),
+ Produce::guard(Inter::Val::new(Produce::at(I), InterTypes::from_type_name(val_kind),
Produce::level(I), val1, val2, NULL));
}
@@ -552,14 +552,14 @@ void Produce::ref_iname(inter_tree *I, kind *K, inter_name *iname) {
void Produce::ref_symbol(inter_tree *I, kind *K, inter_symbol *s) {
inter_ti val1 = 0, val2 = 0;
inter_bookmark *IBM = Packaging::at(I);
- Inter::Types::symbol_to_pair(InterBookmark::tree(IBM), InterBookmark::package(IBM),
+ InterValuePairs::from_symbol(InterBookmark::tree(IBM), InterBookmark::package(IBM),
s, &val1, &val2);
inter_symbol *val_kind = NULL;
if ((K) && (K != K_value)) {
val_kind = Produce::kind_to_symbol(K);
if (val_kind == NULL) internal_error("no kind for ref");
}
- Produce::guard(Inter::Ref::new(Produce::at(I), Inter::Types::from_symbol(val_kind),
+ Produce::guard(Inter::Ref::new(Produce::at(I), InterTypes::from_type_name(val_kind),
Produce::level(I), val1, val2, NULL));
}
@@ -650,8 +650,8 @@ inter_symbol *Produce::local(inter_tree *I, kind *K, text_stream *lname,
Produce::guard(Inter::Comment::new(locals_at, Produce::baseline(locals_at) + 1,
NULL, ID));
}
- inter_type it = Inter::Types::untyped();
- if ((K) && (K != K_value)) it = Inter::Types::from_symbol(Produce::kind_to_symbol(K));
+ inter_type it = InterTypes::untyped();
+ if ((K) && (K != K_value)) it = InterTypes::from_type_name(Produce::kind_to_symbol(K));
Produce::guard(Inter::Local::new(locals_at, local_s, it,
Produce::baseline(locals_at) + 1, NULL));
return local_s;
diff --git a/inter/bytecode-module/Chapter 1/Bytecode Module.w b/inter/bytecode-module/Chapter 1/Bytecode Module.w
index 0c84cd510..3ace81a6f 100644
--- a/inter/bytecode-module/Chapter 1/Bytecode Module.w
+++ b/inter/bytecode-module/Chapter 1/Bytecode Module.w
@@ -17,7 +17,6 @@ which use this module:
@e inter_symbols_table_CLASS
@e inter_symbol_CLASS
@e inter_annotation_CLASS
-@e inter_data_type_CLASS
@e inter_construct_CLASS
@e inter_annotation_form_CLASS
@e inter_error_location_CLASS
@@ -32,7 +31,6 @@ DECLARE_CLASS(inter_tree)
DECLARE_CLASS(inter_warehouse)
DECLARE_CLASS(inter_warehouse_room)
DECLARE_CLASS(inter_symbols_table)
-DECLARE_CLASS(inter_data_type)
DECLARE_CLASS(inter_construct)
DECLARE_CLASS(inter_annotation_form)
DECLARE_CLASS(inter_error_location)
@@ -55,7 +53,7 @@ void BytecodeModule::start(void) {
@;
InterConstruct::create_language();
- Inter::Types::create_all();
+ InterTypes::initialise_constructors();
}
void BytecodeModule::end(void) {
}
diff --git a/inter/bytecode-module/Chapter 2/Symbols Tables.w b/inter/bytecode-module/Chapter 2/Symbols Tables.w
index 1be4183ba..ad1dccd2d 100644
--- a/inter/bytecode-module/Chapter 2/Symbols Tables.w
+++ b/inter/bytecode-module/Chapter 2/Symbols Tables.w
@@ -404,6 +404,12 @@ inter_ti InterSymbolsTable::id_from_symbol(inter_tree *I, inter_package *P, inte
if (S == NULL) internal_error("no symbol");
inter_symbols_table *P_table = InterPackage::scope(P);
if (P_table == NULL) P_table = InterTree::global_scope(I);
+ return InterSymbolsTable::id_from_symbol_in_table(P_table, S);
+}
+
+inter_ti InterSymbolsTable::id_from_symbol_in_table(inter_symbols_table *P_table, inter_symbol *S) {
+ if (S == NULL) internal_error("no symbol");
+ if (P_table == NULL) internal_error("no table");
inter_symbols_table *SP_table = S->owning_table;
if (P_table != SP_table) @
else return S->symbol_ID;
@@ -416,8 +422,6 @@ them on a package-by-package basis, so it is an error to call this function if
@ =
LOGIF(INTER_SYMBOLS,
"Seek ID of $3 from $4, which is not its owner $4\n", S, P_table, SP_table);
- if (SP_table == InterTree::global_scope(I))
- internal_error("cannot make a local symbol ID from a global symbol");
@;
@;
diff --git a/inter/bytecode-module/Chapter 2/The Warehouse.w b/inter/bytecode-module/Chapter 2/The Warehouse.w
index ed16783d3..4413090d9 100644
--- a/inter/bytecode-module/Chapter 2/The Warehouse.w
+++ b/inter/bytecode-module/Chapter 2/The Warehouse.w
@@ -4,8 +4,8 @@ To manage the memory storage of inter code.
@h Introduction.
The data structure in this section may bring to mind the title of the Metallica
-song "The Thing That Should Not Be", but it works. It's also better that it used
-to be (which is more than can be said for Metallica).
+song "The Thing That Should Not Be", but it works. It's also better than it used
+to be (which is more than you can say for Metallica).
Each inter tree needs to store data outside of its own //inter_tree_node// structures,
data which falls into two categories:
diff --git a/inter/bytecode-module/Chapter 3/Inter Data Types.w b/inter/bytecode-module/Chapter 3/Inter Data Types.w
index cebf339f5..944d9e23e 100644
--- a/inter/bytecode-module/Chapter 3/Inter Data Types.w
+++ b/inter/bytecode-module/Chapter 3/Inter Data Types.w
@@ -1,167 +1,628 @@
-[Inter::Types::] Inter Data Types.
+[InterTypes::] Inter Data Types.
A primitive notion of data type, below the level of kinds.
-@
+@h Constructors.
+Abstractly, an Inter type is a combination of a "constructor" and 0 or more
+"operand types", the number depending on which constructor is used. If this
+is 0, type is a "base" constructor.
-@d inter_ti unsigned int
-@d signed_inter_ti int
+Constructors are identified textually by keywords, such as |int32|, and also
+by "constructor ID" numbers, such as |INT32_ITCONC|. This one is a base;
+whereas |list|, for example, is not -- |list of int32| is a valid type, with
+1 type operand, but |list| alone is not sufficient to specify a type.
+
+@ The set of valid constructor IDs is fixed and it is here:
+
+@e UNCHECKED_ITCONC from 1
+@e INT32_ITCONC
+@e INT16_ITCONC
+@e INT8_ITCONC
+@e INT2_ITCONC
+@e TEXT_ITCONC
+@e ENUM_ITCONC
+@e LIST_ITCONC
+@e COLUMN_ITCONC
+@e TABLE_ITCONC
+@e FUNCTION_ITCONC
+@e STRUCT_ITCONC
+@e RELATION_ITCONC
+@e DESCRIPTION_ITCONC
+@e RULE_ITCONC
+@e RULEBOOK_ITCONC
+@e EQUATED_ITCONC
+@e VOID_ITCONC
+
+@d MIN_INTER_TYPE_CONSTRUCTOR UNCHECKED_ITCONC
+@d MAX_INTER_TYPE_CONSTRUCTOR VOID_ITCONC
=
-typedef struct inter_data_type {
- inter_ti type_ID;
- struct text_stream *reserved_word;
+int InterTypes::is_valid_constructor_code(inter_ti constructor) {
+ if ((constructor < MIN_INTER_TYPE_CONSTRUCTOR) ||
+ (constructor > MAX_INTER_TYPE_CONSTRUCTOR)) return FALSE;
+ return TRUE;
+}
+
+@ Clearly we need to store some metadata about what these constructor IDs
+mean, and we do that with a simple lookup array large enough to hold all
+valid constructor codes as indexes:
+
+=
+typedef struct inter_type_constructor {
+ inter_ti constructor_ID;
+ struct text_stream *constructor_keyword;
long long int min_value;
long long int max_value;
- int enumerated;
- CLASS_DEFINITION
-} inter_data_type;
+ int is_enumerated;
+ int is_base;
+ int arity;
+} inter_type_constructor;
-inter_data_type *int32_idt = NULL;
-inter_data_type *unchecked_idt = NULL;
+inter_type_constructor inter_type_constructors[MAX_INTER_TYPE_CONSTRUCTOR + 1];
-@ =
-dictionary *idt_lookup = NULL;
+@ That array initially contains undetermined data, of course, so we need to
+initialise it:
-inter_data_type *Inter::Types::create(inter_ti ID, text_stream *name, int A, int B, int en) {
- inter_data_type *IDT = CREATE(inter_data_type);
- IDT->type_ID = ID;
- IDT->reserved_word = Str::duplicate(name);
- IDT->min_value = A;
- IDT->max_value = B;
- IDT->enumerated = en;
+=
+void InterTypes::initialise_constructors(void) {
+ InterTypes::init_con(UNCHECKED_ITCONC, I"unchecked", -2147483648, 2147483647, FALSE, TRUE, 0);
+ InterTypes::init_con(INT32_ITCONC, I"int32", -2147483648, 2147483647, FALSE, TRUE, 0);
+ InterTypes::init_con(INT16_ITCONC, I"int16", -32768, 32767, FALSE, TRUE, 0);
+ InterTypes::init_con(INT8_ITCONC, I"int8", -128, 127, FALSE, TRUE, 0);
+ InterTypes::init_con(INT2_ITCONC, I"int2", 0, 1, FALSE, TRUE, 0);
+ InterTypes::init_con(TEXT_ITCONC, I"text", -2147483648, 2147483647, FALSE, TRUE, 0);
+ InterTypes::init_con(ENUM_ITCONC, I"enum", 0, 2147483647, TRUE, TRUE, 0);
+ InterTypes::init_con(LIST_ITCONC, I"list", -2147483648, 2147483647, FALSE, FALSE, 1);
+ InterTypes::init_con(COLUMN_ITCONC, I"column", -2147483648, 2147483647, FALSE, FALSE, 1);
+ InterTypes::init_con(TABLE_ITCONC, I"table", -2147483648, 2147483647, FALSE, FALSE, 1);
+ InterTypes::init_con(FUNCTION_ITCONC, I"function", -2147483648, 2147483647, FALSE, FALSE, 2);
+ InterTypes::init_con(STRUCT_ITCONC, I"struct", -2147483648, 2147483647, FALSE, FALSE, 0);
+ InterTypes::init_con(RELATION_ITCONC, I"relation", -2147483648, 2147483647, FALSE, FALSE, 2);
+ InterTypes::init_con(DESCRIPTION_ITCONC, I"description", -2147483648, 2147483647, FALSE, FALSE, 1);
+ InterTypes::init_con(RULE_ITCONC, I"rule", -2147483648, 2147483647, FALSE, FALSE, 2);
+ InterTypes::init_con(RULEBOOK_ITCONC, I"rulebook", -2147483648, 2147483647, FALSE, FALSE, 1);
+ InterTypes::init_con(EQUATED_ITCONC, I"", -2147483648, 2147483647, FALSE, FALSE, 1);
+ InterTypes::init_con(VOID_ITCONC, I"void", 1, 0, FALSE, TRUE, 0);
+}
- if (idt_lookup == NULL) idt_lookup = Dictionaries::new(128, FALSE);
- Dictionaries::create(idt_lookup, name);
- Dictionaries::write_value(idt_lookup, name, (void *) IDT);
+@ Where:
+
+=
+inter_type_constructor *InterTypes::init_con(inter_ti ID, text_stream *name,
+ int range_from, int range_to, int en, int base, int arity) {
+ if (InterTypes::is_valid_constructor_code(ID) == FALSE)
+ internal_error("constructor ID out of range");
+
+ inter_type_constructor *IDT = &(inter_type_constructors[ID]);
+ IDT->constructor_ID = ID;
+ IDT->constructor_keyword = Str::duplicate(name);
+ IDT->min_value = range_from;
+ IDT->max_value = range_to;
+ IDT->is_enumerated = en;
+ IDT->is_base = base;
return IDT;
}
-@
-
-@e UNCHECKED_IDT from 0x60000000
-@e INT32_IDT
-@e INT16_IDT
-@e INT8_IDT
-@e INT2_IDT
-@e ENUM_IDT
-@e LIST_IDT
-@e COLUMN_IDT
-@e TABLE_IDT
-@e TEXT_IDT
-@e FUNCTION_IDT
-@e STRUCT_IDT
-@e RELATION_IDT
-@e DESCRIPTION_IDT
-@e RULE_IDT
-@e RULEBOOK_IDT
+@ Assuming that has been done, it is safe to call these lookup functions. Note
+that it's fine for textual lookups to be relatively slow.
=
-void Inter::Types::create_all(void) {
- unchecked_idt = Inter::Types::create(UNCHECKED_IDT, I"unchecked", -2147483648, 2147483647, FALSE);
- int32_idt = Inter::Types::create(INT32_IDT, I"int32", -2147483648, 2147483647, FALSE);
- Inter::Types::create(INT16_IDT, I"int16", -32768, 32767, FALSE);
- Inter::Types::create(INT8_IDT, I"int8", -128, 127, FALSE);
- Inter::Types::create(INT2_IDT, I"int2", 0, 1, FALSE);
- Inter::Types::create(ENUM_IDT, I"enum", 0, 2147483647, TRUE);
- Inter::Types::create(LIST_IDT, I"list", -2147483648, 2147483647, FALSE);
- Inter::Types::create(COLUMN_IDT, I"column", -2147483648, 2147483647, FALSE);
- Inter::Types::create(TABLE_IDT, I"table", -2147483648, 2147483647, FALSE);
- Inter::Types::create(TEXT_IDT, I"text", -2147483648, 2147483647, FALSE);
- Inter::Types::create(FUNCTION_IDT, I"function", -2147483648, 2147483647, FALSE);
- Inter::Types::create(STRUCT_IDT, I"struct", -2147483648, 2147483647, FALSE);
- Inter::Types::create(RELATION_IDT, I"relation", -2147483648, 2147483647, FALSE);
- Inter::Types::create(DESCRIPTION_IDT, I"description", -2147483648, 2147483647, FALSE);
- Inter::Types::create(RULE_IDT, I"rule", -2147483648, 2147483647, FALSE);
- Inter::Types::create(RULEBOOK_IDT, I"rulebook", -2147483648, 2147483647, FALSE);
+inter_type_constructor *InterTypes::constructor_from_ID(inter_ti ID) {
+ if (InterTypes::is_valid_constructor_code(ID)) return &(inter_type_constructors[ID]);
+ return NULL;
}
-int Inter::Types::is_base(inter_data_type *idt) {
- switch (idt->type_ID) {
- case LIST_IDT:
- case COLUMN_IDT:
- case TABLE_IDT:
- case FUNCTION_IDT:
- case STRUCT_IDT:
- case RELATION_IDT:
- case DESCRIPTION_IDT:
- return FALSE;
+inter_type_constructor *InterTypes::constructor_from_name(text_stream *name) {
+ for (inter_ti ID = MIN_INTER_TYPE_CONSTRUCTOR; ID <= MAX_INTER_TYPE_CONSTRUCTOR; ID++) {
+ inter_type_constructor *itc = &(inter_type_constructors[ID]);
+ if (Str::eq(itc->constructor_keyword, name))
+ return itc;
}
- return TRUE;
+ return NULL;
}
-int Inter::Types::is_enumerated(inter_data_type *idt) {
- if ((idt) && (idt->enumerated)) return TRUE;
+@h Simple types and type names.
+We need to represent types very economically in terms of memory. In principle,
+the set of abstract types is infinite (consider for example |int32|, |list of int32|,
+|list of list of int32|, ...), so there is no limit to the memory which might
+be required.
+
+We use the following representations, starting with the most concise:
+
+(1) A "TID", or type ID, is a single |inter_ti| value, often stored as a field
+in the bytecode for some instruction. For example, a |VARIABLE_IST| instruction
+includes a field holding the TID of its variable's type. This can only represent
+simple descriptions (see below), and you need to know what package a TID
+came from (i.e., what symbols table was in use there) to unravel it.
+
+(2) An //inter_type// is a lightweight structure intended for passing around
+the functions in this section. It can also only represent simple descriptions -- in
+fact, TIDs and |inter_type|s can faithfully be converted back and forth -- but
+has the advantage that you don't need any package context to understand it.
+Arguably this should be called |inter_simple_type_description|, but this is the
+one we use most often, so brevity is good.
+
+(3) An //inter_semisimple_type_description// is a much larger structure used only
+when parsing Inter code from text -- so in a regular Inform 7 compilation run, no
+such structures will ever exist. This is still limited, but to the larger
+set of semi-simple type descriptions.
+
+The following definitions look circular, but are not:[1]
+
+(*) A "simple type description" is either a constructor for which all type
+operands are |unchecked|, such as |int32| or |list of unchecked|, or else a
+"type name".
+
+(*) A "semi-simple type description" is either a constructor for which all
+type operands are simple, or else a "type name".
+
+(*) A "type name" is a name defined with a specific semi-simple type description.
+
+[1] Because the hierarchy of definitions of type names must be well-founded.
+You cannot define |K_apple| to equal |K_pear| and vice versa. Each type name
+must be defined in terms of a finite number of simple types, once all type
+name substitution has been performed, and no type name can ever lead back to
+itself.
+
+@ By using type names we can (indirectly) represent any abstract type using
+any of the representations above. For example, |list of list of int32| is neither
+simple nor semi-simple, but we can get to it by:
+
+(1) Defining |K_list_of_int32| as a type name for |list of int32|, which is
+semi-simple.
+
+(2) Defining |K_list_of_list_of_int32| as a type name for |list of K_list_of_int32|,
+which is semi-simple.
+
+And we now have |K_list_of_list_of_int32|, which is simple since it is a bare
+type name, and so can be stored in an //inter_type// or a TID.
+
+@ So, then, this holds any simple type description:
+
+=
+typedef struct inter_type {
+ inter_ti underlying_constructor;
+ inter_symbol *type_name;
+} inter_type;
+
+@ Since there are two possibilities, there are two functions to construct these:
+
+=
+inter_type InterTypes::from_constructor_code(inter_ti constructor_code) {
+ if (InterTypes::is_valid_constructor_code(constructor_code) == FALSE)
+ internal_error("invalid constructor code");
+ inter_type type;
+ type.underlying_constructor = constructor_code;
+ type.type_name = NULL;
+ return type;
+}
+
+inter_type InterTypes::from_type_name(inter_symbol *S) {
+ if (S) {
+ inter_type type;
+ type.underlying_constructor = Inter::Kind::constructor(S);
+ type.type_name = S;
+ return type;
+ }
+ return InterTypes::untyped();
+}
+
+@ Reading those back:
+
+=
+inter_symbol *InterTypes::type_name(inter_type type) {
+ return type.type_name;
+}
+
+inter_type_constructor *InterTypes::constructor(inter_type type) {
+ inter_type_constructor *itc = InterTypes::constructor_from_ID(type.underlying_constructor);
+ if (itc == NULL) itc = InterTypes::constructor_from_ID(UNCHECKED_ITCONC);
+ return itc;
+}
+
+inter_ti InterTypes::constructor_code(inter_type type) {
+ return InterTypes::constructor(type)->constructor_ID;
+}
+
+@ In some ways the most useful simple type is |unchecked|. This declares that
+all type-checking rules are waived for the data being described. A program
+in which all data is |unchecked| is a program with no type-checking at all.
+
+=
+inter_type InterTypes::untyped(void) {
+ return InterTypes::from_constructor_code(UNCHECKED_ITCONC);
+}
+
+int InterTypes::is_untyped(inter_type type) {
+ if (InterTypes::constructor_code(type) == UNCHECKED_ITCONC) return TRUE;
return FALSE;
}
-inter_data_type *Inter::Types::find_by_ID(inter_ti ID) {
- inter_data_type *IDT;
- LOOP_OVER(IDT, inter_data_type)
- if (ID == IDT->type_ID)
- return IDT;
- return NULL;
+@
+
+=
+int InterTypes::type_arity(inter_type type) {
+ inter_symbol *type_name = InterTypes::type_name(type);
+ if (type_name) return Inter::Kind::arity(type_name);
+ return InterTypes::constructor(type)->arity;
}
-inter_data_type *Inter::Types::find_by_name(text_stream *name) {
- dict_entry *de = Dictionaries::find(idt_lookup, name);
- if (de) return (inter_data_type *) Dictionaries::read_value(idt_lookup, name);
- return NULL;
+inter_type InterTypes::type_operand(inter_type type, int n) {
+ inter_symbol *type_name = InterTypes::type_name(type);
+ if (type_name) return Inter::Kind::operand_type(InterTypes::type_name(type), n);
+ return InterTypes::untyped();
}
-inter_ti Inter::Types::transpose_value(inter_ti V1, inter_ti V2, inter_ti *grid, inter_ti grid_extent, inter_error_message **E) {
- switch (V1) {
- case DWORD_IVAL:
- case PDWORD_IVAL:
- case LITERAL_TEXT_IVAL:
- case REAL_IVAL:
- case GLOB_IVAL:
- case DIVIDER_IVAL:
- V2 = grid[V2];
- break;
+@h Converting inter_type to TID and vice versa.
+
+=
+inter_type InterTypes::from_TID(inter_symbols_table *T, inter_ti TID) {
+ if (TID >= SYMBOL_BASE_VAL)
+ return InterTypes::from_type_name(InterSymbolsTable::symbol_from_ID(T, TID));
+ if (InterTypes::is_valid_constructor_code(TID))
+ return InterTypes::from_constructor_code(TID);
+ return InterTypes::untyped();
+}
+
+inter_type InterTypes::from_TID_in_field(inter_tree_node *P, int field) {
+ return InterTypes::from_TID(InterPackage::scope(Inode::get_package(P)), P->W.instruction[field]);
+}
+
+@ =
+inter_ti InterTypes::to_TID(inter_symbols_table *T, inter_type type) {
+ if (type.type_name)
+ return InterSymbolsTable::id_from_symbol_in_table(T, type.type_name);
+ return type.underlying_constructor;
+}
+
+inter_ti InterTypes::to_TID_wrt_bookmark(inter_bookmark *IBM, inter_type type) {
+ if (type.type_name)
+ return InterSymbolsTable::id_from_symbol_at_bookmark(IBM, type.type_name);
+ return type.underlying_constructor;
+}
+
+@h Parsing from text.
+
+@d DEFAULT_SIZE_OF_ISSTD_OPERAND_ARRAY 32
+
+=
+typedef struct inter_semisimple_type_description {
+ inter_ti constructor_code;
+ int arity;
+ int capacity;
+ inter_ti default_operand_TIDs[DEFAULT_SIZE_OF_ISSTD_OPERAND_ARRAY];
+ inter_ti *operand_TIDs;
+} inter_semisimple_type_description;
+
+void InterTypes::initialise_isstd(inter_semisimple_type_description *results) {
+ results->constructor_code = UNCHECKED_ITCONC;
+ results->arity = 0;
+ results->capacity = DEFAULT_SIZE_OF_ISSTD_OPERAND_ARRAY;
+ results->operand_TIDs = results->default_operand_TIDs;
+}
+
+void InterTypes::add_operand_to_isstd(inter_semisimple_type_description *results,
+ inter_symbols_table *T, inter_type type) {
+ inter_ti TID = InterTypes::to_TID(T, type);
+ if (results->arity >= results->capacity) {
+ inter_ti *extended = (inter_ti *) Memory::calloc(2*results->capacity, sizeof(inter_ti),
+ INTER_BYTECODE_MREASON);
+ for (int i=0; i<2*results->capacity; i++)
+ if (i < results->capacity)
+ extended[i] = results->operand_TIDs[i];
+ else
+ extended[i] = 0;
+ @;
+ results->capacity = 2*results->capacity;
+ results->operand_TIDs = extended;
}
- return V2;
+ results->operand_TIDs[(results->arity)++] = TID;
}
-inter_error_message *Inter::Types::validate_pair(inter_package *owner, inter_tree_node *P, int index, inter_type type) {
- inter_ti V1 = P->W.instruction[index];
- inter_ti V2 = P->W.instruction[index+1];
- inter_symbols_table *scope = InterPackage::scope(owner);
- if (scope == NULL) scope = Inode::globals(P);
- switch (V1) {
- case LITERAL_IVAL: {
- inter_data_type *idt = Inter::Types::data_format(type);
- if (idt) {
- long long int I = (signed_inter_ti) V2;
- if ((I < idt->min_value) || (I > idt->max_value)) return Inode::error(P, I"value out of range", NULL);
- return NULL;
+@ =
+void InterTypes::dispose_of_isstd(inter_semisimple_type_description *results) {
+ results->constructor_code = UNCHECKED_ITCONC;
+ results->arity = 0;
+ @;
+}
+
+@ =
+ if (results->capacity > DEFAULT_SIZE_OF_ISSTD_OPERAND_ARRAY)
+ Memory::I7_array_free(results->operand_TIDs, INTER_BYTECODE_MREASON,
+ results->capacity, sizeof(inter_ti));
+
+@ =
+inter_error_message *InterTypes::parse_semisimple(text_stream *text, inter_symbols_table *T,
+ inter_error_location *eloc, inter_semisimple_type_description *results) {
+ results->constructor_code = UNCHECKED_ITCONC;
+ results->arity = 0;
+ inter_error_message *E = NULL;
+ match_results mr2 = Regexp::create_mr();
+ if (Regexp::match(&mr2, text, L"rulebook of (%C+)")) {
+ results->constructor_code = RULEBOOK_ITCONC;
+ inter_type conts_type = InterTypes::parse_simple(T, eloc, mr2.exp[0], &E);
+ if (E) return E;
+ InterTypes::add_operand_to_isstd(results, T, conts_type);
+ } else if (Regexp::match(&mr2, text, L"list of (%C+)")) {
+ results->constructor_code = LIST_ITCONC;
+ inter_type conts_type = InterTypes::parse_simple(T, eloc, mr2.exp[0], &E);
+ if (E) return E;
+ InterTypes::add_operand_to_isstd(results, T, conts_type);
+ } else if (Regexp::match(&mr2, text, L"relation of (%C+) to (%C+)")) {
+ results->constructor_code = RELATION_ITCONC;
+ inter_type X_type = InterTypes::parse_simple(T, eloc, mr2.exp[0], &E);
+ if (E) return E;
+ inter_type Y_type = InterTypes::parse_simple(T, eloc, mr2.exp[1], &E);
+ if (E) return E;
+ InterTypes::add_operand_to_isstd(results, T, X_type);
+ InterTypes::add_operand_to_isstd(results, T, Y_type);
+ } else if (Regexp::match(&mr2, text, L"column of (%C+)")) {
+ results->constructor_code = COLUMN_ITCONC;
+ inter_type conts_type = InterTypes::parse_simple(T, eloc, mr2.exp[0], &E);
+ if (E) return E;
+ InterTypes::add_operand_to_isstd(results, T, conts_type);
+ } else if (Regexp::match(&mr2, text, L"description of (%C+)")) {
+ results->constructor_code = DESCRIPTION_ITCONC;
+ inter_type conts_type = InterTypes::parse_simple(T, eloc, mr2.exp[0], &E);
+ if (E) return E;
+ InterTypes::add_operand_to_isstd(results, T, conts_type);
+ } else if ((Regexp::match(&mr2, text, L"(function) (%c+) -> (%i+)")) ||
+ (Regexp::match(&mr2, text, L"(rule) (%c+) -> (%i+)"))) {
+ if (Str::eq(mr2.exp[0], I"function")) results->constructor_code = FUNCTION_ITCONC;
+ else results->constructor_code = RULE_ITCONC;
+ text_stream *from = mr2.exp[1];
+ text_stream *to = mr2.exp[2];
+ if (Str::eq(from, I"void")) {
+ InterTypes::add_operand_to_isstd(results, T, InterTypes::from_constructor_code(VOID_ITCONC));
+ } else {
+ match_results mr3 = Regexp::create_mr();
+ while (Regexp::match(&mr3, from, L" *(%C+) *(%c*)")) {
+ inter_type arg_type = InterTypes::parse_simple(T, eloc, mr3.exp[0], &E);
+ if (E) return E;
+ Str::copy(from, mr3.exp[1]);
+ InterTypes::add_operand_to_isstd(results, T, arg_type);
}
+ }
+ if (Str::eq(to, I"void")) {
+ InterTypes::add_operand_to_isstd(results, T, InterTypes::from_constructor_code(VOID_ITCONC));
+ } else {
+ inter_type res_type = InterTypes::parse_simple(T, eloc, to, &E);
+ if (E) return E;
+ InterTypes::add_operand_to_isstd(results, T, res_type);
+ }
+ } else if (Regexp::match(&mr2, text, L"struct (%c+)")) {
+ results->constructor_code = STRUCT_ITCONC;
+ text_stream *elements = mr2.exp[0];
+ match_results mr3 = Regexp::create_mr();
+ while (Regexp::match(&mr3, elements, L" *(%C+) *(%c*)")) {
+ inter_type arg_type = InterTypes::parse_simple(T, eloc, mr3.exp[0], &E);
+ if (E) return E;
+ Str::copy(elements, mr3.exp[1]);
+ InterTypes::add_operand_to_isstd(results, T, arg_type);
+ }
+ } else {
+ inter_type_constructor *itc = InterTypes::constructor_from_name(text);
+ if (itc) {
+ results->constructor_code = itc->constructor_ID;
return NULL;
}
- case ALIAS_IVAL: {
- inter_symbol *symb = InterSymbolsTable::symbol_from_ID(scope, V2);
- if (symb == NULL) return Inode::error(P, I"no such symbol", NULL);
- if (InterSymbol::misc_but_undefined(symb)) return NULL;
- if (InterSymbol::defined_elsewhere(symb)) return NULL;
- if (Inter::Types::expresses_value(symb) == FALSE)
- return Inode::error(P, I"nonconstant symbol", InterSymbol::identifier(symb));
- inter_type symbol_type = Inter::Types::of_symbol(symb);
- return Inter::Types::can_be_used_as(symbol_type, type, InterSymbol::identifier(symb), Inode::get_error_location(P));
- }
- case DWORD_IVAL:
- case PDWORD_IVAL:
- case LITERAL_TEXT_IVAL:
- case REAL_IVAL:
- case GLOB_IVAL:
- case UNDEF_IVAL:
- case DIVIDER_IVAL:
+ inter_symbol *K = TextualInter::find_symbol_in_table(T, eloc, text, KIND_IST, &E);
+ if (E) return E;
+ if (K) {
+ results->constructor_code = EQUATED_ITCONC;
+ InterTypes::add_operand_to_isstd(results, T, InterTypes::from_type_name(K));
return NULL;
+ }
+ return Inter::Errors::quoted(I"no such data type", text, eloc);
}
- return Inode::error(P, I"value of unknown category", NULL);
+ return NULL;
}
-int Inter::Types::expresses_value(inter_symbol *symb) {
+inter_type InterTypes::parse_simple(inter_symbols_table *T, inter_error_location *eloc,
+ text_stream *text, inter_error_message **E) {
+ if (Str::len(text) > 0) {
+ inter_semisimple_type_description parsed_description;
+ InterTypes::initialise_isstd(&parsed_description);
+ *E = InterTypes::parse_semisimple(text, T, eloc, &parsed_description);
+ if (*E) return InterTypes::untyped();
+ if (parsed_description.constructor_code == VOID_ITCONC) {
+ *E = Inter::Errors::quoted(I"'void' cannot be used as a type", text, eloc);
+ return InterTypes::untyped();
+ }
+ if (parsed_description.constructor_code == EQUATED_ITCONC) {
+ inter_type type = InterTypes::from_TID(T, parsed_description.operand_TIDs[0]);
+ InterTypes::dispose_of_isstd(&parsed_description);
+ return type;
+ }
+ if (parsed_description.arity > 0) {
+ InterTypes::dispose_of_isstd(&parsed_description);
+ *E = Inter::Errors::quoted(I"type too complex", text, eloc);
+ return InterTypes::untyped();
+ }
+ inter_type type = InterTypes::from_constructor_code(parsed_description.constructor_code);
+ InterTypes::dispose_of_isstd(&parsed_description);
+ return type;
+ }
+ return InterTypes::untyped();
+}
+
+@h Writing to text.
+
+=
+void InterTypes::write_optional_type_marker(OUTPUT_STREAM, inter_tree_node *P, int field) {
+ inter_type type = InterTypes::from_TID_in_field(P, field);
+ if (type.type_name) {
+ WRITE("("); TextualInter::write_symbol_from(OUT, P, field); WRITE(") ");
+ } else if (InterTypes::is_untyped(type) == FALSE) {
+ WRITE("("); InterTypes::write_type(OUT, type); WRITE(") ");
+ }
+}
+
+void InterTypes::write_type_in_field(OUTPUT_STREAM, inter_tree_node *P, int field) {
+ InterTypes::write_type(OUT, InterTypes::from_TID_in_field(P, field));
+}
+
+void InterTypes::write_type(OUTPUT_STREAM, inter_type type) {
+ if (type.type_name) {
+ TextualInter::write_symbol(OUT, type.type_name);
+ } else {
+ inter_type_constructor *itc = InterTypes::constructor(type);
+ WRITE("%S", itc->constructor_keyword);
+ switch (itc->constructor_ID) {
+ case EQUATED_ITCONC:
+ InterTypes::write_type(OUT, InterTypes::type_operand(type, 0));
+ break;
+ case DESCRIPTION_ITCONC:
+ case COLUMN_ITCONC:
+ case RULEBOOK_ITCONC:
+ case LIST_ITCONC:
+ WRITE(" of ");
+ InterTypes::write_type(OUT, InterTypes::type_operand(type, 0));
+ break;
+ case RELATION_ITCONC:
+ WRITE(" of ");
+ InterTypes::write_type(OUT, InterTypes::type_operand(type, 0));
+ WRITE(" to ");
+ InterTypes::write_type(OUT, InterTypes::type_operand(type, 1));
+ break;
+ case FUNCTION_ITCONC:
+ case RULE_ITCONC: {
+ int arity = InterTypes::type_arity(type);
+ for (int i=0; i ");
+ InterTypes::write_type(OUT, InterTypes::type_operand(type, i));
+ }
+ break;
+ }
+ case STRUCT_ITCONC: {
+ int arity = InterTypes::type_arity(type);
+ for (int i=0; i"); return; }
+ WRITE("%S", itc->constructor_keyword);
+ switch (itc->constructor_ID) {
+ case EQUATED_ITCONC:
+ InterTypes::write_type(OUT, Inter::Kind::operand_type(type_name, 0));
+ break;
+ case DESCRIPTION_ITCONC:
+ case COLUMN_ITCONC:
+ case RULEBOOK_ITCONC:
+ case LIST_ITCONC:
+ WRITE(" of ");
+ InterTypes::write_type(OUT, Inter::Kind::operand_type(type_name, 0));
+ break;
+ case RELATION_ITCONC:
+ WRITE(" of ");
+ InterTypes::write_type(OUT, Inter::Kind::operand_type(type_name, 0));
+ WRITE(" to ");
+ InterTypes::write_type(OUT, Inter::Kind::operand_type(type_name, 1));
+ break;
+ case FUNCTION_ITCONC:
+ case RULE_ITCONC: {
+ int arity = Inter::Kind::arity(type_name);
+ for (int i=0; i ");
+ InterTypes::write_type(OUT, Inter::Kind::operand_type(type_name, i));
+ }
+ break;
+ }
+ case STRUCT_ITCONC: {
+ int arity = Inter::Kind::arity(type_name);
+ for (int i=0; iis_enumerated) return TRUE;
+ return FALSE;
+}
+
+int InterTypes::literal_is_in_range(long long int N, inter_type type) {
+ inter_type_constructor *itc = InterTypes::constructor(type);
+ if ((N < itc->min_value) || (N > itc->max_value)) return FALSE;
+ return TRUE;
+}
+
+inter_error_message *InterTypes::can_be_used_as(inter_type A, inter_type B,
+ text_stream *S, inter_error_location *eloc) {
+ inter_type_constructor *A_itc = InterTypes::constructor(A);
+ inter_type_constructor *B_itc = InterTypes::constructor(B);
+
+ if ((A_itc->constructor_ID == UNCHECKED_ITCONC) || (B_itc->constructor_ID == UNCHECKED_ITCONC))
+ return NULL;
+
+ if ((A_itc->constructor_ID == LIST_ITCONC) && (B_itc->constructor_ID == TEXT_ITCONC))
+ return NULL; // so that two-element arrays can be used to implement I7 texts
+
+ if (A_itc->is_base != B_itc->is_base)
+ @;
+
+ if (A_itc->is_base) {
+ inter_symbol *kind_symbol = B.type_name;
+ inter_symbol *kind_loc = A.type_name;
+ if ((kind_symbol) && (kind_loc) && (Inter::Kind::is_a(kind_loc, kind_symbol) == FALSE))
+ @;
+ } else {
+ if (A_itc->constructor_ID != B_itc->constructor_ID)
+ @;
+ inter_error_message *operand_E = NULL;
+ switch (A_itc->constructor_ID) {
+ case LIST_ITCONC:
+ operand_E = InterTypes::can_be_used_as(InterTypes::type_operand(A, 0),
+ InterTypes::type_operand(B, 0), S, eloc);
+ if (operand_E) @;
+ break;
+ }
+ }
+ return NULL;
+}
+
+@ =
+ text_stream *err = Str::new();
+ WRITE_TO(err, "value '%S' has kind ", S);
+ InterTypes::write_type(err, A);
+ WRITE_TO(err, " which is not a ");
+ InterTypes::write_type(err, B);
+ return Inter::Errors::plain(err, eloc);
+
+@h The type of a defined symbol.
+
+=
+inter_type InterTypes::of_symbol(inter_symbol *symb) {
+ inter_tree_node *D = InterSymbol::definition(symb);
+ if (D == NULL) return InterTypes::untyped();
+ if (InterSymbol::defined_elsewhere(symb)) return InterTypes::untyped();
+ if (D->W.instruction[ID_IFLD] == LOCAL_IST) return Inter::Local::type_of(symb);
+ if (D->W.instruction[ID_IFLD] == CONSTANT_IST) return Inter::Constant::type_of(symb);
+ if (D->W.instruction[ID_IFLD] == INSTANCE_IST) return Inter::Instance::type_of(symb);
+ if (D->W.instruction[ID_IFLD] == VARIABLE_IST) return Inter::Variable::type_of(symb);
+ if (D->W.instruction[ID_IFLD] == PROPERTY_IST) return Inter::Property::type_of(symb);
+ return InterTypes::untyped();
+}
+
+int InterTypes::expresses_value(inter_symbol *symb) {
inter_tree_node *D = InterSymbol::definition(symb);
if (D) {
if (D->W.instruction[ID_IFLD] == KIND_IST) return TRUE;
@@ -173,374 +634,3 @@ int Inter::Types::expresses_value(inter_symbol *symb) {
}
return FALSE;
}
-
-@
-
-@e LITERAL_IVAL from 0x10000
-@e LITERAL_TEXT_IVAL
-@e REAL_IVAL
-@e ALIAS_IVAL
-@e UNDEF_IVAL
-@e DWORD_IVAL
-@e PDWORD_IVAL
-@e GLOB_IVAL
-@e DIVIDER_IVAL
-
-=
-
-void Inter::Types::write_pair(OUTPUT_STREAM, inter_tree_node *F,
- inter_ti V1, inter_ti V2, inter_symbols_table *scope, int hex_flag) {
- switch (V1) {
- case LITERAL_IVAL:
- if (hex_flag) WRITE("0x%x", V2);
- else WRITE("%d", V2); break;
- case REAL_IVAL:
- WRITE("r\"");
- Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
- WRITE("\"");
- break;
- case LITERAL_TEXT_IVAL:
- WRITE("\"");
- Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
- WRITE("\"");
- break;
- case ALIAS_IVAL: {
- inter_symbol *symb = InterSymbolsTable::symbol_from_ID_not_following(scope, V2);
- TextualInter::write_symbol(OUT, symb);
- break;
- }
- case UNDEF_IVAL: WRITE("undef"); break;
- case GLOB_IVAL:
- WRITE("&\"");
- Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
- WRITE("\"");
- break;
- case DWORD_IVAL:
- WRITE("dw'");
- Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
- WRITE("'");
- break;
- case PDWORD_IVAL:
- WRITE("dwp'");
- Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
- WRITE("'");
- break;
- case DIVIDER_IVAL:
- WRITE("^\"");
- Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
- WRITE("\"");
- break;
- default: WRITE(""); break;
- }
-}
-
-inter_error_message *Inter::Types::can_be_used_as(inter_type A, inter_type B,
- text_stream *S, inter_error_location *eloc) {
- inter_data_type *A_idt = Inter::Types::data_format(A);
- inter_data_type *B_idt = Inter::Types::data_format(A);
-
- if ((A_idt->type_ID == UNCHECKED_IDT) || (B_idt->type_ID == UNCHECKED_IDT))
- return NULL;
-
- if ((A_idt->type_ID == LIST_IDT) && (B_idt->type_ID == TEXT_IDT))
- return NULL; // so that two-element arrays can be used to implement I7 texts
-
- if (Inter::Types::is_base(A_idt) != Inter::Types::is_base(B_idt))
- @;
-
- if (Inter::Types::is_base(A_idt)) {
- inter_symbol *kind_symbol = B.conceptual_type;
- inter_symbol *kind_loc = A.conceptual_type;
- if ((kind_symbol) && (kind_loc) && (Inter::Kind::is_a(kind_loc, kind_symbol) == FALSE))
- @;
- } else {
- if (A_idt->type_ID != B_idt->type_ID)
- @;
- inter_error_message *operand_E = NULL;
- switch (A_idt->type_ID) {
- case LIST_IDT:
- operand_E = Inter::Types::can_be_used_as(Inter::Types::type_operand(A, 0),
- Inter::Types::type_operand(B, 0), S, eloc);
- if (operand_E) @;
- break;
- }
- }
- return NULL;
-}
-
-@ =
- text_stream *err = Str::new();
- WRITE_TO(err, "value '%S' has kind ", S);
- Inter::Types::write_type(err, A);
- WRITE_TO(err, " which is not a ");
- Inter::Types::write_type(err, B);
- // WRITE_TO(STDERR, "%S: %S: %x, %x\n", err, S, A.underlying_data->type_ID, B.underlying_data->type_ID);
- return Inter::Errors::plain(err, eloc);
-
-@ =
-inter_type Inter::Types::of_symbol(inter_symbol *symb) {
- inter_tree_node *D = InterSymbol::definition(symb);
- if (D == NULL) return Inter::Types::untyped();
- if (InterSymbol::defined_elsewhere(symb)) return Inter::Types::untyped();
- if (D->W.instruction[ID_IFLD] == LOCAL_IST) return Inter::Local::type_of(symb);
- if (D->W.instruction[ID_IFLD] == CONSTANT_IST) return Inter::Constant::type_of(symb);
- if (D->W.instruction[ID_IFLD] == INSTANCE_IST) return Inter::Instance::type_of(symb);
- if (D->W.instruction[ID_IFLD] == VARIABLE_IST) return Inter::Variable::type_of(symb);
- if (D->W.instruction[ID_IFLD] == PROPERTY_IST) return Inter::Property::type_of(symb);
- return Inter::Types::untyped();
-}
-
-inter_error_message *Inter::Types::read_data_pair(text_stream *line, inter_error_location *eloc,
- inter_bookmark *IBM, inter_type it, text_stream *S, inter_ti *val1, inter_ti *val2,
- inter_symbols_table *scope) {
- inter_tree *I = InterBookmark::tree(IBM);
- inter_package *pack = InterBookmark::package(IBM);
-
- if (Str::eq(S, I"undef")) {
- *val1 = UNDEF_IVAL; *val2 = 0; return NULL;
- }
- if ((Str::begins_with_wide_string(S, L"\"")) && (Str::ends_with_wide_string(S, L"\""))) {
- *val1 = LITERAL_TEXT_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
- text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
- return Inter::Constant::parse_text(glob_storage, S, 1, Str::len(S)-2, eloc);
- }
- if ((Str::begins_with_wide_string(S, L"r\"")) && (Str::ends_with_wide_string(S, L"\""))) {
- *val1 = REAL_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
- text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
- return Inter::Constant::parse_text(glob_storage, S, 2, Str::len(S)-2, eloc);
- }
- if ((Str::begins_with_wide_string(S, L"&\"")) && (Str::ends_with_wide_string(S, L"\""))) {
- *val1 = GLOB_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
- text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
- return Inter::Constant::parse_text(glob_storage, S, 2, Str::len(S)-2, eloc);
- }
- if ((Str::begins_with_wide_string(S, L"dw'")) && (Str::ends_with_wide_string(S, L"'"))) {
- *val1 = DWORD_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
- text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
- return Inter::Constant::parse_text(glob_storage, S, 3, Str::len(S)-2, eloc);
- }
- if ((Str::begins_with_wide_string(S, L"dwp'")) && (Str::ends_with_wide_string(S, L"'"))) {
- *val1 = PDWORD_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
- text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
- return Inter::Constant::parse_text(glob_storage, S, 4, Str::len(S)-2, eloc);
- }
- if ((Str::begins_with_wide_string(S, L"^\"")) && (Str::ends_with_wide_string(S, L"\""))) {
- *val1 = DIVIDER_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
- text_stream *divider_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
- return Inter::Constant::parse_text(divider_storage, S, 2, Str::len(S)-2, eloc);
- }
- if (Str::get_first_char(S) == '/') {
- inter_symbol *symb = InterSymbolsTable::URL_to_symbol(I, S);
- if (symb == NULL) {
- TEMPORARY_TEXT(leaf)
- LOOP_THROUGH_TEXT(pos, S) {
- wchar_t c = Str::get(pos);
- if (c == '/') Str::clear(leaf);
- else PUT_TO(leaf, c);
- }
- if (Str::len(leaf) == 0) return Inter::Errors::quoted(I"URL ends in '/'", S, eloc);
- symb = InterSymbolsTable::symbol_from_name(InterBookmark::scope(IBM), leaf);
- if (!((symb) && (Wiring::is_wired_to_name(symb)) && (Str::eq(Wiring::wired_to_name(symb), S)))) {
- symb = InterSymbolsTable::create_with_unique_name(InterBookmark::scope(IBM), leaf);
- Wiring::wire_to_name(symb, S);
- }
- DISCARD_TEXT(leaf)
- }
- @;
- }
- int ident = FALSE;
- if (Characters::isalpha(Str::get_first_char(S))) {
- ident = TRUE;
- LOOP_THROUGH_TEXT(pos, S)
- if ((Characters::isalpha(Str::get(pos)) == FALSE) &&
- (Characters::isdigit(Str::get(pos)) == FALSE) &&
- (Str::get(pos) != '_'))
- ident = FALSE;
- }
- if (ident) {
- inter_symbol *symb = InterSymbolsTable::symbol_from_name(scope, S);
- if (symb) @;
- symb = InterSymbolsTable::create_with_unique_name(InterBookmark::scope(IBM), S);
- Inter::Types::symbol_to_pair(I, pack, symb, val1, val2);
- InterSymbol::set_flag(symb, SPECULATIVE_ISYMF);
- return NULL;
- }
-
- wchar_t c = Str::get_first_char(S);
- if ((c == '-') || (Characters::isdigit(c))) {
- int sign = 1, base = 10, from = 0;
- if (Str::prefix_eq(S, I"-", 1)) { sign = -1; from = 1; }
- if (Str::prefix_eq(S, I"0b", 2)) { base = 2; from = 2; }
- if (Str::prefix_eq(S, I"0x", 2)) { base = 16; from = 2; }
- long long int N = 0;
- LOOP_THROUGH_TEXT(pos, S) {
- if (pos.index < from) continue;
- int c = Str::get(pos), d = 0;
- if ((c >= 'a') && (c <= 'z')) d = c-'a'+10;
- else if ((c >= 'A') && (c <= 'Z')) d = c-'A'+10;
- else if ((c >= '0') && (c <= '9')) d = c-'0';
- else return Inter::Errors::quoted(I"bad digit", S, eloc);
- if (d > base) return Inter::Errors::quoted(I"bad digit for this number base", S, eloc);
- N = base*N + (long long int) d;
- if (pos.index > 34) return Inter::Errors::quoted(I"value out of range", S, eloc);
- }
- N = sign*N;
- inter_data_type *idt = it.underlying_data;
- if ((idt) && ((N < idt->min_value) || (N > idt->max_value)))
- return Inter::Errors::quoted(I"value out of range", S, eloc);
-
- *val1 = LITERAL_IVAL; *val2 = (inter_ti) N;
- return NULL;
- }
-
- return Inter::Errors::quoted(I"unrecognised value", S, eloc);
-}
-
-@ =
- inter_data_type *idt = it.underlying_data;
- if ((Inter::Types::is_enumerated(idt)) &&
- (InterSymbol::is_defined(symb) == FALSE))
- return Inter::Errors::quoted(I"undefined symbol", S, eloc);
- inter_type symbol_type = Inter::Types::of_symbol(symb);
- if (symbol_type.underlying_data->type_ID != UNCHECKED_IDT) {
- inter_error_message *E = Inter::Types::can_be_used_as(symbol_type, it, S, eloc);
- if (E) return E;
- }
- Inter::Types::symbol_to_pair(I, pack, symb, val1, val2);
- return NULL;
-
-@ =
-int Inter::Types::read_int_in_I6_notation(text_stream *S, inter_ti *val1, inter_ti *val2) {
- int sign = 1, base = 10, from = 0;
- if (Str::prefix_eq(S, I"-", 1)) { sign = -1; from = 1; }
- if (Str::prefix_eq(S, I"$", 1)) { base = 16; from = 1; }
- if (Str::prefix_eq(S, I"$$", 2)) { base = 2; from = 2; }
- long long int N = 0;
- LOOP_THROUGH_TEXT(pos, S) {
- if (pos.index < from) continue;
- int c = Str::get(pos), d = 0;
- if ((c >= 'a') && (c <= 'z')) d = c-'a'+10;
- else if ((c >= 'A') && (c <= 'Z')) d = c-'A'+10;
- else if ((c >= '0') && (c <= '9')) d = c-'0';
- else return FALSE;
- if (d > base) return FALSE;
- N = base*N + (long long int) d;
- if (pos.index > 34) return FALSE;
- }
- N = sign*N;
-
- *val1 = LITERAL_IVAL; *val2 = (inter_ti) N;
- return TRUE;
-}
-
-@
-
-=
-int Inter::Types::pair_holds_symbol(inter_ti val1, inter_ti val2) {
- if (val1 == ALIAS_IVAL) return TRUE;
- return FALSE;
-}
-
-void Inter::Types::symbol_to_pair(inter_tree *I, inter_package *pack, inter_symbol *S,
- inter_ti *val1, inter_ti *val2) {
- if (S == NULL) internal_error("no symbol");
- *val1 = ALIAS_IVAL; *val2 = InterSymbolsTable::id_from_symbol(I, pack, S);
-}
-
-typedef struct inter_type {
- inter_data_type *underlying_data;
- inter_symbol *conceptual_type;
-} inter_type;
-
-inter_type Inter::Types::parse(inter_symbols_table *T, inter_error_location *eloc,
- text_stream *text, inter_error_message **E) {
- inter_type it;
- it.conceptual_type = NULL;
- it.underlying_data = unchecked_idt;
- if (Str::len(text) > 0) {
- it.conceptual_type = TextualInter::find_symbol_in_table(T, eloc, text, KIND_IST, E);
- if (it.conceptual_type)
- it.underlying_data = Inter::Kind::data_type(it.conceptual_type);
- else {
- it.underlying_data = Inter::Types::find_by_name(text);
- if (it.underlying_data == NULL) {
- *E = Inter::Errors::quoted(I"unrecognised data type", text, eloc);
- it.underlying_data = unchecked_idt;
- }
- }
- }
- return it;
-}
-
-inter_type Inter::Types::from_symbol(inter_symbol *S) {
- inter_type it;
- if (S) it.underlying_data = Inter::Kind::data_type(S);
- else it.underlying_data = unchecked_idt;
- it.conceptual_type = S;
- return it;
-}
-
-inter_symbol *Inter::Types::conceptual_type(inter_type it) {
- return it.conceptual_type;
-}
-
-inter_type Inter::Types::untyped(void) {
- return Inter::Types::from_symbol(NULL);
-}
-
-inter_data_type *Inter::Types::data_format(inter_type it) {
- return it.underlying_data;
-}
-
-int Inter::Types::type_arity(inter_type it) {
- return Inter::Kind::arity(Inter::Types::conceptual_type(it));
-}
-
-inter_type Inter::Types::type_operand(inter_type it, int n) {
- return Inter::Types::from_symbol(Inter::Kind::operand_symbol(Inter::Types::conceptual_type(it), n));
-}
-
-inter_type Inter::Types::from_TID(inter_tree_node *P, int field) {
- inter_type it;
- it.underlying_data = unchecked_idt;
- it.conceptual_type = InterSymbolsTable::symbol_from_ID_at_node(P, field);
- if (it.conceptual_type)
- it.underlying_data = Inter::Kind::data_type(it.conceptual_type);
- return it;
-}
-
-inter_ti Inter::Types::to_TID(inter_bookmark *IBM, inter_type it) {
- if (it.conceptual_type)
- return InterSymbolsTable::id_from_symbol_at_bookmark(IBM, it.conceptual_type);
- return 0;
-}
-
-void Inter::Types::verify_type_field(inter_package *owner, inter_tree_node *P,
- int field, int data_field, inter_error_message **E) {
- if (P->W.instruction[field]) {
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[field], KIND_IST);
- if (*E) return;
- if (data_field >= 0) {
- inter_type type = Inter::Types::from_TID(P, field);
- *E = Inter::Types::validate_pair(owner, P, data_field, type);
- if (*E) return;
- }
- }
-}
-
-void Inter::Types::write_type_field(OUTPUT_STREAM, inter_tree_node *P, int field) {
- inter_type it = Inter::Types::from_TID(P, field);
- if (it.conceptual_type) {
- WRITE("("); TextualInter::write_symbol_from(OUT, P, field); WRITE(") ");
- } else if (it.underlying_data != unchecked_idt) {
- WRITE("(%S) ", it.underlying_data->reserved_word);
- }
-}
-
-void Inter::Types::write_type(OUTPUT_STREAM, inter_type type) {
- if (type.conceptual_type) {
- TextualInter::write_symbol(OUT, type.conceptual_type);
- } else if (type.underlying_data != unchecked_idt) {
- WRITE("%S", type.underlying_data->reserved_word);
- }
-}
diff --git a/inter/bytecode-module/Chapter 3/Inter Value Pairs.w b/inter/bytecode-module/Chapter 3/Inter Value Pairs.w
new file mode 100644
index 000000000..0215f55b4
--- /dev/null
+++ b/inter/bytecode-module/Chapter 3/Inter Value Pairs.w
@@ -0,0 +1,268 @@
+[InterValuePairs::] Inter Value Pairs.
+
+Two consecutive bytecode words are used to store a single value in binary Inter.
+
+@
+
+@d inter_ti unsigned int
+@d signed_inter_ti int
+
+@
+
+@e LITERAL_IVAL from 0x10000
+@e LITERAL_TEXT_IVAL
+@e REAL_IVAL
+@e ALIAS_IVAL
+@e UNDEF_IVAL
+@e DWORD_IVAL
+@e PDWORD_IVAL
+@e GLOB_IVAL
+@e DIVIDER_IVAL
+
+=
+void InterValuePairs::write(OUTPUT_STREAM, inter_tree_node *F,
+ inter_ti V1, inter_ti V2, inter_symbols_table *scope, int hex_flag) {
+ switch (V1) {
+ case LITERAL_IVAL:
+ if (hex_flag) WRITE("0x%x", V2);
+ else WRITE("%d", V2); break;
+ case REAL_IVAL:
+ WRITE("r\"");
+ Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
+ WRITE("\"");
+ break;
+ case LITERAL_TEXT_IVAL:
+ WRITE("\"");
+ Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
+ WRITE("\"");
+ break;
+ case ALIAS_IVAL: {
+ inter_symbol *symb = InterSymbolsTable::symbol_from_ID_not_following(scope, V2);
+ TextualInter::write_symbol(OUT, symb);
+ break;
+ }
+ case UNDEF_IVAL: WRITE("undef"); break;
+ case GLOB_IVAL:
+ WRITE("&\"");
+ Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
+ WRITE("\"");
+ break;
+ case DWORD_IVAL:
+ WRITE("dw'");
+ Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
+ WRITE("'");
+ break;
+ case PDWORD_IVAL:
+ WRITE("dwp'");
+ Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
+ WRITE("'");
+ break;
+ case DIVIDER_IVAL:
+ WRITE("^\"");
+ Inter::Constant::write_text(OUT, Inode::ID_to_text(F, V2));
+ WRITE("\"");
+ break;
+ default: WRITE(""); break;
+ }
+}
+
+@ =
+int InterValuePairs::read_int_in_I6_notation(text_stream *S, inter_ti *val1, inter_ti *val2) {
+ int sign = 1, base = 10, from = 0;
+ if (Str::prefix_eq(S, I"-", 1)) { sign = -1; from = 1; }
+ if (Str::prefix_eq(S, I"$", 1)) { base = 16; from = 1; }
+ if (Str::prefix_eq(S, I"$$", 2)) { base = 2; from = 2; }
+ long long int N = 0;
+ LOOP_THROUGH_TEXT(pos, S) {
+ if (pos.index < from) continue;
+ int c = Str::get(pos), d = 0;
+ if ((c >= 'a') && (c <= 'z')) d = c-'a'+10;
+ else if ((c >= 'A') && (c <= 'Z')) d = c-'A'+10;
+ else if ((c >= '0') && (c <= '9')) d = c-'0';
+ else return FALSE;
+ if (d > base) return FALSE;
+ N = base*N + (long long int) d;
+ if (pos.index > 34) return FALSE;
+ }
+ N = sign*N;
+
+ *val1 = LITERAL_IVAL; *val2 = (inter_ti) N;
+ return TRUE;
+}
+
+@
+
+=
+int InterValuePairs::holds_symbol(inter_ti val1, inter_ti val2) {
+ if (val1 == ALIAS_IVAL) return TRUE;
+ return FALSE;
+}
+
+void InterValuePairs::from_symbol(inter_tree *I, inter_package *pack, inter_symbol *S,
+ inter_ti *val1, inter_ti *val2) {
+ if (S == NULL) internal_error("no symbol");
+ *val1 = ALIAS_IVAL; *val2 = InterSymbolsTable::id_from_symbol(I, pack, S);
+}
+
+inter_error_message *InterValuePairs::parse(text_stream *line, inter_error_location *eloc,
+ inter_bookmark *IBM, inter_type type_wanted, text_stream *S, inter_ti *val1, inter_ti *val2,
+ inter_symbols_table *scope) {
+ inter_tree *I = InterBookmark::tree(IBM);
+ inter_package *pack = InterBookmark::package(IBM);
+
+ if (Str::eq(S, I"undef")) {
+ *val1 = UNDEF_IVAL; *val2 = 0; return NULL;
+ }
+ if ((Str::begins_with_wide_string(S, L"\"")) && (Str::ends_with_wide_string(S, L"\""))) {
+ *val1 = LITERAL_TEXT_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
+ text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
+ return Inter::Constant::parse_text(glob_storage, S, 1, Str::len(S)-2, eloc);
+ }
+ if ((Str::begins_with_wide_string(S, L"r\"")) && (Str::ends_with_wide_string(S, L"\""))) {
+ *val1 = REAL_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
+ text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
+ return Inter::Constant::parse_text(glob_storage, S, 2, Str::len(S)-2, eloc);
+ }
+ if ((Str::begins_with_wide_string(S, L"&\"")) && (Str::ends_with_wide_string(S, L"\""))) {
+ *val1 = GLOB_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
+ text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
+ return Inter::Constant::parse_text(glob_storage, S, 2, Str::len(S)-2, eloc);
+ }
+ if ((Str::begins_with_wide_string(S, L"dw'")) && (Str::ends_with_wide_string(S, L"'"))) {
+ *val1 = DWORD_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
+ text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
+ return Inter::Constant::parse_text(glob_storage, S, 3, Str::len(S)-2, eloc);
+ }
+ if ((Str::begins_with_wide_string(S, L"dwp'")) && (Str::ends_with_wide_string(S, L"'"))) {
+ *val1 = PDWORD_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
+ text_stream *glob_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
+ return Inter::Constant::parse_text(glob_storage, S, 4, Str::len(S)-2, eloc);
+ }
+ if ((Str::begins_with_wide_string(S, L"^\"")) && (Str::ends_with_wide_string(S, L"\""))) {
+ *val1 = DIVIDER_IVAL; *val2 = InterWarehouse::create_text(InterTree::warehouse(I), pack);
+ text_stream *divider_storage = InterWarehouse::get_text(InterTree::warehouse(I), *val2);
+ return Inter::Constant::parse_text(divider_storage, S, 2, Str::len(S)-2, eloc);
+ }
+ if (Str::get_first_char(S) == '/') {
+ inter_symbol *symb = InterSymbolsTable::URL_to_symbol(I, S);
+ if (symb == NULL) {
+ TEMPORARY_TEXT(leaf)
+ LOOP_THROUGH_TEXT(pos, S) {
+ wchar_t c = Str::get(pos);
+ if (c == '/') Str::clear(leaf);
+ else PUT_TO(leaf, c);
+ }
+ if (Str::len(leaf) == 0) return Inter::Errors::quoted(I"URL ends in '/'", S, eloc);
+ symb = InterSymbolsTable::symbol_from_name(InterBookmark::scope(IBM), leaf);
+ if (!((symb) && (Wiring::is_wired_to_name(symb)) && (Str::eq(Wiring::wired_to_name(symb), S)))) {
+ symb = InterSymbolsTable::create_with_unique_name(InterBookmark::scope(IBM), leaf);
+ Wiring::wire_to_name(symb, S);
+ }
+ DISCARD_TEXT(leaf)
+ }
+ @;
+ }
+ int ident = FALSE;
+ if (Characters::isalpha(Str::get_first_char(S))) {
+ ident = TRUE;
+ LOOP_THROUGH_TEXT(pos, S)
+ if ((Characters::isalpha(Str::get(pos)) == FALSE) &&
+ (Characters::isdigit(Str::get(pos)) == FALSE) &&
+ (Str::get(pos) != '_'))
+ ident = FALSE;
+ }
+ if (ident) {
+ inter_symbol *symb = InterSymbolsTable::symbol_from_name(scope, S);
+ if (symb) @;
+ symb = InterSymbolsTable::create_with_unique_name(InterBookmark::scope(IBM), S);
+ InterValuePairs::from_symbol(I, pack, symb, val1, val2);
+ InterSymbol::set_flag(symb, SPECULATIVE_ISYMF);
+ return NULL;
+ }
+
+ wchar_t c = Str::get_first_char(S);
+ if ((c == '-') || (Characters::isdigit(c))) {
+ int sign = 1, base = 10, from = 0;
+ if (Str::prefix_eq(S, I"-", 1)) { sign = -1; from = 1; }
+ if (Str::prefix_eq(S, I"0b", 2)) { base = 2; from = 2; }
+ if (Str::prefix_eq(S, I"0x", 2)) { base = 16; from = 2; }
+ long long int N = 0;
+ LOOP_THROUGH_TEXT(pos, S) {
+ if (pos.index < from) continue;
+ int c = Str::get(pos), d = 0;
+ if ((c >= 'a') && (c <= 'z')) d = c-'a'+10;
+ else if ((c >= 'A') && (c <= 'Z')) d = c-'A'+10;
+ else if ((c >= '0') && (c <= '9')) d = c-'0';
+ else return Inter::Errors::quoted(I"bad digit", S, eloc);
+ if (d > base) return Inter::Errors::quoted(I"bad digit for this number base", S, eloc);
+ N = base*N + (long long int) d;
+ if (pos.index > 34) return Inter::Errors::quoted(I"value out of range", S, eloc);
+ }
+ N = sign*N;
+ if (InterTypes::literal_is_in_range(N, type_wanted) == FALSE)
+ return Inter::Errors::quoted(I"value out of range", S, eloc);
+
+ *val1 = LITERAL_IVAL; *val2 = (inter_ti) N;
+ return NULL;
+ }
+
+ return Inter::Errors::quoted(I"unrecognised value", S, eloc);
+}
+
+@ =
+ if ((InterTypes::is_enumerated(type_wanted)) && (InterSymbol::is_defined(symb) == FALSE))
+ return Inter::Errors::quoted(I"undefined symbol", S, eloc);
+ inter_type symbol_type = InterTypes::of_symbol(symb);
+ inter_error_message *E = InterTypes::can_be_used_as(symbol_type, type_wanted, S, eloc);
+ if (E) return E;
+ InterValuePairs::from_symbol(I, pack, symb, val1, val2);
+ return NULL;
+
+@ =
+inter_ti InterValuePairs::transpose_value(inter_ti V1, inter_ti V2, inter_ti *grid, inter_ti grid_extent, inter_error_message **E) {
+ switch (V1) {
+ case DWORD_IVAL:
+ case PDWORD_IVAL:
+ case LITERAL_TEXT_IVAL:
+ case REAL_IVAL:
+ case GLOB_IVAL:
+ case DIVIDER_IVAL:
+ V2 = grid[V2];
+ break;
+ }
+ return V2;
+}
+
+inter_error_message *InterValuePairs::validate(inter_package *owner, inter_tree_node *P, int index, inter_type type) {
+ inter_ti V1 = P->W.instruction[index];
+ inter_ti V2 = P->W.instruction[index+1];
+ inter_symbols_table *scope = InterPackage::scope(owner);
+ if (scope == NULL) scope = Inode::globals(P);
+ switch (V1) {
+ case LITERAL_IVAL: {
+ long long int I = (signed_inter_ti) V2;
+ if (InterTypes::literal_is_in_range(I, type) == FALSE)
+ return Inode::error(P, I"value out of range", NULL);
+ return NULL;
+ }
+ case ALIAS_IVAL: {
+ inter_symbol *symb = InterSymbolsTable::symbol_from_ID(scope, V2);
+ if (symb == NULL) return Inode::error(P, I"no such symbol", NULL);
+ if (InterSymbol::misc_but_undefined(symb)) return NULL;
+ if (InterSymbol::defined_elsewhere(symb)) return NULL;
+ if (InterTypes::expresses_value(symb) == FALSE)
+ return Inode::error(P, I"nonconstant symbol", InterSymbol::identifier(symb));
+ inter_type symbol_type = InterTypes::of_symbol(symb);
+ return InterTypes::can_be_used_as(symbol_type, type, InterSymbol::identifier(symb), Inode::get_error_location(P));
+ }
+ case DWORD_IVAL:
+ case PDWORD_IVAL:
+ case LITERAL_TEXT_IVAL:
+ case REAL_IVAL:
+ case GLOB_IVAL:
+ case UNDEF_IVAL:
+ case DIVIDER_IVAL:
+ return NULL;
+ }
+ return Inode::error(P, I"value of unknown category", NULL);
+}
diff --git a/inter/bytecode-module/Chapter 3/Verifying Inter.w b/inter/bytecode-module/Chapter 3/Verifying Inter.w
index 302e0ab60..ced5b1169 100644
--- a/inter/bytecode-module/Chapter 3/Verifying Inter.w
+++ b/inter/bytecode-module/Chapter 3/Verifying Inter.w
@@ -50,6 +50,32 @@ inter_error_message *Inter::Verify::symbol(inter_package *owner, inter_tree_node
return NULL;
}
+inter_error_message *Inter::Verify::TID(inter_package *owner, inter_tree_node *P, inter_ti TID) {
+ if (TID == 0) return NULL;
+ if (InterTypes::is_valid_constructor_code(TID)) return NULL;
+ return Inter::Verify::symbol(owner, P, TID, KIND_IST);
+}
+
+inter_error_message *Inter::Verify::constructor_code(inter_tree_node *P, int index) {
+ inter_ti ID = P->W.instruction[index];
+ if (InterTypes::is_valid_constructor_code(ID) == FALSE)
+ return Inode::error(P, I"unknown type constructor", NULL);
+ return NULL;
+}
+
+void Inter::Verify::typed_data(inter_package *owner, inter_tree_node *P,
+ int field, int data_field, inter_error_message **E) {
+ if (P->W.instruction[field]) {
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[field]);
+ if (*E) return;
+ if (data_field >= 0) {
+ inter_type type = InterTypes::from_TID_in_field(P, field);
+ *E = InterValuePairs::validate(owner, P, data_field, type);
+ if (*E) return;
+ }
+ }
+}
+
inter_error_message *Inter::Verify::global_symbol(inter_tree_node *P, inter_ti ID, inter_ti construct) {
inter_symbol *S = InterSymbolsTable::symbol_from_ID(Inode::globals(P), ID);
if (S == NULL) { internal_error("IO"); return Inode::error(P, I"3no symbol for ID", NULL); }
@@ -97,13 +123,6 @@ inter_error_message *Inter::Verify::symbol_KOI(inter_package *owner, inter_tree_
return NULL;
}
-inter_error_message *Inter::Verify::data_type(inter_tree_node *P, int index) {
- inter_ti ID = P->W.instruction[index];
- inter_data_type *idt = Inter::Types::find_by_ID(ID);
- if (idt == NULL) return Inode::error(P, I"unknown data type", NULL);
- return NULL;
-}
-
void Inter::Verify::writer(OUTPUT_STREAM, char *format_string, void *vI) {
inter_tree_node *F = (inter_tree_node *) vI;
if (F == NULL) { WRITE(""); return; }
diff --git a/inter/bytecode-module/Chapter 4/The Constant Construct.w b/inter/bytecode-module/Chapter 4/The Constant Construct.w
index ac18c3a0f..c3be1284f 100644
--- a/inter/bytecode-module/Chapter 4/The Constant Construct.w
+++ b/inter/bytecode-module/Chapter 4/The Constant Construct.w
@@ -47,7 +47,7 @@ void Inter::Constant::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
name_text = mr3.exp[1];
}
- inter_type con_type = Inter::Types::parse(InterBookmark::scope(IBM), eloc, kind_text, E);
+ inter_type con_type = InterTypes::parse_simple(InterBookmark::scope(IBM), eloc, kind_text, E);
if (*E) return;
inter_symbol *con_name = TextualInter::new_symbol(eloc, InterBookmark::scope(IBM), name_text, E);
@@ -65,7 +65,7 @@ void Inter::Constant::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
else if (Regexp::match(&mr2, S, L"quotient{ (%c*) }")) op = CONSTANT_QUOTIENT_LIST;
if (op != 0) {
inter_tree_node *P =
- Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), Inter::Types::to_TID(IBM, con_type), op, eloc, (inter_ti) ilp->indent_level);
+ Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), InterTypes::to_TID_wrt_bookmark(IBM, con_type), op, eloc, (inter_ti) ilp->indent_level);
*E = InterConstruct::verify_construct(InterBookmark::package(IBM), P);
if (*E) return;
text_stream *conts = mr2.exp[0];
@@ -84,10 +84,10 @@ void Inter::Constant::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
}
if (Regexp::match(&mr2, S, L"{ (%c*) }")) {
- inter_type conts_type = Inter::Types::type_operand(con_type, 0);
+ inter_type conts_type = InterTypes::type_operand(con_type, 0);
inter_ti form = CONSTANT_INDIRECT_LIST;
inter_tree_node *P =
- Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), Inter::Types::to_TID(IBM, con_type), form, eloc, (inter_ti) ilp->indent_level);
+ Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), InterTypes::to_TID_wrt_bookmark(IBM, con_type), form, eloc, (inter_ti) ilp->indent_level);
*E = InterConstruct::verify_construct(InterBookmark::package(IBM), P);
if (*E) return;
text_stream *conts = mr2.exp[0];
@@ -107,19 +107,19 @@ void Inter::Constant::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
if (Regexp::match(&mr2, S, L"struct{ (%c*) }")) {
inter_tree_node *P =
- Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), Inter::Types::to_TID(IBM, con_type), CONSTANT_STRUCT, eloc, (inter_ti) ilp->indent_level);
- int arity = Inter::Types::type_arity(con_type);
+ Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), InterTypes::to_TID_wrt_bookmark(IBM, con_type), CONSTANT_STRUCT, eloc, (inter_ti) ilp->indent_level);
+ int arity = InterTypes::type_arity(con_type);
int counter = 0;
text_stream *conts = mr2.exp[0];
match_results mr3 = Regexp::create_mr();
while (Regexp::match(&mr3, conts, L"(%c*?), (%c+)")) {
- inter_type conts_type = Inter::Types::type_operand(con_type, counter++);
+ inter_type conts_type = InterTypes::type_operand(con_type, counter++);
if (Inter::Constant::append(ilp->line, eloc, IBM, conts_type, P, mr3.exp[0], E) == FALSE)
return;
Str::copy(conts, mr3.exp[1]);
}
if (Regexp::match(&mr3, conts, L" *(%c*?) *")) {
- inter_type conts_type = Inter::Types::type_operand(con_type, counter++);
+ inter_type conts_type = InterTypes::type_operand(con_type, counter++);
if (Inter::Constant::append(ilp->line, eloc, IBM, conts_type, P, mr3.exp[0], E) == FALSE)
return;
}
@@ -132,18 +132,18 @@ void Inter::Constant::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
if (Regexp::match(&mr2, S, L"table{ (%c*) }")) {
inter_tree_node *P =
- Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), Inter::Types::to_TID(IBM, con_type), CONSTANT_TABLE, eloc, (inter_ti) ilp->indent_level);
+ Inode::new_with_3_data_fields(IBM, CONSTANT_IST, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), InterTypes::to_TID_wrt_bookmark(IBM, con_type), CONSTANT_TABLE, eloc, (inter_ti) ilp->indent_level);
*E = InterConstruct::verify_construct(InterBookmark::package(IBM), P);
if (*E) return;
text_stream *conts = mr2.exp[0];
match_results mr3 = Regexp::create_mr();
while (Regexp::match(&mr3, conts, L"(%c*?), (%c+)")) {
- if (Inter::Constant::append(ilp->line, eloc, IBM, Inter::Types::untyped(), P, mr3.exp[0], E) == FALSE)
+ if (Inter::Constant::append(ilp->line, eloc, IBM, InterTypes::untyped(), P, mr3.exp[0], E) == FALSE)
return;
Str::copy(conts, mr3.exp[1]);
}
if (Regexp::match(&mr3, conts, L" *(%c*?) *")) {
- if (Inter::Constant::append(ilp->line, eloc, IBM, Inter::Types::untyped(), P, mr3.exp[0], E) == FALSE)
+ if (Inter::Constant::append(ilp->line, eloc, IBM, InterTypes::untyped(), P, mr3.exp[0], E) == FALSE)
return;
}
NodePlacement::move_to_moving_bookmark(P, IBM);
@@ -160,7 +160,7 @@ void Inter::Constant::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
}
DISCARD_TEXT(parsed_text)
if (*E) return;
- *E = Inter::Constant::new_textual(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), Inter::Types::to_TID(IBM, con_type), ID, (inter_ti) ilp->indent_level, eloc);
+ *E = Inter::Constant::new_textual(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), InterTypes::to_TID_wrt_bookmark(IBM, con_type), ID, (inter_ti) ilp->indent_level, eloc);
return;
}
@@ -170,17 +170,17 @@ void Inter::Constant::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
if (block == NULL) {
*E = Inter::Errors::quoted(I"no such function body", fname, eloc); return;
}
- *E = Inter::Constant::new_function(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), Inter::Types::to_TID(IBM, con_type), block, (inter_ti) ilp->indent_level, eloc);
+ *E = Inter::Constant::new_function(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), InterTypes::to_TID_wrt_bookmark(IBM, con_type), block, (inter_ti) ilp->indent_level, eloc);
return;
}
inter_ti con_val1 = 0;
inter_ti con_val2 = 0;
- *E = Inter::Types::read_data_pair(ilp->line, eloc, IBM, con_type, S, &con_val1, &con_val2, InterBookmark::scope(IBM));
+ *E = InterValuePairs::parse(ilp->line, eloc, IBM, con_type, S, &con_val1, &con_val2, InterBookmark::scope(IBM));
if (*E) return;
- *E = Inter::Constant::new_numerical(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), Inter::Types::to_TID(IBM, con_type), con_val1, con_val2, (inter_ti) ilp->indent_level, eloc);
+ *E = Inter::Constant::new_numerical(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_name), InterTypes::to_TID_wrt_bookmark(IBM, con_type), con_val1, con_val2, (inter_ti) ilp->indent_level, eloc);
}
inter_error_message *Inter::Constant::parse_text(text_stream *parsed_text, text_stream *S, int from, int to, inter_error_location *eloc) {
@@ -262,21 +262,8 @@ int Inter::Constant::append(text_stream *line, inter_error_location *eloc, inter
*E = NULL;
inter_ti con_val1 = 0;
inter_ti con_val2 = 0;
-/* if (Inter::Types::conceptual_type(conts_type) == NULL) {
- inter_symbol *tc = TextualInter::find_symbol(IBM, eloc, S, CONSTANT_IST, E);
- if (*E) return FALSE;
- if (Inter::Kind::constructor(Inter::Constant::kind_of(tc)) == COLUMN_IDT) {
- Inter::Types::symbol_to_pair(InterBookmark::tree(IBM), InterBookmark::package(IBM), tc, &con_val1, &con_val2);
- } else {
- *E = Inter::Errors::quoted(I"not a table column constant", S, eloc);
- return FALSE;
- }
- } else {
-*/
- // WRITE_TO(STDERR, "Line <%S> S = <%S>\n", line, S);
- *E = Inter::Types::read_data_pair(line, eloc, IBM, conts_type, S, &con_val1, &con_val2, InterBookmark::scope(IBM));
- if (*E) return FALSE;
-// }
+ *E = InterValuePairs::parse(line, eloc, IBM, conts_type, S, &con_val1, &con_val2, InterBookmark::scope(IBM));
+ if (*E) return FALSE;
Inode::extend_instruction_by(P, 2);
P->W.instruction[P->W.extent-2] = con_val1;
P->W.instruction[P->W.extent-1] = con_val2;
@@ -289,7 +276,7 @@ void Inter::Constant::transpose(inter_construct *IC, inter_tree_node *P, inter_t
switch (P->W.instruction[FORMAT_CONST_IFLD]) {
case CONSTANT_DIRECT:
- P->W.instruction[DATA_CONST_IFLD+1] = Inter::Types::transpose_value(P->W.instruction[DATA_CONST_IFLD], P->W.instruction[DATA_CONST_IFLD+1], grid, grid_extent, E);
+ P->W.instruction[DATA_CONST_IFLD+1] = InterValuePairs::transpose_value(P->W.instruction[DATA_CONST_IFLD], P->W.instruction[DATA_CONST_IFLD+1], grid, grid_extent, E);
break;
case CONSTANT_INDIRECT_TEXT:
P->W.instruction[DATA_CONST_IFLD] = grid[P->W.instruction[DATA_CONST_IFLD]];
@@ -302,7 +289,7 @@ void Inter::Constant::transpose(inter_construct *IC, inter_tree_node *P, inter_t
case CONSTANT_STRUCT:
case CONSTANT_TABLE:
for (int i=DATA_CONST_IFLD; iW.extent; i=i+2) {
- P->W.instruction[i+1] = Inter::Types::transpose_value(P->W.instruction[i], P->W.instruction[i+1], grid, grid_extent, E);
+ P->W.instruction[i+1] = InterValuePairs::transpose_value(P->W.instruction[i], P->W.instruction[i+1], grid, grid_extent, E);
}
break;
}
@@ -311,13 +298,13 @@ void Inter::Constant::transpose(inter_construct *IC, inter_tree_node *P, inter_t
void Inter::Constant::verify(inter_construct *IC, inter_tree_node *P, inter_package *owner, inter_error_message **E) {
*E = Inter::Verify::defn(owner, P, DEFN_CONST_IFLD);
if (*E) return;
- Inter::Types::verify_type_field(owner, P, KIND_CONST_IFLD, -1, E);
+ Inter::Verify::typed_data(owner, P, KIND_CONST_IFLD, -1, E);
if (*E) return;
- inter_type it = Inter::Types::from_TID(P, KIND_CONST_IFLD);
+ inter_type it = InterTypes::from_TID_in_field(P, KIND_CONST_IFLD);
switch (P->W.instruction[FORMAT_CONST_IFLD]) {
case CONSTANT_DIRECT:
if (P->W.extent != DATA_CONST_IFLD + 2) { *E = Inode::error(P, I"extent wrong", NULL); return; }
- *E = Inter::Types::validate_pair(owner, P, DATA_CONST_IFLD, it);
+ *E = InterValuePairs::validate(owner, P, DATA_CONST_IFLD, it);
if (*E) return;
break;
case CONSTANT_SUM_LIST:
@@ -326,7 +313,7 @@ void Inter::Constant::verify(inter_construct *IC, inter_tree_node *P, inter_pack
case CONSTANT_QUOTIENT_LIST:
if ((P->W.extent % 2) != 1) { *E = Inode::error(P, I"extent wrong", NULL); return; }
for (int i=DATA_CONST_IFLD; iW.extent; i=i+2) {
- *E = Inter::Types::validate_pair(owner, P, i, it);
+ *E = InterValuePairs::validate(owner, P, i, it);
if (*E) return;
}
break;
@@ -337,9 +324,9 @@ void Inter::Constant::verify(inter_construct *IC, inter_tree_node *P, inter_pack
inter_ti V2 = P->W.instruction[i+1];
inter_symbol *symb = InterSymbolsTable::symbol_from_data_pair(V1, V2, InterPackage::scope(owner));
if (symb) {
- inter_type type = Inter::Types::of_symbol(symb);
- if ((type.underlying_data->type_ID != COLUMN_IDT) &&
- (type.underlying_data->type_ID != UNCHECKED_IDT)) {
+ inter_type type = InterTypes::of_symbol(symb);
+ inter_ti constructor = InterTypes::constructor_code(type);
+ if ((constructor != COLUMN_ITCONC) && (constructor != UNCHECKED_ITCONC)) {
*E = Inode::error(P, I"not a table column constant", NULL); return;
}
} else {
@@ -349,30 +336,31 @@ void Inter::Constant::verify(inter_construct *IC, inter_tree_node *P, inter_pack
break;
case CONSTANT_INDIRECT_LIST: {
if ((P->W.extent % 2) != 1) { *E = Inode::error(P, I"extent wrong", NULL); return; }
- inter_data_type *idt = Inter::Types::data_format(it);
- if ((idt) && ((idt->type_ID == LIST_IDT) || (idt->type_ID == RULEBOOK_IDT) || (idt->type_ID == COLUMN_IDT))) {
- inter_type conts_type = Inter::Types::type_operand(it, 0);
+ inter_ti constructor = InterTypes::constructor_code(it);
+ if ((constructor == LIST_ITCONC) || (constructor == RULEBOOK_ITCONC) || (constructor == COLUMN_ITCONC)) {
+ inter_type conts_type = InterTypes::type_operand(it, 0);
for (int i=DATA_CONST_IFLD; iW.extent; i=i+2) {
- *E = Inter::Types::validate_pair(owner, P, i, conts_type); if (*E) return;
+ *E = InterValuePairs::validate(owner, P, i, conts_type); if (*E) return;
}
- } else if (idt) {
- { *E = Inode::error(P, I"not a list", InterSymbol::identifier(Inter::Types::conceptual_type(it))); return; }
+ } else {
+ *E = Inode::error(P, I"not a list", NULL);
+ return;
}
break;
}
case CONSTANT_STRUCT: {
if ((P->W.extent % 2) != 1) { *E = Inode::error(P, I"extent odd", NULL); return; }
- inter_data_type *idt = Inter::Types::data_format(it);
- if ((idt) && (idt->type_ID == STRUCT_IDT)) {
- int arity = Inter::Kind::arity(Inter::Types::conceptual_type(it));
+ inter_ti constructor = InterTypes::constructor_code(it);
+ if (constructor == STRUCT_ITCONC) {
+ int arity = InterTypes::type_arity(it);
int given = (P->W.extent - DATA_CONST_IFLD)/2;
if (arity != given) { *E = Inode::error(P, I"extent not same size as struct definition", NULL); return; }
for (int i=DATA_CONST_IFLD, counter = 0; iW.extent; i=i+2) {
- inter_type conts_type = Inter::Types::type_operand(it, counter++);
- *E = Inter::Types::validate_pair(owner, P, i, conts_type); if (*E) return;
+ inter_type conts_type = InterTypes::type_operand(it, counter++);
+ *E = InterValuePairs::validate(owner, P, i, conts_type); if (*E) return;
}
- } else if (idt) {
- { *E = Inode::error(P, I"not a struct", NULL); return; }
+ } else {
+ *E = Inode::error(P, I"not a struct", NULL); return;
}
break;
}
@@ -397,11 +385,11 @@ void Inter::Constant::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node
if (SymbolAnnotation::get_b(con_name, HEX_IANN)) hex = TRUE;
if (con_name) {
WRITE("constant ");
- Inter::Types::write_type_field(OUT, P, KIND_CONST_IFLD);
+ InterTypes::write_optional_type_marker(OUT, P, KIND_CONST_IFLD);
WRITE("%S = ", InterSymbol::identifier(con_name));
switch (P->W.instruction[FORMAT_CONST_IFLD]) {
case CONSTANT_DIRECT:
- Inter::Types::write_pair(OUT, P,
+ InterValuePairs::write(OUT, P,
P->W.instruction[DATA_CONST_IFLD], P->W.instruction[DATA_CONST_IFLD+1], InterPackage::scope_of(P), hex);
break;
case CONSTANT_TABLE:
@@ -419,7 +407,7 @@ void Inter::Constant::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node
for (int i=DATA_CONST_IFLD; iW.extent; i=i+2) {
if (i > DATA_CONST_IFLD) WRITE(",");
WRITE(" ");
- Inter::Types::write_pair(OUT, P, P->W.instruction[i], P->W.instruction[i+1], InterPackage::scope_of(P), hex);
+ InterValuePairs::write(OUT, P, P->W.instruction[i], P->W.instruction[i+1], InterPackage::scope_of(P), hex);
}
WRITE(" }");
break;
@@ -429,7 +417,7 @@ void Inter::Constant::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node
for (int i=DATA_CONST_IFLD; iW.extent; i=i+2) {
if (i > DATA_CONST_IFLD) WRITE(",");
WRITE(" ");
- Inter::Types::write_pair(OUT, P, P->W.instruction[i], P->W.instruction[i+1], InterPackage::scope_of(P), hex);
+ InterValuePairs::write(OUT, P, P->W.instruction[i], P->W.instruction[i+1], InterPackage::scope_of(P), hex);
}
WRITE(" }");
break;
@@ -455,11 +443,11 @@ void Inter::Constant::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node
}
inter_type Inter::Constant::type_of(inter_symbol *con_symbol) {
- if (con_symbol == NULL) return Inter::Types::untyped();
+ if (con_symbol == NULL) return InterTypes::untyped();
inter_tree_node *D = InterSymbol::definition(con_symbol);
- if (D == NULL) return Inter::Types::untyped();
- if (D->W.instruction[ID_IFLD] != CONSTANT_IST) return Inter::Types::untyped();
- return Inter::Types::from_TID(D, KIND_CONST_IFLD);
+ if (D == NULL) return InterTypes::untyped();
+ if (D->W.instruction[ID_IFLD] != CONSTANT_IST) return InterTypes::untyped();
+ return InterTypes::from_TID_in_field(D, KIND_CONST_IFLD);
}
inter_package *Inter::Constant::code_block(inter_symbol *con_symbol) {
@@ -533,7 +521,7 @@ int Inter::Constant::constant_depth_r(inter_symbol *con) {
inter_ti Inter::Constant::evaluate(inter_symbols_table *T, inter_ti val1, inter_ti val2) {
if (val1 == LITERAL_IVAL) return val2;
- if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ if (InterValuePairs::holds_symbol(val1, val2)) {
inter_symbol *aliased = InterSymbolsTable::symbol_from_data_pair(val1, val2, T);
if (aliased == NULL) internal_error("bad aliased symbol");
inter_tree_node *D = aliased->definition;
diff --git a/inter/bytecode-module/Chapter 4/The DefaultValue Construct.w b/inter/bytecode-module/Chapter 4/The DefaultValue Construct.w
index 82ec8b259..c36446295 100644
--- a/inter/bytecode-module/Chapter 4/The DefaultValue Construct.w
+++ b/inter/bytecode-module/Chapter 4/The DefaultValue Construct.w
@@ -34,7 +34,7 @@ void Inter::DefaultValue::read(inter_construct *IC, inter_bookmark *IBM, inter_l
inter_ti con_val1 = 0;
inter_ti con_val2 = 0;
- *E = Inter::Types::read_data_pair(ilp->line, eloc, IBM, Inter::Types::from_symbol(con_kind), ilp->mr.exp[1], &con_val1, &con_val2, InterBookmark::scope(IBM));
+ *E = InterValuePairs::parse(ilp->line, eloc, IBM, InterTypes::from_type_name(con_kind), ilp->mr.exp[1], &con_val1, &con_val2, InterBookmark::scope(IBM));
if (*E) return;
*E = Inter::DefaultValue::new(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, con_kind), con_val1, con_val2, (inter_ti) ilp->indent_level, eloc);
@@ -56,7 +56,7 @@ void Inter::DefaultValue::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_n
inter_symbol *con_kind = InterSymbolsTable::symbol_from_ID_at_node(P, KIND_DEF_IFLD);
if (con_kind) {
WRITE("defaultvalue %S = ", InterSymbol::identifier(con_kind));
- Inter::Types::write_pair(OUT, P,
+ InterValuePairs::write(OUT, P,
P->W.instruction[VAL1_DEF_IFLD], P->W.instruction[VAL1_DEF_IFLD+1], InterPackage::scope_of(P), FALSE);
} else {
*E = Inode::error(P, I"defaultvalue can't be written", NULL);
diff --git a/inter/bytecode-module/Chapter 4/The Instance Construct.w b/inter/bytecode-module/Chapter 4/The Instance Construct.w
index c09517293..4232eca98 100644
--- a/inter/bytecode-module/Chapter 4/The Instance Construct.w
+++ b/inter/bytecode-module/Chapter 4/The Instance Construct.w
@@ -45,13 +45,13 @@ void Inter::Instance::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
inter_symbol *inst_kind = TextualInter::find_symbol(IBM, eloc, ktext, KIND_IST, E);
if (*E) return;
- inter_data_type *idt = Inter::Kind::data_type(inst_kind);
- if (Inter::Types::is_enumerated(idt) == FALSE)
+ inter_type inst_type = InterTypes::from_type_name(inst_kind);
+ if (InterTypes::is_enumerated(inst_type) == FALSE)
{ *E = Inter::Errors::quoted(I"not a kind which has instances", ilp->mr.exp[1], eloc); return; }
inter_ti v1 = UNDEF_IVAL, v2 = 0;
if (vtext) {
- *E = Inter::Types::read_data_pair(ilp->line, eloc, IBM, Inter::Types::untyped(), vtext, &v1, &v2, InterBookmark::scope(IBM));
+ *E = InterValuePairs::parse(ilp->line, eloc, IBM, InterTypes::untyped(), vtext, &v1, &v2, InterBookmark::scope(IBM));
if (*E) return;
}
*E = Inter::Instance::new(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, inst_name), InterSymbolsTable::id_from_symbol_at_bookmark(IBM, inst_kind), v1, v2, (inter_ti) ilp->indent_level, eloc);
@@ -79,14 +79,14 @@ void Inter::Instance::verify(inter_construct *IC, inter_tree_node *P, inter_pack
inter_symbol *inst_name = InterSymbolsTable::symbol_from_ID(InterPackage::scope(owner), P->W.instruction[DEFN_INST_IFLD]);
*E = Inter::Verify::symbol(owner, P, P->W.instruction[KIND_INST_IFLD], KIND_IST); if (*E) return;
inter_symbol *inst_kind = InterSymbolsTable::symbol_from_ID(InterPackage::scope(owner), P->W.instruction[KIND_INST_IFLD]);
- inter_data_type *idt = Inter::Kind::data_type(inst_kind);
- if (Inter::Types::is_enumerated(idt)) {
+ inter_type inst_type = InterTypes::from_type_name(inst_kind);
+ if (InterTypes::is_enumerated(inst_type)) {
if (P->W.instruction[VAL1_INST_IFLD] == UNDEF_IVAL) {
P->W.instruction[VAL1_INST_IFLD] = LITERAL_IVAL;
P->W.instruction[VAL2_INST_IFLD] = Inter::Kind::next_enumerated_value(inst_kind);
}
} else { *E = Inode::error(P, I"not a kind which has instances", NULL); return; }
- *E = Inter::Types::validate_pair(owner, P, VAL1_INST_IFLD, Inter::Types::from_symbol(inst_kind)); if (*E) return;
+ *E = InterValuePairs::validate(owner, P, VAL1_INST_IFLD, InterTypes::from_type_name(inst_kind)); if (*E) return;
inter_ti vcount = Inode::bump_verification_count(P);
if (vcount == 0) {
@@ -105,12 +105,9 @@ void Inter::Instance::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node
inter_symbol *inst_name = InterSymbolsTable::symbol_from_ID_at_node(P, DEFN_INST_IFLD);
inter_symbol *inst_kind = InterSymbolsTable::symbol_from_ID_at_node(P, KIND_INST_IFLD);
if ((inst_name) && (inst_kind)) {
- inter_data_type *idt = Inter::Kind::data_type(inst_kind);
- if (idt) {
- WRITE("instance %S %S = ", InterSymbol::identifier(inst_name), InterSymbol::identifier(inst_kind));
- Inter::Types::write_pair(OUT, P,
- P->W.instruction[VAL1_INST_IFLD], P->W.instruction[VAL2_INST_IFLD], InterPackage::scope_of(P), FALSE);
- } else { *E = Inode::error(P, I"instance with bad data type", NULL); return; }
+ WRITE("instance %S %S = ", InterSymbol::identifier(inst_name), InterSymbol::identifier(inst_kind));
+ InterValuePairs::write(OUT, P,
+ P->W.instruction[VAL1_INST_IFLD], P->W.instruction[VAL2_INST_IFLD], InterPackage::scope_of(P), FALSE);
} else { *E = Inode::error(P, I"bad instance", NULL); return; }
SymbolAnnotation::write_annotations(OUT, P, inst_name);
}
@@ -123,13 +120,13 @@ inter_ti Inter::Instance::properties_list(inter_symbol *inst_name) {
}
inter_type Inter::Instance::type_of(inter_symbol *inst_name) {
- if (inst_name == NULL) return Inter::Types::untyped();
+ if (inst_name == NULL) return InterTypes::untyped();
inter_tree_node *D = InterSymbol::definition(inst_name);
- if (D == NULL) return Inter::Types::untyped();
- if (D->W.instruction[ID_IFLD] != INSTANCE_IST) return Inter::Types::untyped();
- return Inter::Types::from_symbol(InterSymbolsTable::symbol_from_ID_at_node(D, KIND_INST_IFLD));
+ if (D == NULL) return InterTypes::untyped();
+ if (D->W.instruction[ID_IFLD] != INSTANCE_IST) return InterTypes::untyped();
+ return InterTypes::from_type_name(InterSymbolsTable::symbol_from_ID_at_node(D, KIND_INST_IFLD));
}
inter_symbol *Inter::Instance::kind_of(inter_symbol *inst_name) {
- return Inter::Types::conceptual_type(Inter::Instance::type_of(inst_name));
+ return InterTypes::type_name(Inter::Instance::type_of(inst_name));
}
diff --git a/inter/bytecode-module/Chapter 4/The Kind Construct.w b/inter/bytecode-module/Chapter 4/The Kind Construct.w
index b2f4da782..de495e149 100644
--- a/inter/bytecode-module/Chapter 4/The Kind Construct.w
+++ b/inter/bytecode-module/Chapter 4/The Kind Construct.w
@@ -30,8 +30,6 @@ void Inter::Kind::define(void) {
@d MIN_EXTENT_KIND_IFR 9
-@d MAX_ICON_OPERANDS 128
-
=
void Inter::Kind::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse *ilp, inter_error_location *eloc, inter_error_message **E) {
*E = InterConstruct::check_level_in_package(IBM, KIND_IST, ilp->indent_level, eloc);
@@ -40,108 +38,33 @@ void Inter::Kind::read(inter_construct *IC, inter_bookmark *IBM, inter_line_pars
inter_symbol *symb = TextualInter::new_symbol(eloc, InterBookmark::scope(IBM), ilp->mr.exp[0], E);
if (*E) return;
+ inter_semisimple_type_description parsed_description;
+ InterTypes::initialise_isstd(&parsed_description);
match_results mr2 = Regexp::create_mr();
- inter_ti constructor = UNCHECKED_IDT;
- int arity = 0;
- inter_ti operands[MAX_ICON_OPERANDS];
inter_symbol *super_kind = NULL;
- for (int i=0; imr.exp[1], L"<= (%i+)")) {
super_kind = TextualInter::find_symbol(IBM, eloc, mr2.exp[0], KIND_IST, E);
- if (*E) return;
- if (Inter::Types::is_enumerated(Inter::Kind::data_type(super_kind)) == FALSE)
+ if ((*E == NULL) &&
+ (InterTypes::is_enumerated(InterTypes::from_type_name(super_kind)) == FALSE))
{ *E = Inter::Errors::quoted(I"not a kind which can have subkinds", mr2.exp[0], eloc); return; }
- constructor = ENUM_IDT;
- } else if (Regexp::match(&mr2, ilp->mr.exp[1], L"rulebook of (%i+)")) {
- constructor = RULEBOOK_IDT;
- inter_symbol *conts_kind = TextualInter::find_symbol(IBM, eloc, mr2.exp[0], KIND_IST, E);
- if (*E) return;
- operands[0] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, conts_kind); arity = 1;
- } else if (Regexp::match(&mr2, ilp->mr.exp[1], L"list of (%i+)")) {
- constructor = LIST_IDT;
- inter_symbol *conts_kind = TextualInter::find_symbol(IBM, eloc, mr2.exp[0], KIND_IST, E);
- if (*E) return;
- operands[0] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, conts_kind); arity = 1;
- } else if (Regexp::match(&mr2, ilp->mr.exp[1], L"relation of (%i+) to (%i+)")) {
- constructor = RELATION_IDT;
- inter_symbol *X_kind = TextualInter::find_symbol(IBM, eloc, mr2.exp[0], KIND_IST, E);
- if (*E) return;
- inter_symbol *Y_kind = TextualInter::find_symbol(IBM, eloc, mr2.exp[1], KIND_IST, E);
- if (*E) return;
- operands[0] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, X_kind);
- operands[1] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, Y_kind);
- arity = 2;
- } else if (Regexp::match(&mr2, ilp->mr.exp[1], L"column of (%i+)")) {
- constructor = COLUMN_IDT;
- inter_symbol *conts_kind = TextualInter::find_symbol(IBM, eloc, mr2.exp[0], KIND_IST, E);
- if (*E) return;
- operands[0] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, conts_kind); arity = 1;
- } else if (Regexp::match(&mr2, ilp->mr.exp[1], L"description of (%i+)")) {
- constructor = DESCRIPTION_IDT;
- inter_symbol *conts_kind = TextualInter::find_symbol(IBM, eloc, mr2.exp[0], KIND_IST, E);
- if (*E) return;
- operands[0] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, conts_kind); arity = 1;
- } else if ((Regexp::match(&mr2, ilp->mr.exp[1], L"(function) (%c+) -> (%i+)")) ||
- (Regexp::match(&mr2, ilp->mr.exp[1], L"(rule) (%c+) -> (%i+)"))) {
- if (Str::eq(mr2.exp[0], I"function")) constructor = FUNCTION_IDT;
- else constructor = RULE_IDT;
- text_stream *from = mr2.exp[1];
- text_stream *to = mr2.exp[2];
- if (Str::eq(from, I"void")) {
- if (arity >= MAX_ICON_OPERANDS) { *E = Inter::Errors::plain(I"too many args", eloc); return; }
- operands[arity++] = 0;
- } else {
- match_results mr3 = Regexp::create_mr();
- while (Regexp::match(&mr3, from, L" *(%i+) *(%c*)")) {
- inter_symbol *arg_kind = TextualInter::find_symbol(IBM, eloc, mr3.exp[0], KIND_IST, E);
- if (*E) return;
- Str::copy(from, mr3.exp[1]);
- if (arity >= MAX_ICON_OPERANDS) { *E = Inter::Errors::plain(I"too many args", eloc); return; }
- operands[arity++] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, arg_kind);
- }
- }
- if (Str::eq(to, I"void")) {
- if (arity >= MAX_ICON_OPERANDS) { *E = Inter::Errors::plain(I"too many args", eloc); return; }
- operands[arity++] = 0;
- } else {
- inter_symbol *res_kind = TextualInter::find_symbol(IBM, eloc, to, KIND_IST, E);
- if (*E) return;
- if (arity >= MAX_ICON_OPERANDS) { *E = Inter::Errors::plain(I"too many args", eloc); return; }
- operands[arity++] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, res_kind);
- }
- } else if (Regexp::match(&mr2, ilp->mr.exp[1], L"struct (%c+)")) {
- constructor = STRUCT_IDT;
- text_stream *elements = mr2.exp[0];
- match_results mr3 = Regexp::create_mr();
- while (Regexp::match(&mr3, elements, L" *(%i+) *(%c*)")) {
- inter_symbol *arg_kind = TextualInter::find_symbol(IBM, eloc, mr3.exp[0], KIND_IST, E);
- if (*E) return;
- Str::copy(elements, mr3.exp[1]);
- if (arity >= MAX_ICON_OPERANDS) { *E = Inter::Errors::plain(I"too many args", eloc); return; }
- operands[arity++] = InterSymbolsTable::id_from_symbol_at_bookmark(IBM, arg_kind);
- }
+ parsed_description.constructor_code = ENUM_ITCONC;
+ parsed_description.arity = 0;
} else {
- inter_data_type *idt = Inter::Kind::parse_data_type(eloc, ilp->mr.exp[1], E);
- if (*E) return;
- constructor = idt->type_ID;
+ *E = InterTypes::parse_semisimple(ilp->mr.exp[1], InterBookmark::scope(IBM), eloc, &parsed_description);
}
-
- *E = Inter::Kind::new(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, symb),
- constructor,
- (super_kind)?(InterSymbolsTable::id_from_symbol_at_bookmark(IBM, super_kind)):0,
- arity, operands, (inter_ti) ilp->indent_level, eloc);
-}
-
-inter_data_type *Inter::Kind::parse_data_type(inter_error_location *eloc, text_stream *name, inter_error_message **E) {
- inter_data_type *idt = Inter::Types::find_by_name(name);
- if (idt == NULL) *E = Inter::Errors::quoted(I"no such data type", name, eloc);
- return idt;
+ Regexp::dispose_of(&mr2);
+
+ if (*E == NULL)
+ *E = Inter::Kind::new(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, symb),
+ parsed_description.constructor_code,
+ (super_kind)?(InterSymbolsTable::id_from_symbol_at_bookmark(IBM, super_kind)):0,
+ parsed_description.arity, parsed_description.operand_TIDs, (inter_ti) ilp->indent_level, eloc);
+ InterTypes::dispose_of_isstd(&parsed_description);
}
inter_error_message *Inter::Kind::new(inter_bookmark *IBM, inter_ti SID, inter_ti constructor, inter_ti SUP,
int arity, inter_ti *operands, inter_ti level, inter_error_location *eloc) {
-
- if ((constructor < UNCHECKED_IDT) || (constructor > RULEBOOK_IDT))
+ if (InterTypes::is_valid_constructor_code(constructor) == FALSE)
internal_error("constructor out of range");
inter_warehouse *warehouse = InterBookmark::warehouse(IBM);
@@ -170,55 +93,60 @@ void Inter::Kind::verify(inter_construct *IC, inter_tree_node *P, inter_package
if (P->W.instruction[ENUM_RANGE_KIND_IFLD] != 0) {
inter_symbol *the_kind = InterSymbolsTable::symbol_from_ID(InterPackage::scope(owner), P->W.instruction[DEFN_KIND_IFLD]);
if ((the_kind == NULL) ||
- (Inter::Types::is_enumerated(Inter::Types::find_by_ID(P->W.instruction[CONSTRUCTOR_KIND_IFLD])) == FALSE))
+ (InterTypes::is_enumerated(InterTypes::from_type_name(the_kind)) == FALSE))
{ *E = Inode::error(P, I"spurious extent in non-enumeration", NULL); return; }
}
if (P->W.instruction[SUPER_KIND_IFLD] != 0) {
*E = Inter::Verify::symbol(owner, P, P->W.instruction[SUPER_KIND_IFLD], KIND_IST); if (*E) return;
inter_symbol *super_kind = InterSymbolsTable::symbol_from_ID(InterPackage::scope(owner), P->W.instruction[SUPER_KIND_IFLD]);
- if (Inter::Types::is_enumerated(Inter::Kind::data_type(super_kind)) == FALSE)
+ if (InterTypes::is_enumerated(InterTypes::from_type_name(super_kind)) == FALSE)
{ *E = Inode::error(P, I"subkind of nonenumerated kind", NULL); return; }
}
- *E = Inter::Verify::data_type(P, CONSTRUCTOR_KIND_IFLD); if (*E) return;
+ *E = Inter::Verify::constructor_code(P, CONSTRUCTOR_KIND_IFLD); if (*E) return;
int arity = P->W.extent - MIN_EXTENT_KIND_IFR;
switch (P->W.instruction[CONSTRUCTOR_KIND_IFLD]) {
- case LIST_IDT:
- case RULEBOOK_IDT:
+ case EQUATED_ITCONC:
+ if (arity != 1) { *E = Inode::error(P, I"wrong equated arity", NULL); return; }
+ if (P->W.instruction[OPERANDS_KIND_IFLD] == 0) { *E = Inode::error(P, I"no equated kind", NULL); return; }
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD]); if (*E) return;
+ break;
+ case LIST_ITCONC:
+ case RULEBOOK_ITCONC:
if (arity != 1) { *E = Inode::error(P, I"wrong list arity", NULL); return; }
if (P->W.instruction[OPERANDS_KIND_IFLD] == 0) { *E = Inode::error(P, I"no listed kind", NULL); return; }
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[OPERANDS_KIND_IFLD], KIND_IST); if (*E) return;
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD]); if (*E) return;
break;
- case COLUMN_IDT: if (arity != 1) { *E = Inode::error(P, I"wrong col arity", NULL); return; }
+ case COLUMN_ITCONC: if (arity != 1) { *E = Inode::error(P, I"wrong col arity", NULL); return; }
if (P->W.instruction[OPERANDS_KIND_IFLD] == 0) { *E = Inode::error(P, I"no listed kind", NULL); return; }
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[OPERANDS_KIND_IFLD], KIND_IST); if (*E) return;
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD]); if (*E) return;
break;
- case DESCRIPTION_IDT: if (arity != 1) { *E = Inode::error(P, I"wrong desc arity", NULL); return; }
+ case DESCRIPTION_ITCONC: if (arity != 1) { *E = Inode::error(P, I"wrong desc arity", NULL); return; }
if (P->W.instruction[OPERANDS_KIND_IFLD] == 0) { *E = Inode::error(P, I"no listed kind", NULL); return; }
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[OPERANDS_KIND_IFLD], KIND_IST); if (*E) return;
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD]); if (*E) return;
break;
- case RELATION_IDT: if (arity != 2) { *E = Inode::error(P, I"wrong relation arity", NULL); return; }
+ case RELATION_ITCONC: if (arity != 2) { *E = Inode::error(P, I"wrong relation arity", NULL); return; }
if (P->W.instruction[OPERANDS_KIND_IFLD] == 0) { *E = Inode::error(P, I"no listed kind", NULL); return; }
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[OPERANDS_KIND_IFLD], KIND_IST); if (*E) return;
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD]); if (*E) return;
if (P->W.instruction[OPERANDS_KIND_IFLD+1] == 0) { *E = Inode::error(P, I"no listed kind", NULL); return; }
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[OPERANDS_KIND_IFLD+1], KIND_IST); if (*E) return;
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD+1]); if (*E) return;
break;
- case FUNCTION_IDT:
- case RULE_IDT:
+ case FUNCTION_ITCONC:
+ case RULE_ITCONC:
if (arity < 2) { *E = Inode::error(P, I"function arity too low", NULL); return; }
for (int i=0; iW.instruction[OPERANDS_KIND_IFLD + i] == 0) {
if (!(((i == 0) && (arity == 2)) || (i == arity - 1)))
{ *E = Inode::error(P, I"no listed kind", NULL); return; }
} else {
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[OPERANDS_KIND_IFLD + i], KIND_IST);
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD + i]);
if (*E) return;
}
}
break;
- case STRUCT_IDT:
+ case STRUCT_ITCONC:
if (arity == 0) { *E = Inode::error(P, I"struct arity too low", NULL); return; }
for (int i=0; iW.instruction[OPERANDS_KIND_IFLD + i], KIND_IST);
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[OPERANDS_KIND_IFLD + i]);
if (*E) return;
}
break;
@@ -245,70 +173,13 @@ inter_ti Inter::Kind::properties_list(inter_symbol *inst_name) {
void Inter::Kind::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
inter_symbol *symb = InterSymbolsTable::symbol_from_ID_at_node(P, DEFN_KIND_IFLD);
- inter_data_type *idt = Inter::Types::find_by_ID(P->W.instruction[CONSTRUCTOR_KIND_IFLD]);
- if ((symb) && (idt)) {
+ if (symb) {
WRITE("kind %S ", InterSymbol::identifier(symb));
if (P->W.instruction[SUPER_KIND_IFLD]) {
inter_symbol *super = InterSymbolsTable::symbol_from_ID_at_node(P, SUPER_KIND_IFLD);
WRITE("<= %S", InterSymbol::identifier(super));
} else {
- switch (P->W.instruction[CONSTRUCTOR_KIND_IFLD]) {
- case LIST_IDT: {
- inter_symbol *conts_kind = InterSymbolsTable::symbol_from_ID_at_node(P, OPERANDS_KIND_IFLD);
- WRITE("list of %S", InterSymbol::identifier(conts_kind));
- break;
- }
- case RULEBOOK_IDT: {
- inter_symbol *conts_kind = InterSymbolsTable::symbol_from_ID_at_node(P, OPERANDS_KIND_IFLD);
- WRITE("rulebook of %S", InterSymbol::identifier(conts_kind));
- break;
- }
- case COLUMN_IDT: {
- inter_symbol *conts_kind = InterSymbolsTable::symbol_from_ID_at_node(P, OPERANDS_KIND_IFLD);
- WRITE("column of %S", InterSymbol::identifier(conts_kind));
- break;
- }
- case DESCRIPTION_IDT: {
- inter_symbol *conts_kind = InterSymbolsTable::symbol_from_ID_at_node(P, OPERANDS_KIND_IFLD);
- WRITE("description of %S", InterSymbol::identifier(conts_kind));
- break;
- }
- case RELATION_IDT: {
- inter_symbol *X_kind = InterSymbolsTable::symbol_from_ID_at_node(P, OPERANDS_KIND_IFLD);
- inter_symbol *Y_kind = InterSymbolsTable::symbol_from_ID_at_node(P, OPERANDS_KIND_IFLD+1);
- WRITE("relation of %S to %S", InterSymbol::identifier(X_kind), InterSymbol::identifier(Y_kind));
- break;
- }
- case FUNCTION_IDT:
- case RULE_IDT: {
- if (P->W.instruction[CONSTRUCTOR_KIND_IFLD] == FUNCTION_IDT)
- WRITE("function");
- else
- WRITE("rule");
- int arity = P->W.extent - MIN_EXTENT_KIND_IFR;
- for (int i=0; i ");
- if (P->W.instruction[OPERANDS_KIND_IFLD + i] == 0) {
- WRITE("void");
- } else {
- inter_symbol *K = InterSymbolsTable::symbol_from_ID_at_node(P, OPERANDS_KIND_IFLD + i);
- WRITE("%S", InterSymbol::identifier(K));
- }
- }
- break;
- }
- case STRUCT_IDT: {
- WRITE("struct");
- int arity = P->W.extent - MIN_EXTENT_KIND_IFR;
- for (int i=0; ireserved_word); break;
- }
+ InterTypes::write_type_name_definition(OUT, symb);
}
} else { *E = Inode::error(P, I"cannot write kind", NULL); return; }
SymbolAnnotation::write_annotations(OUT, P, symb);
@@ -330,13 +201,6 @@ int Inter::Kind::instance_count(inter_symbol *kind_symbol) {
return (int) D->W.instruction[NO_INSTANCES_KIND_IFLD];
}
-int Inter::Kind::constructor(inter_symbol *kind_symbol) {
- if (kind_symbol == NULL) return 0;
- inter_tree_node *D = InterSymbol::definition(kind_symbol);
- if (D == NULL) return 0;
- return (int) D->W.instruction[CONSTRUCTOR_KIND_IFLD];
-}
-
int Inter::Kind::arity(inter_symbol *kind_symbol) {
if (kind_symbol == NULL) return 0;
inter_tree_node *D = InterSymbol::definition(kind_symbol);
@@ -344,21 +208,21 @@ int Inter::Kind::arity(inter_symbol *kind_symbol) {
return D->W.extent - MIN_EXTENT_KIND_IFR;
}
-inter_symbol *Inter::Kind::operand_symbol(inter_symbol *kind_symbol, int i) {
- if (kind_symbol == NULL) return NULL;
+inter_type Inter::Kind::operand_type(inter_symbol *kind_symbol, int i) {
+ if (kind_symbol == NULL) return InterTypes::untyped();
inter_tree_node *D = InterSymbol::definition(kind_symbol);
- if (D == NULL) return NULL;
- if (i >= D->W.extent - MIN_EXTENT_KIND_IFR) return NULL;
- inter_ti CID = D->W.instruction[OPERANDS_KIND_IFLD + i];
+ if (D == NULL) return InterTypes::untyped();
+ if (i >= D->W.extent - MIN_EXTENT_KIND_IFR) return InterTypes::untyped();
+ inter_ti TID = D->W.instruction[OPERANDS_KIND_IFLD + i];
inter_symbols_table *T = InterPackage::scope_of(D);
- return InterSymbolsTable::symbol_from_ID(T, CID);
+ return InterTypes::from_TID(T, TID);
}
-inter_data_type *Inter::Kind::data_type(inter_symbol *kind_symbol) {
- if (kind_symbol == NULL) return unchecked_idt;
+inter_ti Inter::Kind::constructor(inter_symbol *kind_symbol) {
+ if (kind_symbol == NULL) return UNCHECKED_ITCONC;
inter_tree_node *D = InterSymbol::definition(kind_symbol);
- if (D == NULL) return unchecked_idt;
- return Inter::Types::find_by_ID(D->W.instruction[CONSTRUCTOR_KIND_IFLD]);
+ if (D == NULL) return UNCHECKED_ITCONC;
+ return D->W.instruction[CONSTRUCTOR_KIND_IFLD];
}
inter_ti Inter::Kind::next_enumerated_value(inter_symbol *kind_symbol) {
@@ -384,9 +248,9 @@ int Inter::Kind::is(inter_symbol *kind_symbol) {
}
int Inter::Kind::is_a(inter_symbol *K1, inter_symbol *K2) {
- inter_data_type *idt1 = Inter::Kind::data_type(K1);
- inter_data_type *idt2 = Inter::Kind::data_type(K2);
- if ((idt1 == unchecked_idt) || (idt2 == unchecked_idt)) return TRUE;
+ inter_type type1 = InterTypes::from_type_name(K1);
+ inter_type type2 = InterTypes::from_type_name(K2);
+ if ((InterTypes::is_untyped(type1)) || (InterTypes::is_untyped(type2))) return TRUE;
while (K1) {
if (K1 == K2) return TRUE;
K1 = Inter::Kind::super(K1);
diff --git a/inter/bytecode-module/Chapter 4/The Permission Construct.w b/inter/bytecode-module/Chapter 4/The Permission Construct.w
index 2cc867760..fc84510a9 100644
--- a/inter/bytecode-module/Chapter 4/The Permission Construct.w
+++ b/inter/bytecode-module/Chapter 4/The Permission Construct.w
@@ -39,7 +39,7 @@ void Inter::Permission::read(inter_construct *IC, inter_bookmark *IBM, inter_lin
if (*E) return;
if (Inter::Kind::is(owner_name)) {
- if (Inter::Types::is_enumerated(Inter::Kind::data_type(owner_name)) == FALSE)
+ if (InterTypes::is_enumerated(InterTypes::from_type_name(owner_name)) == FALSE)
{ *E = Inter::Errors::quoted(I"not a kind which can have property values", ilp->mr.exp[1], eloc); return; }
inter_node_list *FL =
@@ -111,7 +111,7 @@ void Inter::Permission::verify(inter_construct *IC, inter_tree_node *P, inter_pa
inter_node_list *FL = NULL;
if (Inter::Kind::is(owner_name)) {
- if (Inter::Types::is_enumerated(Inter::Kind::data_type(owner_name)) == FALSE)
+ if (InterTypes::is_enumerated(InterTypes::from_type_name(owner_name)) == FALSE)
{ *E = Inode::error(P, I"property permission for non-enumerated kind", NULL); return; }
FL = Inode::ID_to_frame_list(P, Inter::Kind::permissions_list(owner_name));
if (FL == NULL) internal_error("no permissions list");
diff --git a/inter/bytecode-module/Chapter 4/The Property Construct.w b/inter/bytecode-module/Chapter 4/The Property Construct.w
index 4d6d86a28..bff5a2ca4 100644
--- a/inter/bytecode-module/Chapter 4/The Property Construct.w
+++ b/inter/bytecode-module/Chapter 4/The Property Construct.w
@@ -37,7 +37,7 @@ void Inter::Property::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
name_text = mr2.exp[1];
}
- inter_type prop_type = Inter::Types::parse(InterBookmark::scope(IBM), eloc, kind_text, E);
+ inter_type prop_type = InterTypes::parse_simple(InterBookmark::scope(IBM), eloc, kind_text, E);
if (*E) return;
inter_symbol *prop_name = TextualInter::new_symbol(eloc, InterBookmark::scope(IBM), name_text, E);
@@ -51,7 +51,7 @@ void Inter::Property::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
inter_error_message *Inter::Property::new(inter_bookmark *IBM, inter_ti PID, inter_type prop_type, inter_ti level, inter_error_location *eloc) {
inter_warehouse *warehouse = InterBookmark::warehouse(IBM);
inter_ti L1 = InterWarehouse::create_node_list(warehouse, InterBookmark::package(IBM));
- inter_tree_node *P = Inode::new_with_3_data_fields(IBM, PROPERTY_IST, PID, Inter::Types::to_TID(IBM, prop_type), L1, eloc, level);
+ inter_tree_node *P = Inode::new_with_3_data_fields(IBM, PROPERTY_IST, PID, InterTypes::to_TID_wrt_bookmark(IBM, prop_type), L1, eloc, level);
inter_error_message *E = InterConstruct::verify_construct(InterBookmark::package(IBM), P);
if (E) return E;
NodePlacement::move_to_moving_bookmark(P, IBM);
@@ -65,7 +65,7 @@ void Inter::Property::transpose(inter_construct *IC, inter_tree_node *P, inter_t
void Inter::Property::verify(inter_construct *IC, inter_tree_node *P, inter_package *owner, inter_error_message **E) {
if (P->W.extent != EXTENT_PROP_IFR) { *E = Inode::error(P, I"extent wrong", NULL); return; }
*E = Inter::Verify::defn(owner, P, DEFN_PROP_IFLD); if (*E) return;
- Inter::Types::verify_type_field(owner, P, KIND_PROP_IFLD, -1, E);
+ Inter::Verify::typed_data(owner, P, KIND_PROP_IFLD, -1, E);
}
inter_ti Inter::Property::permissions_list(inter_symbol *prop_name) {
@@ -79,16 +79,16 @@ void Inter::Property::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node
inter_symbol *prop_name = InterSymbolsTable::symbol_from_ID_at_node(P, DEFN_PROP_IFLD);
if (prop_name) {
WRITE("property ");
- Inter::Types::write_type_field(OUT, P, KIND_PROP_IFLD);
+ InterTypes::write_optional_type_marker(OUT, P, KIND_PROP_IFLD);
WRITE("%S", InterSymbol::identifier(prop_name));
SymbolAnnotation::write_annotations(OUT, P, prop_name);
} else { *E = Inode::error(P, I"cannot write property", NULL); return; }
}
inter_type Inter::Property::type_of(inter_symbol *prop_symbol) {
- if (prop_symbol == NULL) return Inter::Types::untyped();
+ if (prop_symbol == NULL) return InterTypes::untyped();
inter_tree_node *D = InterSymbol::definition(prop_symbol);
- if (D == NULL) return Inter::Types::untyped();
- if (D->W.instruction[ID_IFLD] != PROPERTY_IST) return Inter::Types::untyped();
- return Inter::Types::from_TID(D, KIND_PROP_IFLD);
+ if (D == NULL) return InterTypes::untyped();
+ if (D->W.instruction[ID_IFLD] != PROPERTY_IST) return InterTypes::untyped();
+ return InterTypes::from_TID_in_field(D, KIND_PROP_IFLD);
}
diff --git a/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w b/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w
index 3c931f34f..68cd81b86 100644
--- a/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w
+++ b/inter/bytecode-module/Chapter 4/The PropertyValue Construct.w
@@ -53,7 +53,7 @@ void Inter::PropertyValue::read(inter_construct *IC, inter_bookmark *IBM, inter_
inter_type val_type = Inter::Property::type_of(prop_name);
inter_ti con_val1 = 0;
inter_ti con_val2 = 0;
- *E = Inter::Types::read_data_pair(ilp->line, eloc, IBM, val_type, ilp->mr.exp[2], &con_val1, &con_val2, InterBookmark::scope(IBM));
+ *E = InterValuePairs::parse(ilp->line, eloc, IBM, val_type, ilp->mr.exp[2], &con_val1, &con_val2, InterBookmark::scope(IBM));
if (*E) return;
*E = Inter::PropertyValue::new(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, prop_name), InterSymbolsTable::id_from_symbol_at_bookmark(IBM, owner_name),
@@ -148,6 +148,6 @@ void Inter::PropertyValue::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_
inter_symbol *owner_name = InterSymbolsTable::symbol_from_ID_at_node(P, OWNER_PVAL_IFLD);
if ((prop_name) && (owner_name)) {
WRITE("propertyvalue %S %S = ", InterSymbol::identifier(prop_name), InterSymbol::identifier(owner_name));
- Inter::Types::write_pair(OUT, P, P->W.instruction[DVAL1_PVAL_IFLD], P->W.instruction[DVAL2_PVAL_IFLD], InterPackage::scope_of(P), FALSE);
+ InterValuePairs::write(OUT, P, P->W.instruction[DVAL1_PVAL_IFLD], P->W.instruction[DVAL2_PVAL_IFLD], InterPackage::scope_of(P), FALSE);
} else { *E = Inode::error(P, I"cannot write propertyvalue", NULL); return; }
}
diff --git a/inter/bytecode-module/Chapter 4/The Variable Construct.w b/inter/bytecode-module/Chapter 4/The Variable Construct.w
index 70392f081..90e052314 100644
--- a/inter/bytecode-module/Chapter 4/The Variable Construct.w
+++ b/inter/bytecode-module/Chapter 4/The Variable Construct.w
@@ -37,7 +37,7 @@ void Inter::Variable::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
name_text = mr2.exp[1];
}
- inter_type var_type = Inter::Types::parse(InterBookmark::scope(IBM), eloc, kind_text, E);
+ inter_type var_type = InterTypes::parse_simple(InterBookmark::scope(IBM), eloc, kind_text, E);
if (*E) return;
inter_symbol *var_name = TextualInter::new_symbol(eloc, InterBookmark::scope(IBM), name_text, E);
@@ -47,14 +47,14 @@ void Inter::Variable::read(inter_construct *IC, inter_bookmark *IBM, inter_line_
inter_ti var_val1 = 0;
inter_ti var_val2 = 0;
- *E = Inter::Types::read_data_pair(ilp->line, eloc, IBM, var_type, ilp->mr.exp[1], &var_val1, &var_val2, InterBookmark::scope(IBM));
+ *E = InterValuePairs::parse(ilp->line, eloc, IBM, var_type, ilp->mr.exp[1], &var_val1, &var_val2, InterBookmark::scope(IBM));
if (*E) return;
*E = Inter::Variable::new(IBM, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, var_name), var_type, var_val1, var_val2, (inter_ti) ilp->indent_level, eloc);
}
inter_error_message *Inter::Variable::new(inter_bookmark *IBM, inter_ti VID, inter_type var_type, inter_ti var_val1, inter_ti var_val2, inter_ti level, inter_error_location *eloc) {
- inter_tree_node *P = Inode::new_with_4_data_fields(IBM, VARIABLE_IST, VID, Inter::Types::to_TID(IBM, var_type), var_val1, var_val2, eloc, level);
+ inter_tree_node *P = Inode::new_with_4_data_fields(IBM, VARIABLE_IST, VID, InterTypes::to_TID_wrt_bookmark(IBM, var_type), var_val1, var_val2, eloc, level);
inter_error_message *E = InterConstruct::verify_construct(InterBookmark::package(IBM), P);
if (E) return E;
NodePlacement::move_to_moving_bookmark(P, IBM);
@@ -64,24 +64,24 @@ inter_error_message *Inter::Variable::new(inter_bookmark *IBM, inter_ti VID, int
void Inter::Variable::verify(inter_construct *IC, inter_tree_node *P, inter_package *owner, inter_error_message **E) {
if (P->W.extent != EXTENT_VAR_IFR) { *E = Inode::error(P, I"extent wrong", NULL); return; }
*E = Inter::Verify::defn(owner, P, DEFN_VAR_IFLD); if (*E) return;
- Inter::Types::verify_type_field(owner, P, KIND_VAR_IFLD, VAL1_VAR_IFLD, E);
+ Inter::Verify::typed_data(owner, P, KIND_VAR_IFLD, VAL1_VAR_IFLD, E);
}
void Inter::Variable::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
inter_symbol *var_name = InterSymbolsTable::symbol_from_ID_at_node(P, DEFN_VAR_IFLD);
if (var_name) {
WRITE("variable ");
- Inter::Types::write_type_field(OUT, P, KIND_VAR_IFLD);
+ InterTypes::write_optional_type_marker(OUT, P, KIND_VAR_IFLD);
WRITE("%S = ", InterSymbol::identifier(var_name));
- Inter::Types::write_pair(OUT, P, P->W.instruction[VAL1_VAR_IFLD], P->W.instruction[VAL2_VAR_IFLD], InterPackage::scope_of(P), FALSE);
+ InterValuePairs::write(OUT, P, P->W.instruction[VAL1_VAR_IFLD], P->W.instruction[VAL2_VAR_IFLD], InterPackage::scope_of(P), FALSE);
SymbolAnnotation::write_annotations(OUT, P, var_name);
} else { *E = Inode::error(P, I"cannot write variable", NULL); return; }
}
inter_type Inter::Variable::type_of(inter_symbol *con_symbol) {
- if (con_symbol == NULL) return Inter::Types::untyped();
+ if (con_symbol == NULL) return InterTypes::untyped();
inter_tree_node *D = InterSymbol::definition(con_symbol);
- if (D == NULL) return Inter::Types::untyped();
- if (D->W.instruction[ID_IFLD] != VARIABLE_IST) return Inter::Types::untyped();
- return Inter::Types::from_TID(D, KIND_VAR_IFLD);
+ if (D == NULL) return InterTypes::untyped();
+ if (D->W.instruction[ID_IFLD] != VARIABLE_IST) return InterTypes::untyped();
+ return InterTypes::from_TID_in_field(D, KIND_VAR_IFLD);
}
diff --git a/inter/bytecode-module/Chapter 5/The Cast Construct.w b/inter/bytecode-module/Chapter 5/The Cast Construct.w
index 1f2d38e04..c7295086c 100644
--- a/inter/bytecode-module/Chapter 5/The Cast Construct.w
+++ b/inter/bytecode-module/Chapter 5/The Cast Construct.w
@@ -54,8 +54,8 @@ inter_error_message *Inter::Cast::new(inter_bookmark *IBM, inter_symbol *from_ki
void Inter::Cast::verify(inter_construct *IC, inter_tree_node *P, inter_package *owner, inter_error_message **E) {
if (P->W.extent != EXTENT_CAST_IFR) { *E = Inode::error(P, I"extent wrong", NULL); return; }
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[TO_KIND_CAST_IFLD], KIND_IST); if (*E) return;
- *E = Inter::Verify::symbol(owner, P, P->W.instruction[FROM_KIND_CAST_IFLD], KIND_IST); if (*E) return;
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[TO_KIND_CAST_IFLD]); if (*E) return;
+ *E = Inter::Verify::TID(owner, P, P->W.instruction[FROM_KIND_CAST_IFLD]); if (*E) return;
}
void Inter::Cast::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
diff --git a/inter/bytecode-module/Chapter 5/The Local Construct.w b/inter/bytecode-module/Chapter 5/The Local Construct.w
index d602847d1..1a9bdd9f1 100644
--- a/inter/bytecode-module/Chapter 5/The Local Construct.w
+++ b/inter/bytecode-module/Chapter 5/The Local Construct.w
@@ -40,7 +40,7 @@ void Inter::Local::read(inter_construct *IC, inter_bookmark *IBM, inter_line_par
name_text = mr2.exp[1];
}
- inter_type var_type = Inter::Types::parse(InterBookmark::scope(IBM), eloc, kind_text, E);
+ inter_type var_type = InterTypes::parse_simple(InterBookmark::scope(IBM), eloc, kind_text, E);
if (*E) return;
inter_symbol *var_name = TextualInter::new_symbol(eloc, locals, name_text, E);
@@ -54,7 +54,7 @@ void Inter::Local::read(inter_construct *IC, inter_bookmark *IBM, inter_line_par
inter_error_message *Inter::Local::new(inter_bookmark *IBM, inter_symbol *var_name,
inter_type var_type, inter_ti level, inter_error_location *eloc) {
- inter_tree_node *P = Inode::new_with_3_data_fields(IBM, LOCAL_IST, 0, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, var_name), Inter::Types::to_TID(IBM, var_type), eloc, level);
+ inter_tree_node *P = Inode::new_with_3_data_fields(IBM, LOCAL_IST, 0, InterSymbolsTable::id_from_symbol_at_bookmark(IBM, var_name), InterTypes::to_TID_wrt_bookmark(IBM, var_type), eloc, level);
inter_error_message *E = InterConstruct::verify_construct(InterBookmark::package(IBM), P); if (E) return E;
NodePlacement::move_to_moving_bookmark(P, IBM);
return NULL;
@@ -65,7 +65,7 @@ void Inter::Local::verify(inter_construct *IC, inter_tree_node *P, inter_package
inter_symbols_table *locals = InterPackage::scope(owner);
if (locals == NULL) { *E = Inode::error(P, I"no symbols table in function", NULL); return; }
*E = Inter::Verify::local_defn(P, DEFN_LOCAL_IFLD, locals); if (*E) return;
- Inter::Types::verify_type_field(owner, P, KIND_LOCAL_IFLD, -1, E);
+ Inter::Verify::typed_data(owner, P, KIND_LOCAL_IFLD, -1, E);
}
void Inter::Local::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
@@ -73,16 +73,16 @@ void Inter::Local::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P,
inter_symbol *var_name = InterSymbolsTable::symbol_from_ID_in_package(pack, P->W.instruction[DEFN_LOCAL_IFLD]);
if (var_name) {
WRITE("local ");
- Inter::Types::write_type_field(OUT, P, KIND_LOCAL_IFLD);
+ InterTypes::write_optional_type_marker(OUT, P, KIND_LOCAL_IFLD);
WRITE("%S", InterSymbol::identifier(var_name));
SymbolAnnotation::write_annotations(OUT, P, var_name);
} else { *E = Inode::error(P, I"cannot write local", NULL); return; }
}
inter_type Inter::Local::type_of(inter_symbol *con_symbol) {
- if (con_symbol == NULL) return Inter::Types::untyped();
+ if (con_symbol == NULL) return InterTypes::untyped();
inter_tree_node *D = InterSymbol::definition(con_symbol);
- if (D == NULL) return Inter::Types::untyped();
- if (D->W.instruction[ID_IFLD] != LOCAL_IST) return Inter::Types::untyped();
- return Inter::Types::from_TID(D, KIND_LOCAL_IFLD);
+ if (D == NULL) return InterTypes::untyped();
+ if (D->W.instruction[ID_IFLD] != LOCAL_IST) return InterTypes::untyped();
+ return InterTypes::from_TID_in_field(D, KIND_LOCAL_IFLD);
}
diff --git a/inter/bytecode-module/Chapter 5/The Ref Construct.w b/inter/bytecode-module/Chapter 5/The Ref Construct.w
index 98cc6aa56..2222fd836 100644
--- a/inter/bytecode-module/Chapter 5/The Ref Construct.w
+++ b/inter/bytecode-module/Chapter 5/The Ref Construct.w
@@ -45,19 +45,19 @@ void Inter::Ref::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse
value_text = mr2.exp[1];
}
- inter_type ref_type = Inter::Types::parse(InterBookmark::scope(IBM), eloc, kind_text, E);
+ inter_type ref_type = InterTypes::parse_simple(InterBookmark::scope(IBM), eloc, kind_text, E);
if (*E) return;
inter_ti var_val1 = 0;
inter_ti var_val2 = 0;
- *E = Inter::Types::read_data_pair(ilp->line, eloc, IBM, ref_type, value_text, &var_val1, &var_val2, locals);
+ *E = InterValuePairs::parse(ilp->line, eloc, IBM, ref_type, value_text, &var_val1, &var_val2, locals);
if (*E) return;
*E = Inter::Ref::new(IBM, ref_type, ilp->indent_level, var_val1, var_val2, eloc);
}
inter_error_message *Inter::Ref::new(inter_bookmark *IBM, inter_type ref_type, int level, inter_ti val1, inter_ti val2, inter_error_location *eloc) {
- inter_tree_node *P = Inode::new_with_4_data_fields(IBM, REF_IST, 0, Inter::Types::to_TID(IBM, ref_type), val1, val2, eloc, (inter_ti) level);
+ inter_tree_node *P = Inode::new_with_4_data_fields(IBM, REF_IST, 0, InterTypes::to_TID_wrt_bookmark(IBM, ref_type), val1, val2, eloc, (inter_ti) level);
inter_error_message *E = InterConstruct::verify_construct(InterBookmark::package(IBM), P); if (E) return E;
NodePlacement::move_to_moving_bookmark(P, IBM);
return NULL;
@@ -65,7 +65,7 @@ inter_error_message *Inter::Ref::new(inter_bookmark *IBM, inter_type ref_type, i
void Inter::Ref::verify(inter_construct *IC, inter_tree_node *P, inter_package *owner, inter_error_message **E) {
if (P->W.extent != EXTENT_REF_IFR) { *E = Inode::error(P, I"extent wrong", NULL); return; }
- Inter::Types::verify_type_field(owner, P, KIND_REF_IFLD, VAL1_REF_IFLD, E);
+ Inter::Verify::typed_data(owner, P, KIND_REF_IFLD, VAL1_REF_IFLD, E);
}
void Inter::Ref::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
@@ -73,6 +73,6 @@ void Inter::Ref::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, i
inter_symbols_table *locals = InterPackage::scope(pack);
if (locals == NULL) { *E = Inode::error(P, I"function has no symbols table", NULL); return; }
WRITE("ref ");
- Inter::Types::write_type_field(OUT, P, KIND_REF_IFLD);
- Inter::Types::write_pair(OUT, P, P->W.instruction[VAL1_REF_IFLD], P->W.instruction[VAL2_REF_IFLD], locals, FALSE);
+ InterTypes::write_optional_type_marker(OUT, P, KIND_REF_IFLD);
+ InterValuePairs::write(OUT, P, P->W.instruction[VAL1_REF_IFLD], P->W.instruction[VAL2_REF_IFLD], locals, FALSE);
}
diff --git a/inter/bytecode-module/Chapter 5/The Val Construct.w b/inter/bytecode-module/Chapter 5/The Val Construct.w
index bd1e361b5..79af5f1a7 100644
--- a/inter/bytecode-module/Chapter 5/The Val Construct.w
+++ b/inter/bytecode-module/Chapter 5/The Val Construct.w
@@ -46,7 +46,7 @@ void Inter::Val::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse
value_text = mr2.exp[1];
}
- inter_type val_type = Inter::Types::parse(InterBookmark::scope(IBM), eloc, kind_text, E);
+ inter_type val_type = InterTypes::parse_simple(InterBookmark::scope(IBM), eloc, kind_text, E);
if (*E) return;
inter_ti val1 = 0;
@@ -55,9 +55,9 @@ void Inter::Val::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse
inter_symbol *kind_as_value = TextualInter::find_symbol(IBM, eloc, value_text, KIND_IST, E);
if (kind_as_value) {
*E = NULL;
- Inter::Types::symbol_to_pair(InterBookmark::tree(IBM), InterBookmark::package(IBM), kind_as_value, &val1, &val2);
+ InterValuePairs::from_symbol(InterBookmark::tree(IBM), InterBookmark::package(IBM), kind_as_value, &val1, &val2);
} else {
- *E = Inter::Types::read_data_pair(ilp->line, eloc, IBM, val_type, value_text, &val1, &val2, locals);
+ *E = InterValuePairs::parse(ilp->line, eloc, IBM, val_type, value_text, &val1, &val2, locals);
if (*E) return;
}
@@ -66,25 +66,25 @@ void Inter::Val::read(inter_construct *IC, inter_bookmark *IBM, inter_line_parse
inter_error_message *Inter::Val::new(inter_bookmark *IBM, inter_type val_type,
int level, inter_ti val1, inter_ti val2, inter_error_location *eloc) {
- inter_tree_node *P = Inode::new_with_4_data_fields(IBM, VAL_IST, 0, Inter::Types::to_TID(IBM, val_type), val1, val2, eloc, (inter_ti) level);
+ inter_tree_node *P = Inode::new_with_4_data_fields(IBM, VAL_IST, 0, InterTypes::to_TID_wrt_bookmark(IBM, val_type), val1, val2, eloc, (inter_ti) level);
inter_error_message *E = InterConstruct::verify_construct(InterBookmark::package(IBM), P); if (E) return E;
NodePlacement::move_to_moving_bookmark(P, IBM);
return NULL;
}
void Inter::Val::transpose(inter_construct *IC, inter_tree_node *P, inter_ti *grid, inter_ti grid_extent, inter_error_message **E) {
- P->W.instruction[VAL2_VAL_IFLD] = Inter::Types::transpose_value(P->W.instruction[VAL1_VAL_IFLD], P->W.instruction[VAL2_VAL_IFLD], grid, grid_extent, E);
+ P->W.instruction[VAL2_VAL_IFLD] = InterValuePairs::transpose_value(P->W.instruction[VAL1_VAL_IFLD], P->W.instruction[VAL2_VAL_IFLD], grid, grid_extent, E);
}
void Inter::Val::verify(inter_construct *IC, inter_tree_node *P, inter_package *owner, inter_error_message **E) {
if (P->W.extent != EXTENT_VAL_IFR) { *E = Inode::error(P, I"extent wrong", NULL); return; }
- Inter::Types::verify_type_field(owner, P, KIND_VAL_IFLD, VAL1_VAL_IFLD, E);
+ Inter::Verify::typed_data(owner, P, KIND_VAL_IFLD, VAL1_VAL_IFLD, E);
}
void Inter::Val::write(inter_construct *IC, OUTPUT_STREAM, inter_tree_node *P, inter_error_message **E) {
inter_symbols_table *locals = InterPackage::scope_of(P);
if (locals == NULL) { *E = Inode::error(P, I"function has no symbols table", NULL); return; }
WRITE("val ");
- Inter::Types::write_type_field(OUT, P, KIND_VAL_IFLD);
- Inter::Types::write_pair(OUT, P, P->W.instruction[VAL1_VAL_IFLD], P->W.instruction[VAL2_VAL_IFLD], locals, FALSE);
+ InterTypes::write_optional_type_marker(OUT, P, KIND_VAL_IFLD);
+ InterValuePairs::write(OUT, P, P->W.instruction[VAL1_VAL_IFLD], P->W.instruction[VAL2_VAL_IFLD], locals, FALSE);
}
diff --git a/inter/bytecode-module/Contents.w b/inter/bytecode-module/Contents.w
index d14b07e78..9cc1f3d41 100644
--- a/inter/bytecode-module/Contents.w
+++ b/inter/bytecode-module/Contents.w
@@ -30,6 +30,7 @@ Chapter 3: Their Instructions
Inter in Binary Files
Inter in Text Files
Verifying Inter
+ Inter Value Pairs
Inter Data Types
Metadata
Inter Errors
diff --git a/inter/final-module/Chapter 2/Code Generation.w b/inter/final-module/Chapter 2/Code Generation.w
index 9bc5ed391..016d86fc5 100644
--- a/inter/final-module/Chapter 2/Code Generation.w
+++ b/inter/final-module/Chapter 2/Code Generation.w
@@ -469,7 +469,7 @@ void CodeGen::pair(code_generation *gen, inter_tree_node *P,
text_stream *OUT = CodeGen::current(gen);
if (val1 == LITERAL_IVAL) {
Generators::compile_literal_number(gen, val2, FALSE);
- } else if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ } else if (InterValuePairs::holds_symbol(val1, val2)) {
inter_symbol *s = InterSymbolsTable::symbol_from_data_pair(val1, val2, T);
if (s == NULL) internal_error("bad symbol in Inter pair");
Generators::compile_literal_symbol(gen, s);
diff --git a/inter/final-module/Chapter 2/Vanilla Code.w b/inter/final-module/Chapter 2/Vanilla Code.w
index ab7eb045d..c7918e4ca 100644
--- a/inter/final-module/Chapter 2/Vanilla Code.w
+++ b/inter/final-module/Chapter 2/Vanilla Code.w
@@ -113,7 +113,7 @@ a variable here.
void VanillaCode::val_or_ref(code_generation *gen, inter_tree_node *P, int ref) {
inter_ti val1 = P->W.instruction[VAL1_VAL_IFLD];
inter_ti val2 = P->W.instruction[VAL2_VAL_IFLD];
- if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ if (InterValuePairs::holds_symbol(val1, val2)) {
inter_package *pack = InterPackage::container(P);
inter_symbol *named_s =
InterSymbolsTable::symbol_from_ID_in_package(pack, val2);
diff --git a/inter/final-module/Chapter 2/Vanilla Constants.w b/inter/final-module/Chapter 2/Vanilla Constants.w
index 424479255..b2af35803 100644
--- a/inter/final-module/Chapter 2/Vanilla Constants.w
+++ b/inter/final-module/Chapter 2/Vanilla Constants.w
@@ -198,7 +198,7 @@ void VanillaConstants::definition_value(code_generation *gen, int form,
}
int bracket = TRUE;
if ((P->W.instruction[i] == LITERAL_IVAL) ||
- (Inter::Types::pair_holds_symbol(P->W.instruction[i], P->W.instruction[i+1]))) bracket = FALSE;
+ (InterValuePairs::holds_symbol(P->W.instruction[i], P->W.instruction[i+1]))) bracket = FALSE;
if (bracket) WRITE("(");
CodeGen::pair(gen, P, P->W.instruction[i], P->W.instruction[i+1]);
if (bracket) WRITE(")");
diff --git a/inter/final-module/Chapter 2/Vanilla Functions.w b/inter/final-module/Chapter 2/Vanilla Functions.w
index 19ff08a33..ff1715407 100644
--- a/inter/final-module/Chapter 2/Vanilla Functions.w
+++ b/inter/final-module/Chapter 2/Vanilla Functions.w
@@ -147,7 +147,7 @@ void VanillaFunctions::invoke_function(code_generation *gen, inter_symbol *fn_s,
(D->W.instruction[FORMAT_CONST_IFLD] == CONSTANT_DIRECT)) {
inter_ti val1 = D->W.instruction[DATA_CONST_IFLD];
inter_ti val2 = D->W.instruction[DATA_CONST_IFLD + 1];
- if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ if (InterValuePairs::holds_symbol(val1, val2)) {
inter_symbol *S = InterSymbolsTable::symbol_from_data_pair(
val1, val2, InterPackage::scope_of(D));
if (S) fn_s = S;
diff --git a/inter/final-module/Chapter 2/Vanilla IF.w b/inter/final-module/Chapter 2/Vanilla IF.w
index b28e018b0..b114f3964 100644
--- a/inter/final-module/Chapter 2/Vanilla IF.w
+++ b/inter/final-module/Chapter 2/Vanilla IF.w
@@ -424,7 +424,7 @@ The opening byte gives some metadata bits, and then there's a word.
@ =
inter_symbol *VanillaIF::get_symbol(code_generation *gen, inter_tree_node *P,
inter_ti val1, inter_ti val2) {
- if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ if (InterValuePairs::holds_symbol(val1, val2)) {
inter_symbol *S =
InterSymbolsTable::symbol_from_data_pair(val1, val2,
InterPackage::scope_of(P));
diff --git a/inter/final-module/Chapter 2/Vanilla Objects.w b/inter/final-module/Chapter 2/Vanilla Objects.w
index 6b10f77ee..d21e92f32 100644
--- a/inter/final-module/Chapter 2/Vanilla Objects.w
+++ b/inter/final-module/Chapter 2/Vanilla Objects.w
@@ -514,7 +514,7 @@ int VanillaObjects::is_kind_of_object(code_generation *gen, inter_symbol *kind_s
inter_symbol *object_kind = RunningPipelines::get_symbol(gen->from_step, object_kind_RPSYM);
if (object_kind == NULL) return FALSE;
if (kind_s == object_kind) return FALSE;
- if (Inter::Kind::data_type(kind_s) == unchecked_idt) return FALSE;
+ if (InterTypes::is_untyped(InterTypes::from_type_name(kind_s))) return FALSE;
if (Inter::Kind::is_a(kind_s, object_kind)) return TRUE;
return FALSE;
}
diff --git a/inter/final-module/Chapter 4/Inform 6 Code.w b/inter/final-module/Chapter 4/Inform 6 Code.w
index 65e3ba545..40e641f52 100644
--- a/inter/final-module/Chapter 4/Inform 6 Code.w
+++ b/inter/final-module/Chapter 4/Inform 6 Code.w
@@ -752,7 +752,7 @@ text_stream *I6TargetCode::inner_name(code_generation *gen, inter_tree_node *pro
if (prop_node->W.instruction[ID_IFLD] == VAL_IST) {
inter_ti val1 = prop_node->W.instruction[VAL1_VAL_IFLD];
inter_ti val2 = prop_node->W.instruction[VAL2_VAL_IFLD];
- if (Inter::Types::pair_holds_symbol(val1, val2))
+ if (InterValuePairs::holds_symbol(val1, val2))
prop_symbol =
InterSymbolsTable::symbol_from_ID(InterPackage::scope_of(prop_node), val2);
}
@@ -792,7 +792,7 @@ int I6TargetCode::pval_case_inner(inter_tree_node *kind_node, inter_tree_node *p
if (kind_node->W.instruction[ID_IFLD] == VAL_IST) {
inter_ti val1 = kind_node->W.instruction[VAL1_VAL_IFLD];
inter_ti val2 = kind_node->W.instruction[VAL2_VAL_IFLD];
- if (Inter::Types::pair_holds_symbol(val1, val2))
+ if (InterValuePairs::holds_symbol(val1, val2))
kind_symbol =
InterSymbolsTable::symbol_from_ID(InterPackage::scope_of(kind_node), val2);
}
@@ -803,7 +803,7 @@ int I6TargetCode::pval_case_inner(inter_tree_node *kind_node, inter_tree_node *p
if (prop_node->W.instruction[ID_IFLD] == VAL_IST) {
inter_ti val1 = prop_node->W.instruction[VAL1_VAL_IFLD];
inter_ti val2 = prop_node->W.instruction[VAL2_VAL_IFLD];
- if (Inter::Types::pair_holds_symbol(val1, val2))
+ if (InterValuePairs::holds_symbol(val1, val2))
prop_symbol =
InterSymbolsTable::symbol_from_ID(InterPackage::scope_of(prop_node), val2);
}
diff --git a/inter/final-module/Chapter 4/Inform 6 Constants.w b/inter/final-module/Chapter 4/Inform 6 Constants.w
index 3884e4b8b..2beed58be 100644
--- a/inter/final-module/Chapter 4/Inform 6 Constants.w
+++ b/inter/final-module/Chapter 4/Inform 6 Constants.w
@@ -145,7 +145,7 @@ they were any other arrays. Here goes:
for (int i=DATA_CONST_IFLD; iW.extent; i=i+2) {
WRITE(" ");
inter_ti val1 = P->W.instruction[i], val2 = P->W.instruction[i+1];
- if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ if (InterValuePairs::holds_symbol(val1, val2)) {
inter_symbol *A = InterSymbolsTable::symbol_from_data_pair(
val1, val2, InterPackage::scope_of(P));
if (A == NULL) internal_error("bad aliased symbol");
diff --git a/inter/final-module/Chapter 4/Inform 6 Objects.w b/inter/final-module/Chapter 4/Inform 6 Objects.w
index e887affee..e869d1720 100644
--- a/inter/final-module/Chapter 4/Inform 6 Objects.w
+++ b/inter/final-module/Chapter 4/Inform 6 Objects.w
@@ -409,7 +409,7 @@ void I6TargetObjects::assign_property(code_generator *gtr, code_generation *gen,
TEMPORARY_TEXT(val)
CodeGen::select_temporary(gen, val);
int inline_this = FALSE;
- if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ if (InterValuePairs::holds_symbol(val1, val2)) {
inter_symbol *S = InterSymbolsTable::symbol_from_data_pair_at_node(val1, val2, X);
if ((S) && (SymbolAnnotation::get_b(S, INLINE_ARRAY_IANN))) {
inter_tree_node *P = InterSymbol::definition(S);
diff --git a/inter/final-module/Chapter 5/C Object Model.w b/inter/final-module/Chapter 5/C Object Model.w
index 2beb5f615..f4e3a53cf 100644
--- a/inter/final-module/Chapter 5/C Object Model.w
+++ b/inter/final-module/Chapter 5/C Object Model.w
@@ -544,7 +544,7 @@ void CObjectModel::assign_property(code_generator *gtr, code_generation *gen,
inter_symbol *prop_name, inter_ti val1, inter_ti val2, inter_tree_node *X) {
int inline_this = FALSE;
- if (Inter::Types::pair_holds_symbol(val1, val2)) {
+ if (InterValuePairs::holds_symbol(val1, val2)) {
inter_symbol *S = InterSymbolsTable::symbol_from_data_pair_at_node(val1, val2, X);
if ((S) && (SymbolAnnotation::get_b(S, INLINE_ARRAY_IANN)))
inline_this = TRUE;
diff --git a/inter/pipeline-module/Chapter 2/New Stage.w b/inter/pipeline-module/Chapter 2/New Stage.w
index 3d4cb7566..fd03048f9 100644
--- a/inter/pipeline-module/Chapter 2/New Stage.w
+++ b/inter/pipeline-module/Chapter 2/New Stage.w
@@ -70,7 +70,7 @@ base data type matches this".
InterBookmark::scope(&in_generic_kinds), I"K_unchecked");
Inter::Kind::new(&in_generic_kinds,
InterSymbolsTable::id_from_symbol(I, generic_kinds_p, unchecked_kind_symbol),
- UNCHECKED_IDT, 0, 0, NULL,
+ UNCHECKED_ITCONC, 0, 0, NULL,
(inter_ti) InterBookmark::baseline(&in_generic_kinds) + 1, NULL);
@ And this expresses the idea of "any sort of function":
@@ -86,7 +86,7 @@ base data type matches this".
InterBookmark::scope(&in_generic_kinds), I"K_unchecked_function");
Inter::Kind::new(&in_generic_kinds,
InterSymbolsTable::id_from_symbol(I, generic_kinds_p, unchecked_function_symbol),
- FUNCTION_IDT, 0, 2, operands,
+ FUNCTION_ITCONC, 0, 2, operands,
(inter_ti) InterBookmark::baseline(&in_generic_kinds) + 1, NULL);
@ And "any sort of list":
@@ -102,7 +102,7 @@ base data type matches this".
InterBookmark::scope(&in_generic_kinds), I"K_unchecked_list");
Inter::Kind::new(&in_generic_kinds,
InterSymbolsTable::id_from_symbol(I, generic_kinds_p, unchecked_list_symbol),
- LIST_IDT, 0, 1, operands,
+ LIST_ITCONC, 0, 1, operands,
(inter_ti) InterBookmark::baseline(&in_generic_kinds) + 1, NULL);
@ It's safe to say that we are likely to need these, too. (Note that they do not
@@ -115,7 +115,7 @@ end up being basically the same thing.)
InterBookmark::scope(&in_generic_kinds), I"K_int32");
Inter::Kind::new(&in_generic_kinds,
InterSymbolsTable::id_from_symbol(I, generic_kinds_p, integer_kind_symbol),
- INT32_IDT, 0, 0, NULL,
+ INT32_ITCONC, 0, 0, NULL,
(inter_ti) InterBookmark::baseline(&in_generic_kinds) + 1, NULL);
@ =
@@ -124,7 +124,7 @@ end up being basically the same thing.)
InterBookmark::scope(&in_generic_kinds), I"K_int2");
Inter::Kind::new(&in_generic_kinds,
InterSymbolsTable::id_from_symbol(I, generic_kinds_p, boolean_kind_symbol),
- INT2_IDT, 0, 0, NULL,
+ INT2_ITCONC, 0, 0, NULL,
(inter_ti) InterBookmark::baseline(&in_generic_kinds) + 1, NULL);
@ =
@@ -133,5 +133,5 @@ end up being basically the same thing.)
InterBookmark::scope(&in_generic_kinds), I"K_string");
Inter::Kind::new(&in_generic_kinds,
InterSymbolsTable::id_from_symbol(I, generic_kinds_p, string_kind_symbol),
- TEXT_IDT, 0, 0, NULL,
+ TEXT_ITCONC, 0, 0, NULL,
(inter_ti) InterBookmark::baseline(&in_generic_kinds) + 1, NULL);
diff --git a/inter/pipeline-module/Chapter 3/Compile Splats Stage.w b/inter/pipeline-module/Chapter 3/Compile Splats Stage.w
index 8bcd0e025..0e8ba4a2c 100644
--- a/inter/pipeline-module/Chapter 3/Compile Splats Stage.w
+++ b/inter/pipeline-module/Chapter 3/Compile Splats Stage.w
@@ -361,18 +361,18 @@ not already there.
inter_ti B = (inter_ti) InterBookmark::baseline(IBM) + 1;
inter_ti v1 = 0, v2 = 0;
@;
- Produce::guard(Inter::Variable::new(IBM, MID, Inter::Types::untyped(), v1, v2, B, NULL));
+ Produce::guard(Inter::Variable::new(IBM, MID, InterTypes::untyped(), v1, v2, B, NULL));
@ =
inter_ti MID = InterSymbolsTable::id_from_symbol(I, InterBookmark::package(IBM), made_s);
inter_ti B = (inter_ti) InterBookmark::baseline(IBM) + 1;
- Produce::guard(Inter::Property::new(IBM, MID, Inter::Types::untyped(), B, NULL));
+ Produce::guard(Inter::Property::new(IBM, MID, InterTypes::untyped(), B, NULL));
@ =
inter_ti MID = InterSymbolsTable::id_from_symbol(I, InterBookmark::package(IBM), made_s);
inter_ti B = (inter_ti) InterBookmark::baseline(IBM) + 1;
Produce::guard(Inter::Property::new(IBM, MID,
- Inter::Types::from_symbol(RunningPipelines::get_symbol(step, truth_state_kind_RPSYM)),
+ InterTypes::from_type_name(RunningPipelines::get_symbol(step, truth_state_kind_RPSYM)),
B, NULL));
@ A typical Inform 6 array declaration looks like this:
@@ -713,7 +713,7 @@ These have package types |_function| and |_code| respectively.
InterSymbolsTable::create_with_unique_name(InterPackage::scope(IP), value);
InterSymbol::make_local(loc_name);
inter_ti B = (inter_ti) InterBookmark::baseline(IBM) + 1;
- Produce::guard(Inter::Local::new(IBM, loc_name, Inter::Types::untyped(), B, NULL));
+ Produce::guard(Inter::Local::new(IBM, loc_name, InterTypes::untyped(), B, NULL));
DISCARD_TEXT(value)
}
@@ -924,59 +924,59 @@ void CompileSplatsStage::value(pipeline_step *step, inter_bookmark *IBM, text_st
@ =
if (Str::eq(S, I"*")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_divider_RPSYM, I"VERB_DIRECTIVE_DIVIDER"), val1, val2); return;
}
if (Str::eq(S, I"->")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_result_RPSYM, I"VERB_DIRECTIVE_RESULT"), val1, val2); return;
}
if (Str::eq(S, I"reverse")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_reverse_RPSYM, I"VERB_DIRECTIVE_REVERSE"), val1, val2); return;
}
if (Str::eq(S, I"/")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_slash_RPSYM, I"VERB_DIRECTIVE_SLASH"), val1, val2); return;
}
if (Str::eq(S, I"special")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_special_RPSYM, I"VERB_DIRECTIVE_SPECIAL"), val1, val2); return;
}
if (Str::eq(S, I"number")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_number_RPSYM, I"VERB_DIRECTIVE_NUMBER"), val1, val2); return;
}
if (Str::eq(S, I"noun")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_noun_RPSYM, I"VERB_DIRECTIVE_NOUN"), val1, val2); return;
}
if (Str::eq(S, I"multi")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_multi_RPSYM, I"VERB_DIRECTIVE_MULTI"), val1, val2); return;
}
if (Str::eq(S, I"multiinside")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_multiinside_RPSYM, I"VERB_DIRECTIVE_MULTIINSIDE"), val1, val2); return;
}
if (Str::eq(S, I"multiheld")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_multiheld_RPSYM, I"VERB_DIRECTIVE_MULTIHELD"), val1, val2); return;
}
if (Str::eq(S, I"held")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_held_RPSYM, I"VERB_DIRECTIVE_HELD"), val1, val2); return;
}
if (Str::eq(S, I"creature")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_creature_RPSYM, I"VERB_DIRECTIVE_CREATURE"), val1, val2); return;
}
if (Str::eq(S, I"topic")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_topic_RPSYM, I"VERB_DIRECTIVE_TOPIC"), val1, val2); return;
}
if (Str::eq(S, I"multiexcept")) {
- Inter::Types::symbol_to_pair(I, pack, RunningPipelines::ensure_symbol(step,
+ InterValuePairs::from_symbol(I, pack, RunningPipelines::ensure_symbol(step,
verb_directive_multiexcept_RPSYM, I"VERB_DIRECTIVE_MULTIEXCEPT"), val1, val2); return;
}
match_results mr = Regexp::create_mr();
@@ -985,7 +985,7 @@ void CompileSplatsStage::value(pipeline_step *step, inter_bookmark *IBM, text_st
if (symb) {
if (SymbolAnnotation::get_b(symb, SCOPE_FILTER_IANN) == FALSE)
SymbolAnnotation::set_b(symb, SCOPE_FILTER_IANN, TRUE);
- Inter::Types::symbol_to_pair(I, pack, symb, val1, val2); return;
+ InterValuePairs::from_symbol(I, pack, symb, val1, val2); return;
}
}
if (Regexp::match(&mr, S, L"noun=(%i+)")) {
@@ -993,14 +993,14 @@ void CompileSplatsStage::value(pipeline_step *step, inter_bookmark *IBM, text_st
if (symb) {
if (SymbolAnnotation::get_b(symb, NOUN_FILTER_IANN) == FALSE)
SymbolAnnotation::set_b(symb, NOUN_FILTER_IANN, TRUE);
- Inter::Types::symbol_to_pair(I, pack, symb, val1, val2); return;
+ InterValuePairs::from_symbol(I, pack, symb, val1, val2); return;
}
}
@ =
inter_symbol *symb = Wiring::find_socket(I, S);
if (symb) {
- Inter::Types::symbol_to_pair(I, pack, symb, val1, val2); return;
+ InterValuePairs::from_symbol(I, pack, symb, val1, val2); return;
}
@ At this point, maybe the reason we haven't yet recognised the constant |S| is
@@ -1030,7 +1030,7 @@ before they are needed.
CompileSplatsStage::compute_r(step, IBM, sch->node_tree);
if (result_s == NULL)
PipelineErrors::kit_error("Inform 6 constant in kit too complex", S);
- Inter::Types::symbol_to_pair(I, pack, result_s, val1, val2);
+ InterValuePairs::from_symbol(I, pack, result_s, val1, val2);
@ So this is the recursion. Note that we calculate $-x$ as $0 - x$, thus
reducing unary subtraction to a case of binary subtraction.
@@ -1102,13 +1102,13 @@ inter_symbol *CompileSplatsStage::compute_binary_op(inter_ti op, pipeline_step *
int pos = pair_list->W.extent;
Inode::extend_instruction_by(pair_list, 4);
if (i1) {
- Inter::Types::symbol_to_pair(I, pack, i1,
+ InterValuePairs::from_symbol(I, pack, i1,
&(pair_list->W.instruction[pos]), &(pair_list->W.instruction[pos+1]));
} else {
pair_list->W.instruction[pos] = LITERAL_IVAL; pair_list->W.instruction[pos+1] = 0;
}
if (i2) {
- Inter::Types::symbol_to_pair(I, pack, i2,
+ InterValuePairs::from_symbol(I, pack, i2,
&(pair_list->W.instruction[pos+2]), &(pair_list->W.instruction[pos+3]));
} else {
pair_list->W.instruction[pos+2] = LITERAL_IVAL; pair_list->W.instruction[pos+3] = 0;
@@ -1139,7 +1139,7 @@ inter_symbol *CompileSplatsStage::compute_eval(pipeline_step *step,
inter_ti v1 = UNDEF_IVAL, v2 = 0;
if (t->constant_number >= 0) {
v1 = LITERAL_IVAL; v2 = (inter_ti) t->constant_number;
- } else if (Inter::Types::read_int_in_I6_notation(t->material, &v1, &v2) == FALSE) {
+ } else if (InterValuePairs::read_int_in_I6_notation(t->material, &v1, &v2) == FALSE) {
return NULL;
}
if (v1 == UNDEF_IVAL) return NULL;
diff --git a/inter/pipeline-module/Chapter 4/Detect Indirect Calls Stage.w b/inter/pipeline-module/Chapter 4/Detect Indirect Calls Stage.w
index ac4056e24..d45bdcb99 100644
--- a/inter/pipeline-module/Chapter 4/Detect Indirect Calls Stage.w
+++ b/inter/pipeline-module/Chapter 4/Detect Indirect Calls Stage.w
@@ -85,7 +85,7 @@ void DetectIndirectCallsStage::traverse_code_tree(inter_tree_node *P, pipeline_s
@ =
inter_bookmark IBM = InterBookmark::first_child_of(F);
inter_ti val1 = 0, val2 = 0;
- Inter::Types::symbol_to_pair(InterBookmark::tree(&IBM),
+ InterValuePairs::from_symbol(InterBookmark::tree(&IBM),
InterBookmark::package(&IBM), var, &val1, &val2);
- Inter::Val::new(&IBM, Inter::Types::untyped(),
+ Inter::Val::new(&IBM, InterTypes::untyped(),
(int) F->W.instruction[LEVEL_IFLD] + 1, val1, val2, NULL);
diff --git a/inter/pipeline-module/Chapter 5/Literal Text.w b/inter/pipeline-module/Chapter 5/Literal Text.w
index 9c12f0fbb..6ab0cfca2 100644
--- a/inter/pipeline-module/Chapter 5/Literal Text.w
+++ b/inter/pipeline-module/Chapter 5/Literal Text.w
@@ -82,7 +82,7 @@ in |texts|.
Wiring::wire_to(ref_s, latest_s);
inter_ti val1 = 0, val2 = 0;
- Inter::Types::symbol_to_pair(I, InterPackage::container(P), ref_s, &val1, &val2);
+ InterValuePairs::from_symbol(I, InterPackage::container(P), ref_s, &val1, &val2);
P->W.instruction[FORMAT_CONST_IFLD] = CONSTANT_DIRECT;
P->W.instruction[DATA_CONST_IFLD] = val1;
P->W.instruction[DATA_CONST_IFLD+1] = val2;
diff --git a/inter/pipeline-module/Chapter 5/Synoptic Utilities.w b/inter/pipeline-module/Chapter 5/Synoptic Utilities.w
index 34c3e4e95..ae0b97929 100644
--- a/inter/pipeline-module/Chapter 5/Synoptic Utilities.w
+++ b/inter/pipeline-module/Chapter 5/Synoptic Utilities.w
@@ -132,7 +132,7 @@ void Synoptic::symbol_entry(inter_symbol *S) {
InterPackage::scope(pack), InterSymbol::identifier(S));
Wiring::wire_to(local_S, S);
inter_ti val1 = 0, val2 = 0;
- Inter::Types::symbol_to_pair(InterPackage::tree(pack), pack, local_S, &val1, &val2);
+ InterValuePairs::from_symbol(InterPackage::tree(pack), pack, local_S, &val1, &val2);
synoptic_array_node->W.instruction[synoptic_array_node->W.extent-2] = ALIAS_IVAL;
synoptic_array_node->W.instruction[synoptic_array_node->W.extent-1] = val2;
}