⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 14-shortcircuit.dcf

📁 用Java实现的编译器。把源代码编译成SPARC汇编程序
💻 DCF
字号:
// test shortcircuit and other stuffclass Program{  int field_in_class;  int test_long_args(int a, int b, int c, int d, int e, int f)  {    callout("printf","args: %d+%d+%d+%d+%d+%d=%d\n",a,b,c,d,e,f,a+b+c+d+e+f);    return a+b+c+d+e+f;  }  boolean test_short_circuit(boolean and, boolean okay)  {    if (okay != true) {      if (and != true) {        callout("printf","short circuit failed in and\n");      } else {        callout("printf","short circuit failed in or\n");      }    }     return true;  }  void main()  {    int field_on_stack;    int i, result;    boolean a;    callout("printf","hello world from main\n");    field_in_class = 13;    field_on_stack = 14;    callout("printf","some values (13,14): %d %d\n",	    field_in_class,field_on_stack);    result = test_long_args(field_in_class,field_in_class,field_in_class,	                    field_on_stack,field_on_stack,field_on_stack);    callout("printf","returned a variable, value is %d, should be 81\n",result);    a = test_short_circuit(false, true);    callout("printf","returned a constant, value is %d, should be 1\n",a);    a = true;    if (a && test_short_circuit(true, true)) {	callout("printf","successfully did a short-circuited and.\n");    } else {	callout("printf","if failed on a && proc\n");    }    if (a!=true && test_short_circuit(true, false)) {	callout("printf","if failed on !a && proc\n");    } else {	callout("printf","successfully did a short-circuited and.\n");    }    if (a || test_short_circuit(false, false)) {	callout("printf","successfully did a short-circuited or.\n");    } else {	callout("printf","if failed on a || proc\n");    }    if (a!=true || test_short_circuit(false, true)) {	callout("printf","successfully did a short-circuited or.\n");    } else {	callout("printf","if failed on !a || proc\n");    }    i = 0;    result = 0;    field_on_stack = 100;    while(i < field_on_stack) {        result = result + i;	i = i + 1;    }    callout("printf","sum from 0 to 99 is %d, should be 4950\n",result);  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -