-
Notifications
You must be signed in to change notification settings - Fork 2
/
CFunctionDefinitionNode.h
72 lines (55 loc) · 2.71 KB
/
CFunctionDefinitionNode.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
/*
* CFunctionDefinitionNode.h
* HyperCompiler
*
* Created by Uli Kusterer on 10.05.07.
* Copyright 2007 M. Uli Kusterer. All rights reserved.
*
*/
#pragma once
#include "CCodeBlockNode.h"
namespace Carlson
{
class CCommandNode;
class CFunctionDefinitionNode : public CCodeBlockNodeBase
{
public:
CFunctionDefinitionNode( CParseTree* inTree, bool isCommand, const std::string& inName, const std::string& userHandlerName, size_t inLineNum, const std::string &inFileName )
: CCodeBlockNodeBase( inTree, inLineNum, inFileName ), mName( inName ), mUserHandlerName(userHandlerName), mLineNum( inLineNum ), mEndLineNum(0), mLocalVariableCount(0), mIsCommand(isCommand), mAllVarsAreGlobals(false)
{
};
virtual ~CFunctionDefinitionNode();
virtual void AddLocalVar( const std::string& inName, const std::string& inUserName,
TVariantType theType, bool initWithName = false,
bool isParam = false, bool isGlobal = false,
bool dontDispose = false );
virtual int16_t GetBPRelativeOffsetForLocalVar( const std::string& inName );
// Sub-blocks retrieve and modify these two as needed: // TODO: This isn't really very OO.
virtual int16_t& GetLocalVariableCount() { return mLocalVariableCount; };
virtual std::map<std::string,CVariableEntry>& GetLocals() { return mLocals; };
virtual std::map<std::string,CVariableEntry>& GetGlobals() { return mGlobals; };
virtual void DebugPrint( std::ostream& destStream, size_t indentLevel );
virtual void GenerateCode( CCodeBlock* inCodeBlock );
void SetEndLineNum( size_t inEndLineNum ) { mEndLineNum = inEndLineNum; }; // Line number of function's "end" marker, so we can indicate end to the debugger.
size_t GetEndLineNum() { return mEndLineNum; };
void SetCommandsLineNum( size_t n ) { mCommandsLineNum = n; };
size_t GetCommandsLineNum() { return mCommandsLineNum; };
void SetAllVarsAreGlobals( bool inState ) { mAllVarsAreGlobals = inState; }
virtual bool GetAllVarsAreGlobals() { return mAllVarsAreGlobals; }
virtual CCodeBlockNodeBase* GetContainingFunction() { return this; };
bool IsCommand() { return mIsCommand; };
const std::string& GetUserHandlerName() { return mUserHandlerName; };
const std::string& GetName() { return mName; };
protected:
std::string mName;
std::string mUserHandlerName;
bool mIsCommand;
size_t mLineNum;
size_t mEndLineNum;
size_t mCommandsLineNum;
std::map<std::string,CVariableEntry> mLocals;
int16_t mLocalVariableCount;
std::map<std::string,CVariableEntry> mGlobals;
bool mAllVarsAreGlobals; // For message box, which doesn't have local variables and creates globals for every local var.
};
}