Exemple #1
0
 int check_operation(ast::abstract::Operation* op) {
     assert(op != nullptr);
     switch(*op) {
     case ast::VariableNode:
         return check_variable(dynamic_cast<ast::Variable*>(op));
         break;
     case ast::ConstantNode:
         return check_constant(dynamic_cast<ast::Constant*>(op));
         break;
     case ast::CastNode:
         return check_cast(dynamic_cast<ast::Cast*>(op));
         break;
     case ast::UnOpNode:
         return check_un_op(dynamic_cast<ast::UnOp*>(op));
         break;
     case ast::BinOpNode:
         return check_bin_op(dynamic_cast<ast::BinOp*>(op));
         break;
     case ast::CallNode:
         return check_call(dynamic_cast<ast::Call*>(op));
         break;
     }
     assert(false);
     return EXIT_FAILURE;
 }
Exemple #2
0
int
main (int argc, char *argv[])
{
  schro_init();

  check_output (SCHRO_WAVELET_DAUBECHIES_9_7, 1);
  check_output (SCHRO_WAVELET_DAUBECHIES_9_7, 0);

  check_output (SCHRO_WAVELET_DESLAURIERS_DUBUC_9_7, 1);
  check_output (SCHRO_WAVELET_DESLAURIERS_DUBUC_9_7, 0);

  check_output (SCHRO_WAVELET_LE_GALL_5_3, 1);
  check_output (SCHRO_WAVELET_LE_GALL_5_3, 0);

  check_output (SCHRO_WAVELET_DESLAURIERS_DUBUC_13_7, 1);
  check_output (SCHRO_WAVELET_DESLAURIERS_DUBUC_13_7, 0);
  
  check_endpoints (SCHRO_WAVELET_DAUBECHIES_9_7, 1);
  check_endpoints (SCHRO_WAVELET_DAUBECHIES_9_7, 0);

  check_endpoints (SCHRO_WAVELET_DESLAURIERS_DUBUC_9_7, 1);
  check_endpoints (SCHRO_WAVELET_DESLAURIERS_DUBUC_9_7, 0);

  check_endpoints (SCHRO_WAVELET_LE_GALL_5_3, 1);
  check_endpoints (SCHRO_WAVELET_LE_GALL_5_3, 0);

  check_endpoints (SCHRO_WAVELET_DESLAURIERS_DUBUC_13_7, 1);
  check_endpoints (SCHRO_WAVELET_DESLAURIERS_DUBUC_13_7, 0);
  

  check_constant (SCHRO_WAVELET_DAUBECHIES_9_7);
  check_constant (SCHRO_WAVELET_DESLAURIERS_DUBUC_9_7);
  check_constant (SCHRO_WAVELET_LE_GALL_5_3);
  check_constant (SCHRO_WAVELET_DESLAURIERS_DUBUC_13_7);


  check_random (SCHRO_WAVELET_DAUBECHIES_9_7);
  check_random (SCHRO_WAVELET_DESLAURIERS_DUBUC_9_7);
  check_random (SCHRO_WAVELET_LE_GALL_5_3);
  check_random (SCHRO_WAVELET_DESLAURIERS_DUBUC_13_7);


  return 0;
}
Exemple #3
0
int main() {

#if defined(HAVE_AVX512F_INSTRUCTIONS)
    avx512f_gather_init();
#endif

    for(int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for(uint64_t value = 0; value < 256; value += 1) {
            if(!check_constant(w,value)) return -1;
        }
    }
    printf("\n");
    for(int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for(int runstart = 0; runstart < w * (int) sizeof(uint64_t); runstart+= w / 33 + 1) {
            for(int endstart = runstart; endstart < w * (int) sizeof(uint64_t); endstart += w / 11 + 1) {
                if(!check_continuous(w,runstart,endstart)) return -1;
            }
        }
    }
    printf("\n");
    for (int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for (int step = 1; step < w * (int) sizeof(uint64_t);
                step += w / 33 + 1) {
            if (!check_step(w, step))
                return -1;

        }
    }
    printf("\n");
    for (int w = 8; w <= 8192; w = 2 * w - 1) {
        printf(".");
        fflush(stdout);
        for (int start = 0; start < w * (int) sizeof(uint64_t);
                start += w / 11 + 1) {
            if (!check_exponential_step(w, start))
                return -1;

        }
    }
    printf("\n");
    printf("Code looks ok.\n");
    return 0;
}
Exemple #4
0
int check_expr(is_expr* node)
{
	char *typeA, *typeB; 
	int errors = 0;

	switch (node->type)
	{
		case t_expr_var:
			errors += check_var(node->data.var);

			if (errors == 0)
			{
				node->s_type = duplicate_type_decl(node->data.var->s_type);

				if (!node->data.var->initialized)
				{
					errors++;
					pretty_error(node->line, "variable used without being initialized");
				}
			}
		break;

		case t_expr_new_op:
			errors += check_new_op(node->data.new_op);
			if (errors == 0)
				node->s_type = duplicate_type_decl(node->data.new_op->s_type);
		break;

		case t_expr_type_cast:
			errors += check_expr(node->data.type_cast.expr);
			errors += check_type_decl(node->data.type_cast.type);

			if (errors == 0)
			{
				if (!type_type_cast_able(node->data.type_cast.type, node->data.type_cast.expr->s_type))
				{
					errors++;
					typeA = string_type_decl(node->data.type_cast.type);
					typeB = string_type_decl(node->data.type_cast.expr->s_type);

					pretty_error(node->line, "invalid typecast from %s to %s", typeA, typeB);
					free(typeA); free(typeB);
				} else
					node->s_type = duplicate_type_decl(node->data.type_cast.type);
			}
		break;

		case t_expr_constant:
			errors += check_constant(node->data.constant);
			if (errors == 0)
				node->s_type = duplicate_type_decl(node->data.constant->s_type);
		break;

		case t_expr_func_call:
			errors += check_func_call(node->data.func_call);
			if (errors == 0)
				node->s_type = duplicate_type_decl(node->data.func_call->s_type);
		break;

		case t_expr_operation:
			errors += check_expr_op(node->data.operation);
			if (errors == 0)
				node->s_type = duplicate_type_decl(node->data.operation->s_type);
		break;
	}

	return errors;
}
Exemple #5
0
int check_switch_stmt(is_switch_stmt* node, is_switch* root)
{
	int errors = 0;
	char *typeA, *typeB;
	is_switch_stmt_list* temp;

	switch (node->type)
	{
		case t_switch_stmt_default:
			for (temp = root->list; temp->node != node; temp = temp->next)
			{
				if (temp->node->type == t_switch_stmt_default)
				{
					errors++;
					pretty_error(node->line, "duplicate default label inside of switch (previous declaration was here %d)",
						temp->node->line);
				}
			}
			
			if (node->list)
				errors += check_stmt_list(node->list);
		break;

		case t_switch_stmt_case:
			check_constant(node->constant);
			
			if (errors == 0)
			{
				node->s_type = duplicate_type_decl(node->constant->s_type);

	 			if (!type_type_equal(root->expr->s_type, node->s_type))
				{
					errors++;
					typeA = string_type_decl(root->expr->s_type);
					typeB = string_type_decl(node->s_type);

					pretty_error(node->line, "case stmt must by of type %s (but got %s)",
						typeA, typeB);

					free(typeA);
					free(typeB);
				}
			}

			if (errors == 0)
			{
				for (temp = root->list; temp->node != node; temp = temp->next)
				{
					if (temp->node->type != t_switch_stmt_default &&
						constant_constant_equal(temp->node->constant, node->constant))
					{
						errors++;
						pretty_error(node->line, "duplicate case inside of switch (previous declaration was here %d)",
							temp->node->line);
					}
				}
			}

			if (node->list)
				errors += check_stmt_list(node->list);
		break;
	}

	return errors;
}
Exemple #6
0
pmtransflag_t
check_transflag(lua_State *L, int narg)
{
    return check_constant(L, narg, transflag_constants,
                          "expected a pmtransflag_t");
}