|
|
|
#ifndef PRINT_C
|
|
|
|
#define PRINT_C
|
|
|
|
#include "print.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Author: xerox
|
|
|
|
Updated: 1/20/2020
|
|
|
|
|
|
|
|
creates a print statement given variable type and value.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static node_info* create_print_statement(variable_type operation, void* value)
|
|
|
|
{
|
|
|
|
if (!value)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
node_info* new_print_stmt = (node_info*)malloc(sizeof(node_info));
|
|
|
|
print* new_print = malloc(sizeof(print));
|
|
|
|
new_print_stmt->operation = PRINT_OPERATION;
|
|
|
|
new_print_stmt->operation_type.print = PRINT_CONSTANT;
|
|
|
|
new_print->type = operation;
|
|
|
|
new_print->value = value;
|
|
|
|
new_print_stmt->print_expr = new_print;
|
|
|
|
new_print_stmt->statement_list = NULL;
|
|
|
|
new_print_stmt->next = NULL;
|
|
|
|
return new_print_stmt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Author: xerox
|
|
|
|
Updated: 1/19/2020
|
|
|
|
|
|
|
|
create print variable from variable name.
|
|
|
|
*/
|
|
|
|
static node_info* create_print_variable(char* var_name)
|
|
|
|
{
|
|
|
|
if (!var_name)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
node_info* new_print_stmt = (node_info*)malloc(sizeof(node_info));
|
|
|
|
new_print_stmt->var = malloc(sizeof(variable));
|
|
|
|
new_print_stmt->operation = PRINT_OPERATION;
|
|
|
|
new_print_stmt->operation_type.print = PRINT_VARIABLE;
|
|
|
|
new_print_stmt->var->name = var_name;
|
|
|
|
|
|
|
|
new_print_stmt->statement_list = NULL;
|
|
|
|
new_print_stmt->next = NULL;
|
|
|
|
return new_print_stmt;
|
|
|
|
}
|
|
|
|
#endif
|