Beispiel #1
0
tree
evaluate_xor (tree t) {
  if (N(t)!=2) return evaluate_error ("bad xor");
  tree t1= evaluate (t[0]);
  tree t2= evaluate (t[1]);
  if (!is_bool (t1) || !is_bool (t2))
    return evaluate_error ("bad xor");
  return as_string_bool (as_bool (t1) ^ as_bool (t2));
}
bool static_features::is_diff_atom(expr const * e) const {
    if (!is_bool(e))
        return false;
    if (!m_manager.is_eq(e) && !is_arith_expr(e))
        return false;
    SASSERT(to_app(e)->get_num_args() == 2);
    expr * lhs = to_app(e)->get_arg(0);
    expr * rhs = to_app(e)->get_arg(1);
    if (!is_arith_expr(lhs) && !is_arith_expr(rhs)) 
        return true;    
    if (!is_numeral(rhs)) 
        return false;    
    // lhs can be 'x' or '(+ x (* -1 y))'
    if (!is_arith_expr(lhs))
        return true;
    expr* arg1, *arg2;
    if (!m_autil.is_add(lhs, arg1, arg2)) 
        return false;    
    // x
    if (is_arith_expr(arg1))
        return false;
    // arg2: (* -1 y)
    expr* m1, *m2;
    return m_autil.is_mul(arg2, m1, m2) &&  is_minus_one(m1) && !is_arith_expr(m2);
}
Beispiel #3
0
LLVMValueRef gen_not(compile_t* c, ast_t* ast)
{
  LLVMValueRef value = gen_expr(c, ast);

  if(value == NULL)
    return NULL;

  ast_t* type = ast_type(ast);

  if(is_bool(type))
  {
    if(LLVMIsAConstantInt(value))
    {
      if(is_always_true(value))
        return LLVMConstInt(c->ibool, 0, false);

      return LLVMConstInt(c->ibool, 1, false);
    }

    LLVMValueRef test = LLVMBuildICmp(c->builder, LLVMIntEQ, value,
      LLVMConstInt(c->ibool, 0, false), "");
    return LLVMBuildZExt(c->builder, test, c->ibool, "");
  }

  if(LLVMIsAConstantInt(value))
    return LLVMConstNot(value);

  return LLVMBuildNot(c->builder, value, "");
}
Beispiel #4
0
void print(Value x)
{
	if (is_nil(x))
		prints("nil");
	else if (is_eof(x))
		printf("#eof");
	else if (is_fixnum(x))
		printf("%d", as_fixnum(x));
	else if (is_bool(x))
		printf("%s", as_bool(x) ? "true" : "false");
	else if (is_char(x))
		printf("'%c'", as_char(x));
	else if (is_pair(x))
		print_list(x);
	else if (is_symbol(x))
		prints(as_symbol(x)->value);
	else if (is_string(x))
		print_string(as_string(x));
	else if (is_procedure(x))
		printf("#<procedure %s>", as_procedure(x)->name->value);
	else if (is_module(x))
		printf("#<module>");
	else if (is_type(x))
		printf("#<type %s>", as_type(x)->name->value);
	else if (is_ptr(x))
		printf("#<object %p>", as_ptr(x));
	else if (is_undefined(x))
		printf("#undefined");
	else
		printf("#ufo");
}
Beispiel #5
0
void Flag::print_on(outputStream* st, bool withComments) {
  st->print("%9s %-40s %c= ", type, name, (origin != DEFAULT ? ':' : ' '));
  if (is_bool())     st->print("%-16s", get_bool() ? "true" : "false");
  if (is_intx())     st->print("%-16ld", get_intx());
  if (is_uintx())    st->print("%-16lu", get_uintx());
  if (is_uint64_t()) st->print("%-16lu", get_uint64_t());
  if (is_double())   st->print("%-16f", get_double());

  if (is_ccstr()) {
     const char* cp = get_ccstr();
     if (cp != NULL) {
       const char* eol;
       while ((eol = strchr(cp, '\n')) != NULL) {
         char format_buffer[FORMAT_BUFFER_LEN];
         size_t llen = pointer_delta(eol, cp, sizeof(char));
         jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
                     "%%." SIZE_FORMAT "s", llen);
         st->print(format_buffer, cp);
         st->cr();
         cp = eol+1;
         st->print("%5s %-35s += ", "", name);
       }
       st->print("%-16s", cp);
     }
     else st->print("%-16s", "");
  }
  st->print("%-20s", kind);
  if (withComments) {
#ifndef PRODUCT
    st->print("%s", doc );
#endif
  }
  st->cr();
}
Beispiel #6
0
tree
evaluate_not (tree t) {
  if (N(t)!=1) return evaluate_error ("bad not");
  tree u= evaluate(t[0]);
  if (!is_bool (u)) return evaluate_error ("bad not");
  return as_string_bool (!as_bool (u));
}
Beispiel #7
0
void Flag::print_as_flag(outputStream* st) {
  if (is_bool()) {
    st->print("-XX:%s%s", get_bool() ? "+" : "-", name);
  } else if (is_intx()) {
    st->print("-XX:%s=" INTX_FORMAT, name, get_intx());
  } else if (is_uintx()) {
    st->print("-XX:%s=" UINTX_FORMAT, name, get_uintx());
  } else if (is_uint64_t()) {
    st->print("-XX:%s=" UINT64_FORMAT, name, get_uint64_t());
  } else if (is_double()) {
    st->print("-XX:%s=%f", name, get_double());
  } else if (is_ccstr()) {
    st->print("-XX:%s=", name);
    const char* cp = get_ccstr();
    if (cp != NULL) {
      // Need to turn embedded '\n's back into separate arguments
      // Not so efficient to print one character at a time,
      // but the choice is to do the transformation to a buffer
      // and print that.  And this need not be efficient.
      for (; *cp != '\0'; cp += 1) {
        switch (*cp) {
          default:
            st->print("%c", *cp);
            break;
          case '\n':
            st->print(" -XX:%s=", name);
            break;
        }
      }
    }
  } else {
    ShouldNotReachHere();
  }
}
Beispiel #8
0
		void help(std::basic_ostream<Char>& ost) {
			int max_width = 0;

			auto begin = c_.desc_begin(), end = c_.desc_end();

			// 最長の名前を取得
			auto it = begin;
			while (it != end) {
				if (max_width < it->opt_name_.size()) max_width = it->opt_name_.size();
				++it;
			}

			// helpを出力
			ost << descript_ << std::endl;
			it = begin;
			while (it != end) {
				if (it->is_bool()) {
					program_option::print_help_bool(ost, it->opt_name_, it->opt_ch_, it->desc_, max_width);
				}
				else {
					program_option::print_help(ost, it->opt_name_, it->opt_ch_, it->desc_, max_width);
				}
				++it;
			}
		}
Beispiel #9
0
 void ConfUnit::set_bool(bool b) {
     if (is_bool()) {
         _union.b = b;
     }
     else {
         throw std::exception();
     }
 }
Beispiel #10
0
 bool ConfUnit::to_bool() const {
     if (is_bool()) {
         return _union.b;
     }
     else {
         throw std::exception();
     }
 }
Beispiel #11
0
void ring_murmurhash3_x64_128(void *pPointer)
{
    char *key = NULL;
    int keylen;
    int seed = 0;
    uint64_t out[2];
    int ret_type = 0;

    List *tmp_list, *ret_val;

    if (RING_API_PARACOUNT < 2 || RING_API_PARACOUNT > 3) {
        RING_API_ERROR(RING_API_MISS2PARA);
        return ;
    }

    if (!RING_API_ISSTRING(1)) {
        RING_API_ERROR("murmurhash3_x64_128 expects the first parameter to be a string");
        return;
    }

    if (!RING_API_ISNUMBER(2)) {
        RING_API_ERROR("murmurhash3_x64_128 expects the first parameter to be an integer");
        return;
    }

    key = RING_API_GETSTRING(1);
    keylen = strlen(key);
    seed = RING_API_GETNUMBER(2);

    if (RING_API_PARACOUNT == 3) {
        if (RING_API_ISNUMBER(3)) {
            ret_type = RING_API_GETNUMBER(3);
            if (!is_bool(ret_type)) {
                RING_API_ERROR("Third parameter should be boolean value\n");
            }
        } else {
            RING_API_ERROR("murmurhash3_x64_128 expects the third parameter to be an integer\n");
        }
    }

    MurmurHash3_x64_128(key, keylen, seed, out);

    ret_val = RING_API_NEWLIST;
    tmp_list = ring_list_newlist_gc(((VM *)pPointer)->pRingState, ret_val);

    for (int i = 0; i < 2; i++) {
        if (ret_type) {
            char tmp[50];
            LONG2HEX(tmp, out[i]);
            ring_list_addstring2(tmp_list, (char*) tmp, strlen((char *) tmp));
        } else {
            ring_list_addint(tmp_list, out[i]);
        }
    }

    RING_API_RETLIST(ret_val);
}
Beispiel #12
0
static gboolean bee_irc_user_msg(bee_t *bee, bee_user_t *bu, const char *msg_, guint32 flags, time_t sent_at)
{
	irc_t *irc = bee->ui_data;
	irc_user_t *iu = (irc_user_t *) bu->ui_data;
	irc_user_t *src_iu = iu;
	irc_user_t *dst_iu = irc->user;
	const char *dst;
	char *prefix = NULL;
	char *wrapped, *ts = NULL;
	char *msg = g_strdup(msg_);
	char *message_type = "PRIVMSG";
	GSList *l;

	if (sent_at > 0 && set_getbool(&irc->b->set, "display_timestamps")) {
		ts = irc_format_timestamp(irc, sent_at);
	}

	dst = irc_user_msgdest(iu);

	if (flags & OPT_SELFMESSAGE) {
		char *setting = set_getstr(&irc->b->set, "self_messages");

		if (is_bool(setting)) {
			if (bool2int(setting)) {
				/* set to true, send it with src/dst flipped */
				
				dst_iu = iu;
				src_iu = irc->user;

				if (dst == irc->user->nick) {
					dst = dst_iu->nick;
				}
			} else {
				/* set to false, skip the message completely */
				goto cleanup;
			}
		} else if (g_strncasecmp(setting, "prefix", 6) == 0) {
			/* third state, prefix, loosely imitates the znc privmsg_prefix module */

			g_free(msg);
			if (g_strncasecmp(msg_, "/me ", 4) == 0) {
				msg = g_strdup_printf("/me -> %s", msg_ + 4);
			} else {
				msg = g_strdup_printf("-> %s", msg_);
			}

			if (g_strcasecmp(setting, "prefix_notice") == 0) {
				message_type = "NOTICE";
			}
		}

	}

	if (dst != dst_iu->nick) {
		/* if not messaging directly (control channel), call user by name */
		prefix = g_strdup_printf("%s%s%s", dst_iu->nick, set_getstr(&bee->set, "to_char"), ts ? : "");
	} else {
Beispiel #13
0
void decl_collector::visit_func(func_decl * n) {
    family_id fid = n->get_family_id();
    if (fid == null_family_id) {
        if (m_sep_preds && is_bool(n->get_range()))
            m_preds.push_back(n);
        else
            m_decls.push_back(n);
    }        
}
Beispiel #14
0
bool expr_if(pass_opt_t* opt, ast_t* ast)
{
    ast_t* cond = ast_child(ast);
    ast_t* left = ast_sibling(cond);
    ast_t* right = ast_sibling(left);
    ast_t* cond_type = ast_type(cond);

    if(is_typecheck_error(cond_type))
        return false;

    if(!is_bool(cond_type))
    {
        ast_error(cond, "condition must be a Bool");
        return false;
    }

    ast_t* l_type = ast_type(left);
    ast_t* r_type = ast_type(right);

    ast_t* type = NULL;
    size_t branch_count = 0;

    if(!is_control_type(l_type))
    {
        type = control_type_add_branch(type, left);
        ast_inheritbranch(ast, left);
        branch_count++;
    }

    if(!is_control_type(r_type))
    {
        type = control_type_add_branch(type, right);
        ast_inheritbranch(ast, right);
        branch_count++;
    }

    if(type == NULL)
    {
        if(ast_sibling(ast) != NULL)
        {
            ast_error(ast_sibling(ast), "unreachable code");
            return false;
        }

        type = ast_from(ast, TK_IF);
    }

    ast_settype(ast, type);
    ast_inheritflags(ast);
    ast_consolidate_branches(ast, branch_count);
    literal_unify_control(ast, opt);

    // Push our symbol status to our parent scope.
    ast_inheritstatus(ast_parent(ast), ast);
    return true;
}
Beispiel #15
0
term_t cbif_aes_cbc_crypt4(proc_t *proc, term_t *regs)
{
	term_t Key = regs[0];
	term_t IVec = regs[1];
	term_t Data = regs[2];
	term_t Dir = regs[3];

	if (!is_list(Key) && !is_boxed_binary(Key))
		badarg(Key);
	if (!is_boxed_binary(IVec))
		badarg(IVec);
	if (!is_list(Data) && !is_boxed_binary(Data))
		badarg(Data);
	if (!is_bool(Dir))
		badarg(Dir);

	int key_size = iolist_size(Key);
	if (key_size < AES_MIN_KEY_SIZE || key_size > AES_MAX_KEY_SIZE)
		badarg(Key);
	uint8_t key_buf[key_size];
	iolist_flatten(Key, key_buf);

	bits_t src, dst;
	bits_get_real(peel_boxed(IVec), &src);
	if (src.ends -src.starts != AES_BLOCK_SIZE *8)
		badarg(IVec);
	uint8_t ivec_buf[AES_BLOCK_SIZE];
	bits_init_buf(ivec_buf, AES_BLOCK_SIZE, &dst);
	bits_copy(&src, &dst);

	int data_size = iolist_size(Data);
	if (data_size < 0)
		badarg(Data);
	assert(data_size <= 65536);		//TODO: use heap_tmp_buf for larger Data
	uint8_t data_buf[data_size];
	iolist_flatten(Data, data_buf);

	struct CBC_CTX(struct aes_ctx, AES_BLOCK_SIZE) ctx;

	if (Dir == A_TRUE)
		aes_set_encrypt_key((struct aes_ctx *)&ctx, key_size, key_buf);
	else
		aes_set_decrypt_key((struct aes_ctx *)&ctx, key_size, key_buf);

	CBC_SET_IV(&ctx, ivec_buf);

	uint8_t *ptr;
	term_t cipher_text = heap_make_bin(&proc->hp, data_size, &ptr);

	if (Dir == A_TRUE)
		CBC_ENCRYPT(&ctx, aes_encrypt, data_size, ptr, data_buf);
	else
		CBC_DECRYPT(&ctx, aes_decrypt, data_size, ptr, data_buf);

	return cipher_text;
}
PRAGMA_FORMAT_NONLITERAL_IGNORED_EXTERNAL
void Flag::print_on(outputStream* st, bool withComments) {
  // Don't print notproduct and develop flags in a product build.
  if (is_constant_in_binary()) {
    return;
  }

  st->print("%9s %-40s %c= ", _type, _name, (!is_default() ? ':' : ' '));

  if (is_bool()) {
    st->print("%-16s", get_bool() ? "true" : "false");
  }
  if (is_intx()) {
    st->print("%-16ld", get_intx());
  }
  if (is_uintx()) {
    st->print("%-16lu", get_uintx());
  }
  if (is_uint64_t()) {
    st->print("%-16lu", get_uint64_t());
  }
  if (is_double()) {
    st->print("%-16f", get_double());
  }
  if (is_ccstr()) {
    const char* cp = get_ccstr();
    if (cp != NULL) {
      const char* eol;
      while ((eol = strchr(cp, '\n')) != NULL) {
        char format_buffer[FORMAT_BUFFER_LEN];
        size_t llen = pointer_delta(eol, cp, sizeof(char));
        jio_snprintf(format_buffer, FORMAT_BUFFER_LEN,
            "%%." SIZE_FORMAT "s", llen);
PRAGMA_DIAG_PUSH
PRAGMA_FORMAT_NONLITERAL_IGNORED_INTERNAL
        st->print(format_buffer, cp);
PRAGMA_DIAG_POP
        st->cr();
        cp = eol+1;
        st->print("%5s %-35s += ", "", _name);
      }
      st->print("%-16s", cp);
    }
    else st->print("%-16s", "");
  }

  st->print("%-20s", " ");
  print_kind(st);

  if (withComments) {
#ifndef PRODUCT
    st->print("%s", _doc);
#endif
  }
  st->cr();
}
Beispiel #17
0
bool expr_repeat(pass_opt_t* opt, ast_t* ast)
{
  AST_GET_CHILDREN(ast, body, cond, else_clause);

  ast_t* body_type = ast_type(body);
  ast_t* cond_type = ast_type(cond);
  ast_t* else_type = ast_type(else_clause);

  if(is_typecheck_error(cond_type))
    return false;

  if(!is_bool(cond_type))
  {
    ast_error(opt->check.errors, cond, "condition must be a Bool");
    return false;
  }

  if(is_typecheck_error(body_type) || is_typecheck_error(else_type))
    return false;

  // All consumes have to be in scope when the loop body finishes.
  errorframe_t errorf = NULL;
  if(!ast_all_consumes_in_scope(body, body, &errorf))
  {
    errorframe_report(&errorf, opt->check.errors);
    return false;
  }

  // Union with any existing type due to a break expression.
  ast_t* type = ast_type(ast);

  // No symbol status is inherited from the loop body or condition. Nothing
  // from outside can be consumed, and definitions inside may not occur.
  if(!is_control_type(body_type))
    type = control_type_add_branch(opt, type, body);

  if(!is_control_type(else_type))
  {
    type = control_type_add_branch(opt, type, else_clause);
    ast_inheritbranch(ast, else_clause);

    // Use a branch count of two instead of one. This means we will pick up any
    // consumes, but not any definitions, since definitions may not occur.
    ast_consolidate_branches(ast, 2);
  }

  if(type == NULL)
    type = ast_from(ast, TK_REPEAT);

  ast_settype(ast, type);
  literal_unify_control(ast, opt);

  // Push our symbol status to our parent scope.
  ast_inheritstatus(ast_parent(ast), ast);
  return true;
}
Beispiel #18
0
tree
evaluate_and (tree t) {
  if (N(t)<2) return evaluate_error ("bad and");
  for (int i=0; i<N(t); i++) {
    tree u= evaluate (t[i]);
    if (!is_bool (u)) return evaluate_error ("bad and");
    if (!as_bool (u)) return as_string_bool (false);
  }
  return as_string_bool (true);
}
Beispiel #19
0
 void print_on(Stream* st) const {
   st->print("%-6s %-40s = ", type, name);
   if (is_bool()) {
     st->print("%-10s", get_bool() ? "true" : "false");
   }
   else if (is_int()) {
     st->print("%-10ld", get_int());
   }
   st->print(" %s", kind);
   st->cr();
 }
Beispiel #20
0
char *set_eval_account( set_t *set, char *value )
{
	account_t *acc = set->data;
	
	/* Double-check: We refuse to edit on-line accounts. */
	if( set->flags & ACC_SET_OFFLINE_ONLY && acc->ic )
		return SET_INVALID;
	
	if( strcmp( set->key, "server" ) == 0 )
	{
		g_free( acc->server );
		if( value && *value )
		{
			acc->server = g_strdup( value );
			return value;
		}
		else
		{
			acc->server = g_strdup( set->def );
			return g_strdup( set->def );
		}
	}
	else if( strcmp( set->key, "username" ) == 0 )
	{
		g_free( acc->user );
		acc->user = g_strdup( value );
		return value;
	}
	else if( strcmp( set->key, "password" ) == 0 )
	{
		if( value )
		{
			g_free( acc->pass );
			acc->pass = g_strdup( value );
			return NULL;	/* password shouldn't be visible in plaintext! */
		}
		else
		{
			/* NULL can (should) be stored in the set_t
			   variable, but is otherwise not correct. */
			return SET_INVALID;
		}
	}
	else if( strcmp( set->key, "auto_connect" ) == 0 )
	{
		if( !is_bool( value ) )
			return SET_INVALID;
		
		acc->auto_connect = bool2int( value );
		return value;
	}
	
	return SET_INVALID;
}
Beispiel #21
0
const bool* json_node::get_bool(void) const
{
	if (!is_bool())
		return NULL;
	const char* txt = get_text();
	if (txt == NULL || *txt == 0)
		return NULL;
	const_cast<json_node*>(this)->node_val_.b =
		strcasecmp(txt, "true") == 0 ? true : false;
	return &node_val_.b;
}
// num_skipped counts the number of reads that do not show up in output. Used by validate to account for all the input reads.
b2g_error_t params2gasv_input(char *BAM_PATH, char *OUTPUT_PREFIX, int MAPPING_QUALITY, int WRITE_CONCORDANT, int WRITE_LOWQ, int LOW_MEMORY, int AMBIGUOUS, int LIB_SEP, int VERBOSE, int CUTOFF_X, int CUTOFF_Y, b2g_cutoff_lminlmax_mode_t CUTOFF_MODE, char *CUTOFF_NAME, int PROPER_LENGTH, int USE_NUMBER_READS, int DEBUG_LEVEL, int WRITE_SPLITREAD, int MIN_ALIGNED_PCT, char *CHROMOSOME_NAMING, b2g_platform_t PLATFORM, int VALIDATION_STRINGENCY, int GASV_PRO, int IGNORE_DUPLICATES, int QNAME_SORTED, int SPLIT_BY_CHROMOSOME, unsigned int *num_skipped) {
  assert(BAM_PATH && OUTPUT_PREFIX && in_range(MAPPING_QUALITY, 0, 255) && is_bool(WRITE_CONCORDANT) && is_bool(WRITE_LOWQ) && is_bool(LOW_MEMORY) && is_bool(AMBIGUOUS) && is_bool(LIB_SEP) && is_bool(VERBOSE) && CUTOFF_MODE && (FILENAME != CUTOFF_MODE || CUTOFF_NAME) && is_nonnegative(PROPER_LENGTH) && is_positive(USE_NUMBER_READS) && is_bool(WRITE_SPLITREAD) && in_range(MIN_ALIGNED_PCT, 50, 100) && is_bool(GASV_PRO) && is_bool(IGNORE_DUPLICATES) && is_bool(SPLIT_BY_CHROMOSOME));

  b2g_error_t ERR = B2GERR_NO_ERROR;
  hash_t *pairtable = NULL;
  samfile_t *in = NULL, *lowq_file = NULL, *split_file = NULL;
  FILE *chromosome_naming_file = NULL, *cutoff_file = NULL, *info_file = NULL, *gasv_file = NULL, *gasvpro_file = NULL;
  unsigned long GENOME_LENGTH = DEFAULT_GENOME_LENGTH;
  if (GASV_PRO && !WRITE_CONCORDANT) {
    if (VERBOSE) printf("-WRITE_CONCORDANT is required for -GASVPRO output. Automatically enabling.\n\n");
    WRITE_CONCORDANT = 1;    
  }
  if (AMBIGUOUS && !QNAME_SORTED) {
    if (VERBOSE) printf("-QNAME_SORTED is required for -AMBIGUOUS output. Automatically enabling.\n\n");
    QNAME_SORTED = 1; 
  }
  if (FILENAME == CUTOFF_MODE && !LIB_SEP) {
    if (VERBOSE) printf("-LIB_SEP sep is required for -CUTOFF_LMINLMAX FILE=... output. Automatically enabling.\n\n");
    LIB_SEP = 1;     
  }
  if (AMBIGUOUS && (WRITE_LOWQ || WRITE_SPLITREAD)) {
    if (VERBOSE) printf("-WRITE_LOWQ and -WRITE_SPLITREAD behavior are undefined for -AMBIGUOUS. Automatically disabling\n\n");
    WRITE_LOWQ = WRITE_SPLITREAD = 0; 
  }

  // Open all external resources and abort if failure.
  if ((ERR = _open_files(&in, &chromosome_naming_file, &cutoff_file, &lowq_file, &split_file, &info_file, &gasv_file, &gasvpro_file, BAM_PATH, OUTPUT_PREFIX, CHROMOSOME_NAMING, CUTOFF_MODE, CUTOFF_NAME, WRITE_LOWQ, WRITE_SPLITREAD, GASV_PRO))) return _cleanup(in, chromosome_naming_file, cutoff_file, lowq_file, split_file, info_file, gasv_file, gasvpro_file, pairtable, ERR);

  // Allocate hash table
  struct stat st;
  stat(BAM_PATH, &st);  
  if (!(pairtable = hash(!QNAME_SORTED * ((st.st_size / B2G_HASH_SIZE) / (LOW_MEMORY ? MAX_BAM_FILES : 1))))) return _cleanup(in, chromosome_naming_file, cutoff_file, lowq_file, split_file, info_file, gasv_file, gasvpro_file, pairtable, B2GERR_OUT_OF_MEMORY);

  // Calculate required space for bam_header metadata,
  int NUM_CHROMOSOMES, NUM_READGROUPS, NUM_LIBRARIES;
  b2g_bam_header_counts(in->header, &NUM_CHROMOSOMES, &NUM_READGROUPS, &NUM_LIBRARIES, &LIB_SEP, PROPER_LENGTH);
    
  // allocate memory for said data,
  b2g_cutoff_lminlmax_t cutoff_lminlmax = {CUTOFF_MODE, CUTOFF_X , CUTOFF_Y, CUTOFF_NAME};
  int chromosome_numbers[NUM_CHROMOSOMES];
  b2g_chromosomes_t chromosomes = {NUM_CHROMOSOMES, chromosome_numbers};
  b2g_readgroup2library_t rgs2libs[NUM_READGROUPS];
  b2g_library_t libs[NUM_LIBRARIES];
  b2g_libraries_t libraries = {NUM_READGROUPS, NUM_LIBRARIES, &rgs2libs[0], &libs[0]};

  // and read the header into that memory.
  if ((ERR = b2g_bam_header_read(in->header, &chromosomes, &libraries, &GENOME_LENGTH, cutoff_lminlmax, chromosome_naming_file, cutoff_file, LIB_SEP, USE_NUMBER_READS, PROPER_LENGTH, VERBOSE))) return _cleanup(in, chromosome_naming_file, cutoff_file, lowq_file, split_file, info_file, gasv_file, gasvpro_file, pairtable, ERR);

  // Do all the main program logic of splitting the bam file, sorting the contents, merging the final output, and dumping the statistics.
  if ((ERR = _split_sort_merge_dump(BAM_PATH, OUTPUT_PREFIX, MAPPING_QUALITY, WRITE_CONCORDANT, WRITE_LOWQ, LOW_MEMORY, AMBIGUOUS, LIB_SEP, VERBOSE, CUTOFF_X, CUTOFF_Y, CUTOFF_MODE, CUTOFF_NAME, PROPER_LENGTH, USE_NUMBER_READS, DEBUG_LEVEL, WRITE_SPLITREAD, MIN_ALIGNED_PCT, CHROMOSOME_NAMING, PLATFORM, GASV_PRO, IGNORE_DUPLICATES, lowq_file, split_file, &libraries, &chromosomes, pairtable, info_file, gasv_file, gasvpro_file, GENOME_LENGTH, QNAME_SORTED, SPLIT_BY_CHROMOSOME, num_skipped))) return _cleanup(in, chromosome_naming_file, cutoff_file, lowq_file, split_file, info_file, gasv_file, gasvpro_file, pairtable, ERR);

  return _cleanup(in, chromosome_naming_file, cutoff_file, lowq_file, split_file, info_file, gasv_file, gasvpro_file, pairtable, B2GERR_NO_ERROR);
}
Beispiel #23
0
void test_block_as_assertions_list(Block* block, std::string const& contextStr)
{
    if (has_static_errors(block)) {
        std::cout << "Static error " << contextStr << ":" << std::endl;
        print_static_errors_formatted(block, std::cout);
        declare_current_test_failed();
        return;
    }

    std::stringstream checkInvariantsOutput;
    if (!block_check_invariants_print_result(block, checkInvariantsOutput)) {
        std::cout << "Failed invariant " << contextStr << std::endl;
        std::cout << checkInvariantsOutput.str() << std::endl;
        declare_current_test_failed();
        return;
    }

    Stack context;
    evaluate_block(&context, block);

    if (context.errorOccurred) {
        std::cout << "Runtime error " << contextStr << std::endl;
        print_error_stack(&context, std::cout);
        declare_current_test_failed();
        return;
    }

    int boolean_statements_found = 0;
    for (int i=0; i < block->length(); i++) {
        Term* term = block->get(i);
        if (!is_statement(term))
            continue;

        if (!is_bool(term_value(term)))
            continue;

        boolean_statements_found++;

        if (!as_bool(term_value(term))) {
            std::cout << "Assertion failed " << contextStr << std::endl;
            std::cout << "failed: " << get_term_source_text(term) << std::endl;
            declare_current_test_failed();
            return;
        }
    }

    if (boolean_statements_found == 0) {
        std::cout << "No boolean statements found " << contextStr << std::endl;
        declare_current_test_failed();
        return;
    }
}
Beispiel #24
0
	bool operator() (ti_atomic_t ta) const {
	    switch (ta) {
	    case TI_BOOL:     if (is_bool(v_))     return true; break;
	    case TI_INT:      if (is_int(v_))      return true; break;
	    case TI_UINT:     if (is_uint(v_))     return true; break;
	    case TI_DOUBLE:   if (is_double(v_))   return true; break;
	    case TI_STRING:   if (is_string(v_))   return true; break;
            case TI_TIME:     if (is_time(v_))     return true; break; 
            case TI_IPV4ADDR: if (is_ipv4addr(v_)) return true; break;
            case TI_IPV6ADDR: if (is_ipv6addr(v_)) return true; break;
	    default: assert(false);
	    }
	    return false;
	}
Beispiel #25
0
void static_features::update_core(expr * e) {
    m_num_exprs++;
    
    // even if a benchmark does not contain any theory interpreted function decls, we still have to install
    // the theory if the benchmark contains constants or function applications of an interpreted sort.
    sort * s      = m_manager.get_sort(e);
    mark_theory(s->get_family_id());
    
    bool _is_gate = is_gate(e);
    bool _is_eq   = m_manager.is_eq(e);
    if (_is_gate) {
        m_cnf = false;
        m_num_nested_formulas++;
        switch (to_app(e)->get_decl_kind()) {
        case OP_ITE: 
            if (is_bool(e))
                m_num_ite_formulas++;
            else {
                m_num_ite_terms++;
                // process then&else nodes
                for (unsigned i = 1; i < 3; i++) {
                    expr * arg = to_app(e)->get_arg(i);
                    acc_num(arg);
                    // Must check whether arg is diff logic or not.
                    // Otherwise, problem can be incorrectly tagged as diff logic.
                    sort * arg_s = m_manager.get_sort(arg); 
                    family_id fid_arg = arg_s->get_family_id();
                    if (fid_arg == m_afid) {
                        m_num_arith_terms++;
                        rational k;
                        TRACE("diff_term", tout << "diff_term: " << is_diff_term(arg, k) << "\n" << mk_pp(arg, m_manager) << "\n";);
                        if (is_diff_term(arg, k)) {
                            m_num_diff_terms++;
                            acc_num(k);
                        }
                    }
                }
            }
            break;
        case OP_AND: 
            m_num_ands++;
            break;
        case OP_OR:
            m_num_ors++;
            break;
        case OP_IFF: 
            m_num_iffs++;
            break;
        }
Beispiel #26
0
bool is_machine_word(ast_t* type)
{
  return is_bool(type) ||
    is_literal(type, "I8") ||
    is_literal(type, "I16") ||
    is_literal(type, "I32") ||
    is_literal(type, "I64") ||
    is_literal(type, "I128") ||
    is_literal(type, "U8") ||
    is_literal(type, "U16") ||
    is_literal(type, "U32") ||
    is_literal(type, "U64") ||
    is_literal(type, "U128") ||
    is_literal(type, "F32") ||
    is_literal(type, "F64");
}
Beispiel #27
0
/**
 * Implemented #set_eval for the set of game_status.
 *
 * @param set   The #set_t.
 * @param value The set value.
 *
 * @return The resulting set value.
 **/
static char *steam_eval_game_status(set_t *set, char *value)
{
    account_t *acc = set->data;
    SteamData *sata;

    if (!is_bool(value))
        return SET_INVALID;

    if (acc->ic == NULL)
        return value;

    sata = acc->ic->proto_data;
    sata->game_status = bool2int(value);

    return value;
}
Beispiel #28
0
static void setup_dwarf(dwarf_t* dwarf, dwarf_meta_t* meta, gentype_t* g,
  bool opaque, bool field)
{
  memset(meta, 0, sizeof(dwarf_meta_t));

  ast_t* ast = g->ast;
  LLVMTypeRef type = g->primitive;

  if(is_machine_word(ast))
  {
    if(is_float(ast))
      meta->flags |= DWARF_FLOAT;
    else if(is_signed(dwarf->opt, ast))
      meta->flags |= DWARF_SIGNED;
    else if(is_bool(ast))
      meta->flags |= DWARF_BOOLEAN;
  }
  else if(is_pointer(ast) || is_maybe(ast) || !is_concrete(ast) ||
    (is_constructable(ast) && field))
  {
    type = g->use_type;
  }
  else if(is_constructable(ast))
  {
    type = g->structure;
  }

  bool defined_type = g->underlying != TK_TUPLETYPE &&
    g->underlying != TK_UNIONTYPE && g->underlying != TK_ISECTTYPE;

  source_t* source;

  if(defined_type)
    ast = (ast_t*)ast_data(ast);

  source = ast_source(ast);
  meta->file = source->file;
  meta->name = g->type_name;
  meta->line = ast_line(ast);
  meta->pos = ast_pos(ast);

  if(!opaque)
  {
    meta->size = LLVMABISizeOfType(dwarf->target_data, type) << 3;
    meta->align = LLVMABIAlignmentOfType(dwarf->target_data, type) << 3;
  }
}
void configcontainer::handle_action(const std::string& action, const std::vector<std::string>& params) {
	std::string resolved_action = lookup_alias(action);

	configdata& cfgdata = config_data[resolved_action];

	// configdata_t::INVALID indicates that the action didn't exist, and that the returned object was created ad-hoc.
	if (cfgdata.type == configdata_t::INVALID) {
		LOG(level::WARN, "configcontainer::handler_action: unknown action %s", action);
		throw confighandlerexception(action_handler_status::INVALID_COMMAND);
	}

	LOG(level::DEBUG, "configcontainer::handle_action: action = %s, type = %u", action, cfgdata.type);

	if (params.size() < 1) {
		throw confighandlerexception(action_handler_status::TOO_FEW_PARAMS);
	}

	switch (cfgdata.type) {
	case configdata_t::BOOL:
		if (!is_bool(params[0]))
			throw confighandlerexception(strprintf::fmt(_("expected boolean value, found `%s' instead"), params[0]));
		cfgdata.value = params[0];
		break;

	case configdata_t::INT:
		if (!is_int(params[0]))
			throw confighandlerexception(strprintf::fmt(_("expected integer value, found `%s' instead"), params[0]));
		cfgdata.value = params[0];
		break;

	case configdata_t::ENUM:
		if (cfgdata.enum_values.find(params[0]) == cfgdata.enum_values.end())
			throw confighandlerexception(strprintf::fmt(_("invalid configuration value `%s'"), params[0]));
	// fall-through
	case configdata_t::STR:
	case configdata_t::PATH:
		if (cfgdata.multi_option)
			cfgdata.value = utils::join(params, " ");
		else
			cfgdata.value = params[0];
		break;

	default:
		// should not happen
		throw confighandlerexception(action_handler_status::INVALID_COMMAND);
	}
}
Beispiel #30
0
const char* json_node::get_type(void) const
{
	if (is_string())
		return "string";
	else if (is_number())
		return "number";
	else if (is_bool())
		return "bool";
	else if (is_null())
		return "null";
	else if (is_object())
		return "object";
	else if (is_array())
		return "array";
	else
		return "unknown";
}