Skip to content

Commit 6da284d

Browse files
committed
[[ LCB ]] Ensure types are exported in the interface module.
1 parent 2f62098 commit 6da284d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

libscript/src/script-module.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,27 @@ bool MCScriptWriteInterfaceOfModule(MCScriptModuleRef self, MCStreamRef stream)
10881088
switch(t_type -> kind)
10891089
{
10901090
case kMCScriptTypeKindForeign:
1091+
{
10911092
__writeln(stream, "foreign type %@", t_def_name);
1093+
}
1094+
break;
1095+
case kMCScriptTypeKindHandler:
1096+
{
1097+
MCAutoStringRef t_sig;
1098+
type_to_string(self, static_cast<MCScriptTypeDefinition *>(t_def) -> type, &t_sig);
1099+
__writeln(stream, "handler type %@%@", t_def_name, *t_sig);
1100+
}
1101+
break;
1102+
case kMCScriptTypeKindRecord:
1103+
// TODO - Records not yet supported
10921104
break;
1105+
default:
1106+
{
1107+
MCAutoStringRef t_sig;
1108+
type_to_string(self, static_cast<MCScriptTypeDefinition *>(t_def) -> type, &t_sig);
1109+
__writeln(stream, "type %@ is %@", t_def_name, *t_sig);
1110+
}
1111+
break;
10931112
}
10941113
}
10951114
break;

toolchain/lc-compile/src/grammar.g

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@
180180
'rule' ImportDefinition(-> type(Position, public, Id, foreign(Position, ""))):
181181
"foreign" @(-> Position) "type" Identifier(-> Id)
182182
183+
'rule' ImportDefinition(-> type(Position, public, Id, handler(Position, Signature))):
184+
"handler" @(-> Position) "type" Identifier(-> Id) Signature(-> Signature)
185+
186+
'rule' ImportDefinition(-> type(Position, public, Id, Type)):
187+
"type" @(-> Position) Identifier(-> Id) "is" Type(-> Type)
188+
183189
'rule' ImportDefinition(-> constant(Position, public, Id, nil)):
184190
"constant" @(-> Position) Identifier(-> Id)
185191

0 commit comments

Comments
 (0)