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

Method MakeFunction

source/common/scripting/backend/vmbuilder.cpp:117–155  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117void VMFunctionBuilder::MakeFunction(VMScriptFunction *func)
118{
119 func->Alloc(Code.Size(), IntConstantList.Size(), FloatConstantList.Size(), StringConstantList.Size(), AddressConstantList.Size(), LineNumbers.Size());
120
121 // Copy code block.
122 memcpy(func->Code, &Code[0], Code.Size() * sizeof(VMOP));
123 memcpy(func->LineInfo, &LineNumbers[0], LineNumbers.Size() * sizeof(LineNumbers[0]));
124
125 // Create constant tables.
126 if (IntConstantList.Size() > 0)
127 {
128 FillIntConstants(func->KonstD);
129 }
130 if (FloatConstantList.Size() > 0)
131 {
132 FillFloatConstants(func->KonstF);
133 }
134 if (AddressConstantList.Size() > 0)
135 {
136 FillAddressConstants(func->KonstA);
137 }
138 if (StringConstantList.Size() > 0)
139 {
140 FillStringConstants(func->KonstS);
141 }
142
143 // Assign required register space.
144 func->NumRegD = Registers[REGT_INT].MostUsed;
145 func->NumRegF = Registers[REGT_FLOAT].MostUsed;
146 func->NumRegA = Registers[REGT_POINTER].MostUsed;
147 func->NumRegS = Registers[REGT_STRING].MostUsed;
148 func->MaxParam = MaxParam;
149 func->StackSize = VMFrame::FrameSize(func->NumRegD, func->NumRegF, func->NumRegS, func->NumRegA, func->MaxParam, func->ExtraSpace);
150
151 // Technically, there's no reason why we can't end the function with
152 // entries on the parameter stack, but it means the caller probably
153 // did something wrong.
154 assert(ActiveParam == 0);
155}
156
157//==========================================================================
158//

Callers 1

BuildMethod · 0.80

Calls 2

AllocMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected