Skip to content

Commit 5cbb8b9

Browse files
committed
Merge branch 'master' of https://github.com/yugeshk/CS335
2 parents f390cae + 0875e9a commit 5cbb8b9

File tree

5 files changed

+62
-30
lines changed

5 files changed

+62
-30
lines changed

src/3ac.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ void arithmetic_optimise(Quad* q){
494494
else if(oper=="/"){
495495

496496
if(y==0){
497-
error_msg("Division by zero not possible",line_num);
498497
return;
499498
}
500499
else{

src/expression.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,17 @@ Expression *create_postfix_expr_voidfun( Identifier *fi ) {
249249
Expression *create_postfix_expr_fun( Identifier *fi, ArgumentExprList *ae ) {
250250
PostfixExpression *P = new PostfixExpression();
251251

252-
if ( fi->value == "printf" || fi->value == "scanf" ) {
253-
// XXX:
254-
/* Hack : To support printf for now */
255-
P->type = Type( INT_T, 0, true );
256-
P->add_children( fi, ae );
257-
P->res = new_temp();
258-
create_new_call( P->res, fi->value );
259-
// emit( P->res, "call", new_3id( fi->value ), new_3const( 0, INT3 ) );
260-
return P;
261-
}
252+
// if ( fi->value == "printf" || fi->value == "scanf" ) {
253+
// error_msg("Use functions in lib/lib.asm",line_num)
254+
// // XXX:
255+
// /* Hack : To support printf for now */
256+
// // P->type = Type( INT_T, 0, true );
257+
// // P->add_children( fi, ae );
258+
// // P->res = new_temp();
259+
// // create_new_call( P->res, fi->value );
260+
// // emit( P->res, "call", new_3id( fi->value ), new_3const( 0, INT3 ) );
261+
// return P;
262+
// }
262263

263264
SymTabEntry *ste = global_symbol_table.get_symbol_from_table( fi->value );
264265
if ( ste == nullptr ) {

tests/3ac_3.c

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/optimisations.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
void print_int(int c);
2+
void print_char(char c);
3+
int scan_int();
4+
void print_string(char *);
5+
int main(){
6+
int a,b,c;
7+
a = 14*3+5+(4+(8*12/73))-23*76+48;
8+
print_int(a);
9+
10+
// multiply and divide by power of 2 is shift
11+
b = a*2;
12+
b= a/16;
13+
14+
b=a*0;
15+
b=a+0;
16+
17+
while(1){
18+
print_string("Inside while\n");
19+
b++;
20+
if(b==7){
21+
break;
22+
}
23+
}
24+
25+
return 0;
26+
}

tests/switch2.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/// switch
2+
void print_int(int);
3+
void print_char(char );
4+
void print_string(char *);
5+
int scan_int();
6+
int main()
7+
{
8+
char y;
9+
char arr[10];
10+
int x;
11+
print_string("Enter the integer for switch case\n");
12+
x=scan_int();
13+
y = 'a';
14+
15+
switch(x)
16+
{
17+
case 'a': x++;
18+
break;
19+
case 'b' :x+=2;
20+
break;
21+
}
22+
print_int(x);
23+
return 0;
24+
25+
}

0 commit comments

Comments
 (0)