Skip to content

Commit d82c7df

Browse files
committed
Added definitions (function, variables).
1 parent 1bc5953 commit d82c7df

File tree

4 files changed

+113
-0
lines changed

4 files changed

+113
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "Fonction.h"
2+
3+
namespace FPL {
4+
bool FonctionDef::isArgument(std::string const& argument) {
5+
if (this->AllFonctionArguments.contains(argument)) { return true; }
6+
return false;
7+
}
8+
9+
std::optional<FonctionArgumentDef> FonctionDef::getArgument(const std::string &argument) {
10+
if (this->isArgument(argument)) {
11+
return this->AllFonctionArguments[argument];
12+
}
13+
return std::nullopt;
14+
}
15+
16+
void FonctionDef::updateValueOfArgument(FonctionArgumentDef argument, std::string_view value) {
17+
this->AllFonctionArguments[argument.ArgumentName].ArgumentValue = value;
18+
}
19+
20+
std::ostream& operator<<(std::ostream &flux, FPL::FonctionDef const& f) {
21+
flux << "Nom de la fonction: " << f.FonctionName << ", type: " << f.FonctionType.Name << ", args: " << f.FonctionNumberArgument;
22+
return flux;
23+
}
24+
25+
std::ostream& operator<<(std::ostream &flux, FPL::FonctionArgumentDef const& f) {
26+
flux << "Nom de l'argument: " << f.ArgumentName << ", type: " << f.ArgumentType.Name << ", value: " << f.ArgumentValue;
27+
return flux;
28+
}
29+
30+
bool operator==(FonctionArgumentDef const& arg1, FonctionArgumentDef const& arg2) {
31+
return arg1.ArgumentName == arg2.ArgumentName;
32+
}
33+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#pragma once
2+
3+
#include <iostream>
4+
#include <vector>
5+
#include <ostream>
6+
#include <string>
7+
#include <map>
8+
#include <algorithm>
9+
#include <iterator>
10+
#include <optional>
11+
12+
#include "../Types.h"
13+
14+
namespace FPL {
15+
class FonctionArgumentDef {
16+
public:
17+
std::string ArgumentName;
18+
std::string ArgumentValue;
19+
Types::Types ArgumentType;
20+
21+
friend std::ostream& operator<<(std::ostream& flux, FonctionArgumentDef const& arg);
22+
friend bool operator==(FonctionArgumentDef const& arg1, FonctionArgumentDef const& arg2);
23+
};
24+
25+
class FonctionDef {
26+
public:
27+
std::string FonctionName;
28+
Types::Types FonctionType;
29+
std::map<std::string, FonctionArgumentDef> AllFonctionArguments;
30+
std::vector<std::string> FonctionContentCode;
31+
int FonctionNumberArgument = 0;
32+
std::string ReturnValue = "N/A";
33+
34+
friend std::ostream& operator<<(std::ostream& flux, FonctionDef const& var);
35+
36+
bool isArgument(std::string const& argument);
37+
std::optional<FonctionArgumentDef> getArgument(std::string const& argument);
38+
void updateValueOfArgument(FonctionArgumentDef argument, std::string_view value);
39+
};
40+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "Variables.h"
2+
3+
namespace FPL {
4+
std::ostream& operator<<(std::ostream &flux, FPL::VariableDef const& var) {
5+
flux << "Une variable du nom de " << var.VariableName << ", a pour valeur " << var.VariableValue << ", pour type " << var.VariableType.Name << ", globale : " << var.IsGlobal;
6+
return flux;
7+
}
8+
9+
bool operator==(const VariableDef &v1, const VariableDef &v2) {
10+
return v1.VariableType.Type == v2.VariableType.Type;
11+
}
12+
13+
bool operator!=(const VariableDef &v1, const VariableDef &v2) {
14+
return v1.VariableType.Type != v2.VariableType.Type;
15+
}
16+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <iostream>
4+
#include <vector>
5+
#include <ostream>
6+
#include <string>
7+
8+
#include "../Types.h"
9+
10+
namespace FPL {
11+
class VariableDef {
12+
public:
13+
std::string VariableName;
14+
Types::Types VariableType;
15+
std::string VariableValue;
16+
bool NeedDelete = false;
17+
bool IsGlobal = false;
18+
19+
friend std::ostream& operator<<(std::ostream& flux, VariableDef const& var);
20+
21+
friend bool operator==(const VariableDef &v1, const VariableDef &v2);
22+
friend bool operator!=(const VariableDef &v1, const VariableDef &v2);
23+
};
24+
}

0 commit comments

Comments
 (0)