| 388 | //========================================================================== |
| 389 | |
| 390 | void ZCCRazeCompiler::DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *property, DCoreActor *defaults, Baggage &bag) |
| 391 | { |
| 392 | ZCC_ExprConstant one; |
| 393 | unsigned parmcount = 1; |
| 394 | ZCC_TreeNode *x = property->Values; |
| 395 | if (x == nullptr) |
| 396 | { |
| 397 | parmcount = 0; |
| 398 | } |
| 399 | else |
| 400 | { |
| 401 | while (x->SiblingNext != property->Values) |
| 402 | { |
| 403 | x = x->SiblingNext; |
| 404 | parmcount++; |
| 405 | } |
| 406 | } |
| 407 | if (parmcount == 0 && prop->Variables.Size() == 1 && prop->Variables[0]->Type == TypeBool) |
| 408 | { |
| 409 | // allow boolean properties to have the parameter omitted |
| 410 | memset(&one, 0, sizeof(one)); |
| 411 | one.SourceName = property->SourceName; // This may not be null! |
| 412 | one.Operation = PEX_ConstValue; |
| 413 | one.NodeType = AST_ExprConstant; |
| 414 | one.Type = TypeBool; |
| 415 | one.IntVal = 1; |
| 416 | property->Values = &one; |
| 417 | } |
| 418 | else if (parmcount != prop->Variables.Size()) |
| 419 | { |
| 420 | Error(x == nullptr? property : x, "Argument count mismatch: Got %u, expected %u", parmcount, prop->Variables.Size()); |
| 421 | return; |
| 422 | } |
| 423 | |
| 424 | auto exp = property->Values; |
| 425 | FCompileContext ctx(OutNamespace, bag.Info->VMType, false, mVersion); |
| 426 | for (auto f : prop->Variables) |
| 427 | { |
| 428 | void *addr; |
| 429 | if (f == nullptr) |
| 430 | { |
| 431 | // This variable was missing. The error had been reported for the property itself already. |
| 432 | return; |
| 433 | } |
| 434 | |
| 435 | if (f->Flags & VARF_Meta) |
| 436 | { |
| 437 | addr = ((char*)bag.Info->Meta) + f->Offset; |
| 438 | } |
| 439 | else |
| 440 | { |
| 441 | addr = ((char*)defaults) + f->Offset; |
| 442 | } |
| 443 | |
| 444 | FxExpression *ex = ConvertNode(exp); |
| 445 | ex = ex->Resolve(ctx); |
| 446 | if (ex == nullptr) |
| 447 | { |
nothing calls this directly
no test coverage detected