mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Removed under-used optimization options
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
DONE: rework type system
|
||||
DONE: var decl with a type, but no value
|
||||
DONE: type casting
|
||||
DONE: remove optimization option
|
||||
|
||||
TODO: string concat with the + operator
|
||||
TODO: empty string as falsy?
|
||||
TODO: remove optimization option
|
||||
TODO: increment & decrement operators
|
||||
TODO: a = b = c = 1;
|
||||
TODO: are compounds shallow or deep copies?
|
||||
|
||||
@@ -17,7 +17,6 @@ void initCommand(int argc, const char* argv[]) {
|
||||
command.outfile = "out.tb";
|
||||
command.source = NULL;
|
||||
command.verbose = false;
|
||||
command.optimize = 1;
|
||||
|
||||
for (int i = 1; i < argc; i++) { //start at 1 to skip the program name
|
||||
command.error = true; //error state by default, set to false by successful flags
|
||||
@@ -40,12 +39,6 @@ void initCommand(int argc, const char* argv[]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!strncmp(argv[i], "-O", 2)) {
|
||||
sscanf(argv[i], "-O%d", &command.optimize);
|
||||
command.error = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((!strcmp(argv[i], "-f") || !strcmp(argv[i], "--sourcefile")) && i + 1 < argc) {
|
||||
command.sourcefile = (char*)argv[i + 1];
|
||||
i++;
|
||||
@@ -89,7 +82,7 @@ void initCommand(int argc, const char* argv[]) {
|
||||
}
|
||||
|
||||
void usageCommand(int argc, const char* argv[]) {
|
||||
printf("Usage: %s [<file.tb> | -h | -v | [-d][-OX][-f file | -i source | -c file [-o outfile]]]\n\n", argv[0]);
|
||||
printf("Usage: %s [<file.tb> | -h | -v | [-d][-f file | -i source | -c file [-o outfile]]]\n\n", argv[0]);
|
||||
}
|
||||
|
||||
void helpCommand(int argc, const char* argv[]) {
|
||||
@@ -99,7 +92,6 @@ void helpCommand(int argc, const char* argv[]) {
|
||||
printf("-h\t| --help\t\tShow this help then exit.\n\n");
|
||||
printf("-v\t| --version\t\tShow version and copyright information then exit.\n\n");
|
||||
printf("-d\t| --debug\t\tBe verbose when operating.\n\n");
|
||||
printf("-OX\t\t\t\tUse level X optimization (default 1)\n\n");
|
||||
printf("-f\t| --file filename\tParse, compile and execute the source file.\n\n");
|
||||
printf("-i\t| --input source\tParse, compile and execute this given string of source code.\n\n");
|
||||
printf("-c\t| --compile filename\tParse and compile the specified source file into an output file.\n\n");
|
||||
|
||||
@@ -20,7 +20,6 @@ typedef struct {
|
||||
char* outfile; //defaults to out.tb
|
||||
char* source;
|
||||
bool verbose;
|
||||
int optimize;
|
||||
} Command;
|
||||
|
||||
extern Command command;
|
||||
|
||||
@@ -328,7 +328,7 @@ static Opcode unary(Parser* parser, Node** nodeHandle) {
|
||||
parsePrecedence(parser, &tmpNode, PREC_TERNARY); //can be a literal
|
||||
|
||||
//check for negative literals (optimisation)
|
||||
if (command.optimize >= 1 && tmpNode->type == NODE_LITERAL) {
|
||||
if (tmpNode->type == NODE_LITERAL) {
|
||||
//negate directly, if int or float
|
||||
Literal lit = tmpNode->atomic.literal;
|
||||
|
||||
@@ -725,7 +725,7 @@ static void parsePrecedence(Parser* parser, Node** nodeHandle, PrecedenceRule ru
|
||||
const Opcode opcode = infixRule(parser, &rhsNode); //NOTE: infix rule must advance the parser
|
||||
emitNodeBinary(nodeHandle, rhsNode, opcode);
|
||||
|
||||
if (command.optimize >= 1 && !calcStaticBinaryArithmetic(parser, nodeHandle)) {
|
||||
if (!calcStaticBinaryArithmetic(parser, nodeHandle)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user