MCPcopy Create free account
hub / github.com/ZDoom/Raze / DispatchScriptProperty

Method DispatchScriptProperty

source/core/zcc_compile_raze.cpp:390–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388//==========================================================================
389
390void 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 {

Callers

nothing calls this directly

Calls 15

GetIntConstFunction · 0.85
S_FindSoundFunction · 0.85
V_GetColorFunction · 0.85
GetFloatConstFunction · 0.85
stricmpFunction · 0.85
isIntCompatibleMethod · 0.80
isClassPointerMethod · 0.80
FindClassTentativeMethod · 0.80
IsDescendantOfMethod · 0.80
DescriptiveNameMethod · 0.80
ToErrorNodeMethod · 0.80
SizeMethod · 0.45

Tested by

no test coverage detected