| 438 | } |
| 439 | |
| 440 | void ZCCDoomCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *property, AActor *defaults, Baggage &bag) |
| 441 | { |
| 442 | ZCC_ExprConstant one; |
| 443 | unsigned parmcount = 1; |
| 444 | ZCC_TreeNode *x = property->Values; |
| 445 | if (x == nullptr) |
| 446 | { |
| 447 | parmcount = 0; |
| 448 | } |
| 449 | else |
| 450 | { |
| 451 | while (x->SiblingNext != property->Values) |
| 452 | { |
| 453 | x = x->SiblingNext; |
| 454 | parmcount++; |
| 455 | } |
| 456 | } |
| 457 | if (parmcount == 0 && prop->Variables.Size() == 1 && prop->Variables[0]->Type == TypeBool) |
| 458 | { |
| 459 | // allow boolean properties to have the parameter omitted |
| 460 | memset(&one, 0, sizeof(one)); |
| 461 | one.SourceName = property->SourceName; // This may not be null! |
| 462 | one.Operation = PEX_ConstValue; |
| 463 | one.NodeType = AST_ExprConstant; |
| 464 | one.Type = TypeBool; |
| 465 | one.IntVal = 1; |
| 466 | property->Values = &one; |
| 467 | } |
| 468 | else if (parmcount != prop->Variables.Size()) |
| 469 | { |
| 470 | Error(x == nullptr? property : x, "Argument count mismatch: Got %u, expected %u", parmcount, prop->Variables.Size()); |
| 471 | return; |
| 472 | } |
| 473 | |
| 474 | auto exp = property->Values; |
| 475 | FCompileContext ctx(OutNamespace, bag.Info->VMType, false, mVersion); |
| 476 | for (auto f : prop->Variables) |
| 477 | { |
| 478 | void *addr; |
| 479 | if (f == nullptr) |
| 480 | { |
| 481 | // This variable was missing. The error had been reported for the property itself already. |
| 482 | return; |
| 483 | } |
| 484 | |
| 485 | if (f->Flags & VARF_Meta) |
| 486 | { |
| 487 | addr = ((char*)bag.Info->Meta) + f->Offset; |
| 488 | } |
| 489 | else |
| 490 | { |
| 491 | addr = ((char*)defaults) + f->Offset; |
| 492 | } |
| 493 | |
| 494 | FxExpression *ex = ConvertNode(exp); |
| 495 | ex = ex->Resolve(ctx); |
| 496 | if (ex == nullptr) |
| 497 | { |
nothing calls this directly
no test coverage detected