- added readonly pointers. They need to be defined with 'readonly<classtype>'. These are significantly different from declaring a field readonly in that they do not disallow modification of the variable itself but what it points to. For the actor defaults this is necessary to prevent accidental modification. A readonly pointer is actually a different type than a regular pointer.
- fixed code generation for dynamic cast. It was missing the jump instruction after the compare.
This commit is contained in:
parent
ca878b5e6b
commit
24925c88a8
7 changed files with 47 additions and 20 deletions
|
|
@ -668,6 +668,7 @@ type_name(X) ::= type_name1(A).
|
|||
NEW_AST_NODE(BasicType, type, A);
|
||||
type->Type = (EZCCBuiltinType)A.Int;
|
||||
type->UserType = NULL;
|
||||
type->isconst = false;
|
||||
X = type;
|
||||
}
|
||||
type_name(X) ::= IDENTIFIER(A). /* User-defined type (struct, enum, or class) */
|
||||
|
|
@ -676,14 +677,27 @@ type_name(X) ::= IDENTIFIER(A). /* User-defined type (struct, enum, or class)
|
|||
NEW_AST_NODE(Identifier, id, A);
|
||||
type->Type = ZCC_UserType;
|
||||
type->UserType = id;
|
||||
type->isconst = false;
|
||||
id->Id = A.Name();
|
||||
X = type;
|
||||
}
|
||||
type_name(X) ::= READONLY LT IDENTIFIER(A) GT.
|
||||
{
|
||||
NEW_AST_NODE(BasicType, type, A);
|
||||
NEW_AST_NODE(Identifier, id, A);
|
||||
type->Type = ZCC_UserType;
|
||||
type->UserType = id;
|
||||
type->isconst = true;
|
||||
id->Id = A.Name();
|
||||
X = type;
|
||||
}
|
||||
|
||||
type_name(X) ::= DOT dottable_id(A).
|
||||
{
|
||||
NEW_AST_NODE(BasicType, type, A);
|
||||
type->Type = ZCC_UserType;
|
||||
type->UserType = A;
|
||||
type->isconst = false;
|
||||
X = type;
|
||||
}
|
||||
|
||||
|
|
@ -698,7 +712,7 @@ type_name(X) ::= DOT dottable_id(A).
|
|||
%type type_list {ZCC_Type *}
|
||||
%type type_list_or_void {ZCC_Type *}
|
||||
%type type_or_array {ZCC_Type *}
|
||||
%type class_restrictor {ZCC_Identifier *}
|
||||
%type class_restrictor {ZCC_Identifier *}
|
||||
%type array_size{ZCC_Expression *}
|
||||
%type array_size_expr{ZCC_Expression *}
|
||||
|
||||
|
|
|
|||
|
|
@ -1481,16 +1481,16 @@ PType *ZCCCompiler::ResolveUserType(ZCC_BasicType *type, PSymbolTable *symt)
|
|||
if (sym == nullptr && symt != &GlobalSymbols) sym = GlobalSymbols.FindSymbolInTable(type->UserType->Id, table);
|
||||
if (sym != nullptr && sym->IsKindOf(RUNTIME_CLASS(PSymbolType)))
|
||||
{
|
||||
auto type = static_cast<PSymbolType *>(sym)->Type;
|
||||
if (type->IsKindOf(RUNTIME_CLASS(PEnum)))
|
||||
auto ptype = static_cast<PSymbolType *>(sym)->Type;
|
||||
if (ptype->IsKindOf(RUNTIME_CLASS(PEnum)))
|
||||
{
|
||||
return TypeSInt32; // hack this to an integer until we can resolve the enum mess.
|
||||
}
|
||||
if (type->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
if (ptype->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
{
|
||||
return NewPointer(type);
|
||||
return NewPointer(ptype, type->isconst);
|
||||
}
|
||||
return type;
|
||||
return ptype;
|
||||
}
|
||||
Error(type, "Unable to resolve %s as type.", FName(type->UserType->Id).GetChars());
|
||||
return TypeError;
|
||||
|
|
|
|||
|
|
@ -310,6 +310,7 @@ struct ZCC_BasicType : ZCC_Type
|
|||
{
|
||||
EZCCBuiltinType Type;
|
||||
ZCC_Identifier *UserType;
|
||||
bool isconst;
|
||||
};
|
||||
|
||||
struct ZCC_MapType : ZCC_Type
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue