Skip to content

Commit c4d38fc

Browse files
author
Nicholas Reed
committed
partial support for aggregate bounds that aren't compile-time constants; SCL git 7425e55
1 parent a96f0c3 commit c4d38fc

6 files changed

Lines changed: 252 additions & 118 deletions

File tree

src/cleditor/SdaiHeaderSchemaInit.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) {
5353
header_section_schemae_file_population->AddExplicitAttr( a_3determination_method );
5454
SetTypeDescriptor * t_0 = new SetTypeDescriptor;
5555
t_0->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function
56-
t_0->Bound1( 1 );
57-
t_0->Bound2( 2147483647 );
56+
t_0->SetBound1( 1 );
57+
t_0->SetBound2( 2147483647 );
5858
t_0->FundamentalType( SET_TYPE );
5959
t_0->Description( "SET [1:?] OF section_name" );
6060
t_0->OriginatingSchema( s_header_section_schema );
@@ -80,8 +80,8 @@ void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) {
8080
header_section_schemae_file_name->AddExplicitAttr( a_6time_stamp );
8181
ListTypeDescriptor * t_1 = new ListTypeDescriptor;
8282
t_1->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function
83-
t_1->Bound1( 1 );
84-
t_1->Bound2( 2147483647 );
83+
t_1->SetBound1( 1 );
84+
t_1->SetBound2( 2147483647 );
8585
t_1->FundamentalType( LIST_TYPE );
8686
t_1->Description( "LIST [1:?] OF STRING (256)" );
8787
t_1->OriginatingSchema( s_header_section_schema );
@@ -92,8 +92,8 @@ void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) {
9292
header_section_schemae_file_name->AddExplicitAttr( a_7author );
9393
ListTypeDescriptor * t_2 = new ListTypeDescriptor;
9494
t_2->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function
95-
t_2->Bound1( 1 );
96-
t_2->Bound2( 2147483647 );
95+
t_2->SetBound1( 1 );
96+
t_2->SetBound2( 2147483647 );
9797
t_2->FundamentalType( LIST_TYPE );
9898
t_2->Description( "LIST [1:?] OF STRING (256)" );
9999
t_2->OriginatingSchema( s_header_section_schema );
@@ -129,8 +129,8 @@ void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) {
129129
header_section_schemae_section_context->AddExplicitAttr( a_12section );
130130
ListTypeDescriptor * t_3 = new ListTypeDescriptor;
131131
t_3->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function
132-
t_3->Bound1( 1 );
133-
t_3->Bound2( 2147483647 );
132+
t_3->SetBound1( 1 );
133+
t_3->SetBound2( 2147483647 );
134134
t_3->FundamentalType( LIST_TYPE );
135135
t_3->Description( "LIST [1:?] OF context_name" );
136136
t_3->OriginatingSchema( s_header_section_schema );
@@ -146,8 +146,8 @@ void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) {
146146

147147
ListTypeDescriptor * t_4 = new ListTypeDescriptor;
148148
t_4->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function
149-
t_4->Bound1( 1 );
150-
t_4->Bound2( 2147483647 );
149+
t_4->SetBound1( 1 );
150+
t_4->SetBound2( 2147483647 );
151151
t_4->FundamentalType( LIST_TYPE );
152152
t_4->Description( "LIST [1:?] OF STRING (256)" );
153153
t_4->OriginatingSchema( s_header_section_schema );
@@ -168,8 +168,8 @@ void SdaiHEADER_SECTION_SCHEMAInit( Registry & reg ) {
168168

169169
ListTypeDescriptor * t_5 = new ListTypeDescriptor;
170170
t_5->AssignAggrCreator( ( AggregateCreator ) create_StringAggregate ); // Creator function
171-
t_5->Bound1( 1 );
172-
t_5->Bound2( 2147483647 );
171+
t_5->SetBound1( 1 );
172+
t_5->SetBound2( 2147483647 );
173173
t_5->UniqueElements( LTrue );
174174
t_5->FundamentalType( LIST_TYPE );
175175
t_5->Description( "LIST [1:?] OF UNIQUE schema_name" );

src/clstepcore/ExpDict.h

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <vector>
1919
#include <string>
20+
#include <assert.h>
2021

2122
typedef SDAI_Application_instance * ( * Creator )();
2223

@@ -27,6 +28,13 @@ enum AttrType_Enum {
2728
AttrType_Redefining
2829
};
2930

31+
enum AggrBoundTypeEnum {
32+
bound_unset = 0,
33+
bound_constant,
34+
bound_runtime,
35+
bound_funcall
36+
};
37+
3038
#include <SingleLinkList.h>
3139

3240
#include <baseType.h>
@@ -1644,28 +1652,32 @@ SCL_CORE_EXPORT RealAggregate * create_RealAggregate();
16441652

16451653
SCL_CORE_EXPORT IntAggregate * create_IntAggregate();
16461654

1647-
///////////////////////////////////////////////////////////////////////////////
1648-
// AggrTypeDescriptor
1649-
// I think we decided on a simplistic representation of aggr. types for now?
1650-
// i.e. just have one AggrTypeDesc for Array of [list of] [set of] someType
1651-
// the inherited variable _referentType will point to the TypeDesc for someType
1652-
// So I don't believe this class was necessary. If we were to retain
1653-
// info for each of the [aggr of]'s in the example above then there would be
1654-
// one of these for each [aggr of] above and they would be strung
1655-
// together by the _aggrDomainType variables. If you can make this
1656-
// work then go for it.
1657-
///////////////////////////////////////////////////////////////////////////////
1658-
1655+
typedef SDAI_Integer (*boundCallbackFn)(SDAI_Application_instance *);
1656+
1657+
/**
1658+
* \class AggrTypeDescriptor
1659+
* I think we decided on a simplistic representation of aggr. types for now?
1660+
* i.e. just have one AggrTypeDesc for Array of [list of] [set of] someType
1661+
* the inherited variable _referentType will point to the TypeDesc for someType
1662+
* So I don't believe this class was necessary. If we were to retain
1663+
* info for each of the [aggr of]'s in the example above then there would be
1664+
* one of these for each [aggr of] above and they would be strung
1665+
* together by the _aggrDomainType variables. If you can make this
1666+
* work then go for it.
1667+
*/
16591668
class SCL_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor {
16601669

16611670
protected:
16621671

1663-
SDAI_Integer _bound1;
1664-
SDAI_Integer _bound2;
1672+
SDAI_Integer _bound1, _bound2;
16651673
SDAI_LOGICAL _uniqueElements;
16661674
TypeDescriptor * _aggrDomainType;
16671675
AggregateCreator CreateNewAggr;
16681676

1677+
AggrBoundTypeEnum _bound1_type, _bound2_type;
1678+
boundCallbackFn _bound1_callback, _bound2_callback;
1679+
std::string _bound1_str, _bound2_str;
1680+
16691681
public:
16701682

16711683
void AssignAggrCreator( AggregateCreator f = 0 ) {
@@ -1685,18 +1697,68 @@ class SCL_CORE_EXPORT AggrTypeDescriptor : public TypeDescriptor {
16851697
virtual ~AggrTypeDescriptor();
16861698

16871699

1688-
SDAI_Integer & Bound1() {
1700+
/// find bound type
1701+
AggrBoundTypeEnum Bound1Type() const { return _bound1_type; };
1702+
/// get a constant bound
1703+
SDAI_Integer Bound1( ) const {
1704+
assert( _bound1_type == bound_constant );
16891705
return _bound1;
16901706
}
1691-
void Bound1( SDAI_Integer b1 ) {
1707+
/// get a runtime bound using an object's 'this' pointer
1708+
SDAI_Integer Bound1Runtime( SDAI_Application_instance* this_ptr) const {
1709+
assert( this_ptr && ( _bound1_type == bound_runtime ) );
1710+
return _bound1_callback(this_ptr) ;
1711+
}
1712+
/// get a bound's EXPRESS function call string
1713+
std::string Bound1Funcall() const {
1714+
return _bound1_str;
1715+
}
1716+
/// set bound to a constant
1717+
void SetBound1( SDAI_Integer b1 ) {
16921718
_bound1 = b1;
1719+
_bound1_type = bound_constant;
1720+
}
1721+
///set bound's callback fn. only for bounds dependent on an attribute
1722+
void SetBound1FromMemberAccessor( boundCallbackFn callback ) {
1723+
_bound1_callback = callback;
1724+
_bound1_type = bound_runtime;
1725+
}
1726+
///set bound from express function call. currently, this only stores the function call as a string.
1727+
void SetBound1FromExpressFuncall( std::string s ) {
1728+
_bound1_str = s;
1729+
_bound1_type = bound_funcall;
16931730
}
16941731

1695-
SDAI_Integer & Bound2() {
1732+
/// find bound type
1733+
AggrBoundTypeEnum Bound2Type() const { return _bound2_type; };
1734+
/// get a constant bound
1735+
SDAI_Integer Bound2( ) const {
1736+
assert( _bound2_type == bound_constant );
16961737
return _bound2;
16971738
}
1698-
void Bound2( SDAI_Integer b2 ) {
1739+
/// get a runtime bound using an object's 'this' pointer
1740+
SDAI_Integer Bound2Runtime( SDAI_Application_instance* this_ptr) const {
1741+
assert( this_ptr && ( _bound2_type == bound_runtime ) );
1742+
return _bound2_callback(this_ptr) ;
1743+
}
1744+
/// get a bound's EXPRESS function call string
1745+
std::string Bound2Funcall() const {
1746+
return _bound2_str;
1747+
}
1748+
/// set bound to a constant
1749+
void SetBound2( SDAI_Integer b2 ) {
16991750
_bound2 = b2;
1751+
_bound2_type = bound_constant;
1752+
}
1753+
///set bound's callback fn
1754+
void SetBound2FromMemberAccessor( boundCallbackFn callback ){
1755+
_bound2_callback = callback;
1756+
_bound2_type = bound_runtime;
1757+
}
1758+
///set bound from express function call. currently, this only stores the function call as a string.
1759+
void SetBound2FromExpressFuncall( std::string s ) {
1760+
_bound2_str = s;
1761+
_bound2_type = bound_funcall;
17001762
}
17011763

17021764
SDAI_LOGICAL & UniqueElements() {

src/express/expr.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -577,12 +577,16 @@ Type EXPresolve_op_group( Expression expr, Scope scope ) {
577577
/* &op2->symbol, op2->symbol.name);*/
578578
return( Type_Runtime );
579579
}
580+
case array_:
581+
if( op1->type->u.type->body->type == self_ ) {
582+
return( Type_Runtime ); //not sure if there are other cases where Type_Runtime should be returned, or not
583+
} // else fallthrough
580584
case unknown_: /* unable to resolve operand */
581585
/* presumably error has already been reported */
582586
resolve_failed( expr );
583587
return( Type_Bad );
584588
case aggregate_:
585-
case array_:
589+
586590
case bag_:
587591
case list_:
588592
case set_:

0 commit comments

Comments
 (0)