- removed token 'mode' because it isn't used anywhere and clashed with some actor properties.

- fixed uninitialized counter variable in DECORATE parser.
- allow dottable_id of xxx.color so that the property parser can parse 'powerup.color'.
- fixed crash with actor replacement in script compiler.
- add the lump number to tree nodes because parts of the property parser need that to make decisions.
- removed test stuff.
- converted inventory.txt, player.txt and specialspot.txt to ZSCRIPT. These were the minimal files required to allow actor.txt to parse successfully.
- removed the converted files from the DECORATE include list so that these are entirely handled by ZSCRIPT now.
This commit is contained in:
Christoph Oelckers 2016-10-13 20:45:52 +02:00
parent a72fbb771f
commit 433bf46010
18 changed files with 601 additions and 844 deletions

View file

@ -1526,7 +1526,7 @@ void ParseDecorate (FScanner &sc)
void ParseAllDecorate()
{
int lastlump, lump;
int lastlump = 0, lump;
while ((lump = Wads.FindLump("DECORATE", &lastlump)) != -1)
{

View file

@ -658,7 +658,7 @@ VMFunction *FFunctionBuildList::AddFunction(PClass *cls, FxExpression *code, con
return func;
}
Printf("Adding %s\n", name.GetChars());
//Printf("Adding %s\n", name.GetChars());
Item it;
it.Class = cls;

View file

@ -211,6 +211,16 @@ dottable_id(X) ::= dottable_id(A) DOT IDENTIFIER(B).
A->AppendSibling(id2);
X = A; /*X-overwrites-A*/
}
// a bit of a hack to allow the 'color' token to be used inside default properties.
// as a variable name it is practically meaningless because it cannot defined
// as such anywhere so it will always produce an error during processing.
dottable_id(X) ::= dottable_id(A) DOT COLOR.
{
NEW_AST_NODE(Identifier,id2,A);
id2->Id = NAME_Color;
A->AppendSibling(id2);
X = A; /*X-overwrites-A*/
}
/*------ Class Body ------*/
// Body is a list of:

View file

@ -70,7 +70,7 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode)
name << "nodes - " << FName(cnode->NodeName);
cls->TreeNodes.SetName(name);
if (!static_cast<PClassActor *>(cnode->Type)->SetReplacement(cnode->Replaces->Id))
if (cnode->Replaces != nullptr && !static_cast<PClassActor *>(cnode->Type)->SetReplacement(cnode->Replaces->Id))
{
Warn(cnode, "Replaced type '%s' not found for %s", FName(cnode->Replaces->Id).GetChars(), cnode->Type->TypeName.GetChars());
}
@ -1565,7 +1565,9 @@ void ZCCCompiler::DispatchProperty(FPropertyInfo *prop, ZCC_PropertyStmt *proper
if (exp->NodeType != AST_ExprConstant)
{
Error(exp, "%s: non-constant parameter", prop->name);
// If we get TypeError, there has already been a message from deeper down so do not print another one.
if (exp->Type != TypeError) Error(exp, "%s: non-constant parameter", prop->name);
return;
}
conv.s = nullptr;
pref.s = nullptr;
@ -1654,6 +1656,7 @@ void ZCCCompiler::DispatchProperty(FPropertyInfo *prop, ZCC_PropertyStmt *proper
if (exp != property->Values)
{
Error(property, "Too many values for '%s'", prop->name);
return;
}
break;
}
@ -1662,6 +1665,7 @@ void ZCCCompiler::DispatchProperty(FPropertyInfo *prop, ZCC_PropertyStmt *proper
if (*p < 'a')
{
Error(property, "Insufficient parameters for %s", prop->name);
return;
}
break;
}
@ -1816,7 +1820,7 @@ void ZCCCompiler::InitDefaults()
bag.StateSet = false;
bag.fromZScript = true;
bag.CurrentState = 0;
bag.Lumpnum = Wads.CheckNumForFullName(*c->cls->SourceName, true);
bag.Lumpnum = c->cls->SourceLump;
bag.DropItemList = nullptr;
bag.ScriptPosition.StrictErrors = true;
// The actual script position needs to be set per property.
@ -2061,6 +2065,8 @@ void ZCCCompiler::CompileStates()
}
FString statename; // The state builder wants the label as one complete string, not separated into tokens.
FStateDefinitions statedef;
statedef.MakeStateDefines(dyn_cast<PClassActor>(c->Type()->ParentClass));
for (auto s : c->States)
{
auto st = s->Body;

View file

@ -399,6 +399,7 @@ ZCC_TreeNode *ZCC_AST::InitNode(size_t size, EZCCTreeNodeType type, ZCC_TreeNode
if (basis != NULL)
{
node->SourceName = basis->SourceName;
node->SourceLump = basis->SourceLump;
node->SourceLoc = basis->SourceLoc;
}
return node;
@ -408,5 +409,6 @@ ZCC_TreeNode *ZCCParseState::InitNode(size_t size, EZCCTreeNodeType type)
{
ZCC_TreeNode *node = ZCC_AST::InitNode(size, type, NULL);
node->SourceName = Strings.Alloc(sc->ScriptName);
node->SourceLump = sc->LumpNum;
return node;
}

View file

@ -149,6 +149,7 @@ struct ZCC_TreeNode
// can't use FScriptPosition, because the string wouldn't have a chance to
// destruct if we did that.
FString *SourceName;
int SourceLump;
int SourceLoc;
// Node type is one of the node types above, which corresponds with