forked from dolphinsmalltalk/DolphinVM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointPrim.cpp
More file actions
73 lines (57 loc) · 1.62 KB
/
PointPrim.cpp
File metadata and controls
73 lines (57 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/******************************************************************************
File: PointPrim.cpp
Description:
Implementation of the Interpreter class' Point primitive methods
Eventually we'll jump to these directly as they don't take any parameters
******************************************************************************/
#include "Ist.h"
#ifndef _DEBUG
#pragma optimize("s", on)
#pragma auto_inline(off)
#endif
#pragma code_seg(PRIM_SEG)
#include "ObjMem.h"
#include "Interprt.h"
#include "InterprtPrim.inl"
// Smalltalk classes
#include "STBehavior.h"
BOOL __fastcall Interpreter::primitiveMakePoint(CompiledMethod&, unsigned argCount)
{
#ifdef TIMEDEXPIRY
if (argCount == 0)
{
stackTop() = Integer::NewUnsigned32WithRef(ObjectMemory::GetMachineId());
}
else
#endif
{
Oop oopReceiver = stackValue(argCount);
if (!ObjectMemory::isBehavior(oopReceiver))
return primitiveFailure(0);
BehaviorOTE* oteClass = reinterpret_cast<BehaviorOTE*>(oopReceiver);
Behavior* behavior = oteClass->m_location;
if (behavior->isBytes())
return primitiveFailure(1);
MWORD oops = argCount;
if (behavior->isIndexable())
{
oops += behavior->fixedFields();
}
else
{
if (behavior->fixedFields() != oops)
return primitiveFailure(2);
}
// Note that instantiateClassWithPointers counts up the class,
PointersOTE* oteObj = ObjectMemory::newPointerObject(oteClass, oops);
VariantObject* obj = oteObj->m_location;
for (int i=oops-1;i>=0;i--)
{
Oop oopArg = popStack();
ObjectMemory::countUp(oopArg);
obj->m_fields[i] = oopArg;
}
replaceStackTopWithNew(oteObj);
}
return TRUE;
}