Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tddd55-lab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TDDD55 - Compilers and Interpreters
tddd55-lab
Merge requests
!2
Delete function.hh
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Delete function.hh
johti17-master-patch-83260
into
master
Overview
1
Commits
1
Pipelines
0
Changes
1
Merged
John Tinnerholm
requested to merge
johti17-master-patch-83260
into
master
4 years ago
Overview
1
Commits
1
Pipelines
0
Changes
1
Expand
This file is not used
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
d931ec78
1 commit,
4 years ago
1 file
+
0
−
114
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
lab3-4/function.hh deleted
100644 → 0
+
0
−
114
Options
#ifndef __KOMP_FUNCTION__
#define __KOMP_FUNCTION__
/*
* SymbolInformationType is used to tag object subclassed from
* SymbolInformation. The value of SymbolInformation's type field
* specified which subclass the object belongs to.
*/
typedef
enum
{
kFunctionInformation
,
kVariableInformation
,
kTypeInformation
,
}
SymbolInformationType
;
/*
* SymbolInformation is the base class for all information about
* symbols. It is never used directly; use the subclasses instead
*/
class
SymbolInformation
{
public:
SymbolInformationType
type
;
string
id
;
SymbolTable
*
table
;
SymbolInformation
(
SymbolInformationType
t
)
:
type
(
t
)
{};
};
/*
* FunctionInformation represents information stored about a function
* in the symbol table. It contains the return type of the function, a
* pointer to the functions's first parameter and a pointer to the
* symbol table for the function.
*/
class
FunctionInformation
:
SymbolInformation
{
public:
TypeInformation
*
returnType
;
VariableInformation
*
firstParam
;
SymbolTable
*
symbolTable
;
FunctionInformation
()
:
SymbolInformationType
(
kFunctionInformation
)
{};
void
SetParent
(
FunctionInformation
*
);
void
SetReturnType
(
TypeInformation
*
);
void
SetName
(
string
&
);
char
AddParameter
(
string
&
,
TypeInformation
*
);
char
AddVariable
(
string
&
,
TypeInformation
*
);
char
AddArrayType
(
TypeInformation
*
,
int
);
};
/*
* VariableInformation represents information stored about a variable
* in the symbol table. It contains a type field which specifies
* the type of the variable and a next field which is used to link
* together parameters and local variables in a symbol table.
*/
class
VariableInformation
:
SymbolInformation
{
public:
TypeInformation
*
type
;
VariableInformation
*
next
;
VariableInformation
()
:
SymbolInformation
(
kVariableInformation
)
{};
};
class
TypeInformation
:
SymbolInformation
{
public:
TypeInformation
*
elementType
;
int
arrayDimensions
;
TypeInformation
()
:
SymbolInformation
(
kTypeInformation
)
{};
}
/*
* SymbolTable is a symbol table. You'll never really use this
* directly. Instead, use the methods in the FunctionInformation
* class for adding and looking up variables in the symbol table
*/
class
SymbolTableElement
{
public:
SymbolInformation
*
info
;
SymbolTableElement
*
next
;
};
class
SymbolTable
{
public:
SymbolTableElement
**
table
;
static
int
nextTemporary
;
void
AddSymbol
(
SymbolInformation
*
);
SymbolInformation
*
LookupSymbol
(
string
&
);
VariableInformation
*
GenTemp
(
TypeInformation
*
);
};
Loading