-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathSTBlockClosure.h
77 lines (59 loc) · 1.83 KB
/
STBlockClosure.h
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
73
74
75
76
77
/******************************************************************************
File: STBlockClosure.h
Description:
VM representation of Smalltalk block objects
N.B. The classes here defined are well known to the VM, and must not
be modified in the image. Note also that these classes may also have
a representation in the assembler modules (so see istasm.inc)
******************************************************************************/
#pragma once
#include "VMPointers.h"
#include "STMethod.h"
namespace ST
{
#include "STBlockInfo.h"
class BlockClosure : public Object
{
public:
// Outer environment, or SmallInteger frame pointer if a method env.
POTE m_outer;
MethodOTE* m_method;
Oop m_initialIP;
BlockInfo m_info;
Oop m_receiver;
Oop m_copiedValues[];
public:
// The pool must contain fixed size objects, so choose a suitable maximum number of
// copied values permissible; very uncommonly exceed 2 (see Util class>>blockStats)
enum { MaxCopiedValues = 2 };
enum { OuterIndex = ObjectFixedSize, MethodIndex, InitialIPIndex, InfoIndex, ReceiverIndex, FixedSize };
enum { TempFrameStart = FixedSize };
static BlockOTE* __fastcall New(unsigned copiedValuesCount);
unsigned initialIP() const
{
return integerValueOf(m_initialIP);
}
unsigned copiedValuesCount(BlockOTE* myOTE) const
{
return myOTE->pointersSize() - FixedSize;
}
unsigned stackTempsCount() const
{
return m_info.stackTempsCount;
}
unsigned envTempsCount() const
{
return m_info.envTempsCount;
}
unsigned argumentCount() const
{
return m_info.argumentCount;
}
bool isClean(BlockOTE* ote) const
{
return m_receiver == Oop(Pointers.Nil) && m_outer == Pointers.Nil
&& copiedValuesCount(ote) == 0 && envTempsCount() == 0;
}
};
}
std::wostream& operator<<(std::wostream& st, const BlockOTE*);