From 7514b3a0889ec51bb744a4939a0e87e81905633d Mon Sep 17 00:00:00 2001 From: Brandon Rozek Date: Fri, 28 Sep 2018 12:32:19 -0400 Subject: [PATCH] Variable constructor made --- src/variables/variable.cpp | 13 ------------- src/variables/variable.hpp | 18 +++++------------- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/variables/variable.cpp b/src/variables/variable.cpp index 0262ea6..55d7a73 100644 --- a/src/variables/variable.cpp +++ b/src/variables/variable.cpp @@ -2,19 +2,6 @@ #include #include "variable.hpp" -/* creates a new variable and returns it */ -struct Variable* make_variable(std::string id, struct Value* value) { - /* allocate space */ - struct Variable* var = new Variable(); - - /* set properties */ - var->id = id; - var->value = value; - - /* return new variable */ - return var; -} - void set_value(struct Variable* var, struct Value* value) { if (!var) { std::cerr << "Error: Invalid Variable" << std::endl; return; } var->value = value; diff --git a/src/variables/variable.hpp b/src/variables/variable.hpp index f951089..8d5dbb3 100644 --- a/src/variables/variable.hpp +++ b/src/variables/variable.hpp @@ -7,10 +7,14 @@ struct Variable { std::string id; struct Value* value; + + Variable(std::string s, struct Value* val) { + id = s; + value = val; + } }; // Variable Functions -struct Variable* make_variable(std::string id, struct Value* value); void set_value(struct Variable* var, struct Value* value); struct Value* get_value(struct Variable* var); struct Value* make_long(long num); @@ -21,15 +25,3 @@ struct Value* make_boolean(int x); struct Value* make_expression(struct Node* expr); #endif -// /* creates a new variable and returns it */ -// struct Variable* make_variable(char* id, struct Value* value) { -// /* allocate space */ -// struct Variable* var = new Variable(); - -// /* set properties */ -// strcpy(var->id, id); -// var->value = value; - -// /* return new variable */ -// return var; -// } \ No newline at end of file