Beispiel #1
0
Tree * evaluate_full(Tree * tree)
{
	if (tree->type == branch && 
		tree->left->type == branch && 
		tree->left->left->type == leaf &&
		tree->left->left->value == K)
	{
		return evaluate_full(tree->left->right); // Reduce to normal form
	}
	else if (tree->type == branch &&
		tree->left->type == branch &&
		tree->left->left->type == branch &&
		tree->left->left->left->type == leaf &&
		tree->left->left->left->value == S)
	{
		Tree * x = tree->left->left->right;
		Tree * y = tree->left->right;
		Tree * z = tree->right;
		return evaluate_full(create_branch(create_branch(x, z), create_branch(y, z))); // Reduce to normal form
	}
	else
	{
		if (tree->type == branch)
		{
			return create_branch(evaluate_full(tree->left), evaluate_full(tree->right));
		}
		else
		{
			return tree;
		}
	}
}
Beispiel #2
0
int git_branch_create(
	git_reference **ref_out,
	git_repository *repository,
	const char *branch_name,
	const git_commit *commit,
	int force)
{
	return create_branch(ref_out, repository, branch_name, commit, git_oid_tostr_s(git_commit_id(commit)), force);
}
Beispiel #3
0
int git_branch_create_from_annotated(
	git_reference **ref_out,
	git_repository *repository,
	const char *branch_name,
	const git_annotated_commit *commit,
	int force)
{
	return create_branch(ref_out,
		repository, branch_name, commit->commit, commit->description, force);
}
Beispiel #4
0
void UI_create_branch(emulator_instance& inst, uint64_t id, const std::string& name,
	std::function<void(std::exception&)> onerror)
{
	auto project = inst.project;
	inst.iqueue->run_async([project, id, name]() {
		auto p = project->get();
		if(!p) return;
		p->create_branch(id, name);
		p->flush();
	}, onerror);
}
static unsigned int
ftrace_call_replace(unsigned long ip, unsigned long addr, int link)
{
	unsigned int op;

	addr = ppc_function_entry((void *)addr);

	/* if (link) set op to 'bl' else 'b' */
	op = create_branch((unsigned int *)ip, addr, link ? 1 : 0);

	return op;
}
Beispiel #6
0
static void __init create_trampoline(unsigned long addr)
{
	/* The maximum range of a single instruction branch, is the current
	 * instruction's address + (32 MB - 4) bytes. For the trampoline we
	 * need to branch to current address + 32 MB. So we insert a nop at
	 * the trampoline address, then the next instruction (+ 4 bytes)
	 * does a branch to (32 MB - 4). The net effect is that when we
	 * branch to "addr" we jump to ("addr" + 32 MB). Although it requires
	 * two instructions it doesn't require any registers.
	 */
	create_instruction(addr, 0x60000000); /* nop */
	create_branch(addr + 4, addr + PHYSICAL_START, 0);
}
Beispiel #7
0
void init_game()
{
    statestack_push(STATE_READ_COMMAND);

    current_branch = create_branch("Town");
    current_dungeon = current_branch->dungeons[0];

//  do
//  {
//    player.pos.x = random(0, current_dungeon->width - 1);
//    player.pos.y = random(0, current_dungeon->height - 1);
//  } while (!(get_tile_at(current_dungeon, player.pos.x, player.pos.y)->properties & TILE_PROP_WALKABLE));
}
Beispiel #8
0
int
expand_branch(solution_t *root, int depth)
{
  int slots = sched->num_slots;
  solution_t *new_root = NULL;

  num_expanded_solutions++;

  if (depth == slots) {
    return 0;
  }

  if (root->active == 0) {
    return 0;
  }

  if (debug) {
    printf("%s: new depth: %d, weight %1.3f\n",
	   __FUNCTION__, depth+1, root->total_weight);
  }

  create_branch(root, depth);

  // iterate on the branch as long as it is active
  //
  while(root->active) {

    if (!select_branch(root, &new_root) || !new_root) {
      root->active = 0;
      break;
    }

    if (solution_is_feasible(new_root)) {
      incumbent_update_and_prune(new_root);
    }

    if (new_root->active) {
      expand_branch(new_root, depth+1);
    }

    if (!solution_is_active(root)) {
      root->active = 0;
    }
  }

  return 0;
}
Beispiel #9
0
static int create_tracking_branch(
	git_reference **branch,
	git_repository *repo,
	const git_oid *target,
	const char *branch_name)
{
	int error;

	if ((error = create_branch(branch, repo, target, branch_name)) < 0)
		return error;

	return setup_tracking_config(
		repo,
		branch_name,
		GIT_REMOTE_ORIGIN,
		git_reference_name(*branch));
}
Beispiel #10
0
void project_state::do_branch_mk(const std::string& args)
{
	regex_results r = regex("([0-9]+)[ \t]+(.*)", args);
	if(!r) {
		messages << "Syntax: create-branch <parentid> <name>" << std::endl;
		return;
	}
	try {
		auto prj = get();
		uint64_t pbid = parse_value<uint64_t>(r[1]);
		if(!prj)
			throw std::runtime_error("Not in project context");
		uint64_t bid = prj->create_branch(pbid, r[2]);
		messages << "Created branch #" << bid << std::endl;
		prj->flush();
	} catch(std::exception& e) {
		messages << "Can't create new branch: " << e.what() << std::endl;
	}
}
Beispiel #11
0
static void __init
smp_86xx_kick_cpu(int nr)
{
	unsigned int save_vector;
	unsigned long target, flags;
	int n = 0;
	volatile unsigned int *vector
		 = (volatile unsigned int *)(KERNELBASE + 0x100);

	if (nr < 0 || nr >= NR_CPUS)
		return;

	pr_debug("smp_86xx_kick_cpu: kick CPU #%d\n", nr);

	local_irq_save(flags);
	local_irq_disable();

	/* Save reset vector */
	save_vector = *vector;

	/* Setup fake reset vector to call __secondary_start_mpc86xx. */
	target = (unsigned long) __secondary_start_mpc86xx;
	create_branch((unsigned long)vector, target, BRANCH_SET_LINK);

	/* Kick that CPU */
	smp_86xx_release_core(nr);

	/* Wait a bit for the CPU to take the exception. */
	while ((__secondary_hold_acknowledge != nr) && (n++, n < 1000))
		mdelay(1);

	/* Restore the exception vector */
	*vector = save_vector;
	flush_icache_range((unsigned long) vector, (unsigned long) vector + 4);

	local_irq_restore(flags);

	pr_debug("wait CPU #%d for %d msecs.\n", nr, n);
}
Beispiel #12
0
static void update_refs_for_switch(const struct checkout_opts *opts,
				   struct branch_info *old_branch_info,
				   struct branch_info *new_branch_info)
{
	struct strbuf msg = STRBUF_INIT;
	const char *old_desc, *reflog_msg;
	if (opts->new_branch) {
		if (opts->new_orphan_branch) {
			char *refname;

			refname = mkpathdup("refs/heads/%s", opts->new_orphan_branch);
			if (opts->new_branch_log &&
			    !should_autocreate_reflog(refname)) {
				int ret;
				struct strbuf err = STRBUF_INIT;

				ret = safe_create_reflog(refname, 1, &err);
				if (ret) {
					fprintf(stderr, _("Can not do reflog for '%s': %s\n"),
						opts->new_orphan_branch, err.buf);
					strbuf_release(&err);
					free(refname);
					return;
				}
				strbuf_release(&err);
			}
			free(refname);
		}
		else
			create_branch(the_repository,
				      opts->new_branch, new_branch_info->name,
				      opts->new_branch_force ? 1 : 0,
				      opts->new_branch_force ? 1 : 0,
				      opts->new_branch_log,
				      opts->quiet,
				      opts->track);
		new_branch_info->name = opts->new_branch;
		setup_branch_path(new_branch_info);
	}

	old_desc = old_branch_info->name;
	if (!old_desc && old_branch_info->commit)
		old_desc = oid_to_hex(&old_branch_info->commit->object.oid);

	reflog_msg = getenv("GIT_REFLOG_ACTION");
	if (!reflog_msg)
		strbuf_addf(&msg, "checkout: moving from %s to %s",
			old_desc ? old_desc : "(invalid)", new_branch_info->name);
	else
		strbuf_insert(&msg, 0, reflog_msg, strlen(reflog_msg));

	if (!strcmp(new_branch_info->name, "HEAD") && !new_branch_info->path && !opts->force_detach) {
		/* Nothing to do. */
	} else if (opts->force_detach || !new_branch_info->path) {	/* No longer on any branch. */
		update_ref(msg.buf, "HEAD", &new_branch_info->commit->object.oid, NULL,
			   REF_NO_DEREF, UPDATE_REFS_DIE_ON_ERR);
		if (!opts->quiet) {
			if (old_branch_info->path &&
			    advice_detached_head && !opts->force_detach)
				detach_advice(new_branch_info->name);
			describe_detached_head(_("HEAD is now at"), new_branch_info->commit);
		}
	} else if (new_branch_info->path) {	/* Switch branches. */
		if (create_symref("HEAD", new_branch_info->path, msg.buf) < 0)
			die(_("unable to update HEAD"));
		if (!opts->quiet) {
			if (old_branch_info->path && !strcmp(new_branch_info->path, old_branch_info->path)) {
				if (opts->new_branch_force)
					fprintf(stderr, _("Reset branch '%s'\n"),
						new_branch_info->name);
				else
					fprintf(stderr, _("Already on '%s'\n"),
						new_branch_info->name);
			} else if (opts->new_branch) {
				if (opts->branch_exists)
					fprintf(stderr, _("Switched to and reset branch '%s'\n"), new_branch_info->name);
				else
					fprintf(stderr, _("Switched to a new branch '%s'\n"), new_branch_info->name);
			} else {
				fprintf(stderr, _("Switched to branch '%s'\n"),
					new_branch_info->name);
			}
		}
		if (old_branch_info->path && old_branch_info->name) {
			if (!ref_exists(old_branch_info->path) && reflog_exists(old_branch_info->path))
				delete_reflog(old_branch_info->path);
		}
	}
	remove_branch_state(the_repository);
	strbuf_release(&msg);
	if (!opts->quiet &&
	    (new_branch_info->path || (!opts->force_detach && !strcmp(new_branch_info->name, "HEAD"))))
		report_tracking(new_branch_info);
}
Beispiel #13
0
void _take_stairs(stairs_t* stairs)
{
    dungeon_t* prev_dungeon = current_dungeon;

    TRACE("take_stairs: stairs->to_branch=%s", stairs->to_branch.c_str());

    // Arrive from town to infinite dungeon: clear infinite dungeon.
    if (stairs->to && stairs->to_branch == BRANCH_INFINITE_DUNGEON && current_branch->name != BRANCH_INFINITE_DUNGEON)
    {
        stairs->to = nullptr;
        branch_t* inf_branch = find_branch(stairs->to_branch);

        for (dungeon_t* dungeon : inf_branch->dungeons)
        {
            destroy_dungeon(dungeon);
        }
        inf_branch->dungeons.clear();
    }

    // Generate the next dungeon if needed.
    if (stairs->to == nullptr && stairs->to_branch == current_branch->name)
    {
        dungeon_t* next_level = generate_next_level(current_branch);
        create_up_stairs(next_level, current_branch, prev_dungeon, stairs);
    }
    else if (stairs->to == nullptr)
    {
        // Stairs to a new branch.
        branch_t* prev_branch = current_branch;
        current_branch = create_branch(stairs->to_branch);

        dungeon_t* next_level = current_branch->dungeons.front();

        // Check if the level has stairs that lead back to the branch already.
        bool has_stairs = false;
        for (int i = 0; i < next_level->num_stairs; i++)
        {
            if (next_level->stairs[i]->to_branch == prev_branch->name)
                has_stairs = true;
        }

        if (!has_stairs)
            create_up_stairs(next_level, prev_branch, prev_dungeon, stairs);
        else
            stairs->to = next_level;
    }

    dungeon_t* dst = stairs->to;
    current_dungeon = dst;
    current_branch = find_branch(stairs->to_branch);

    player.pos.x = stairs->warp_x;
    player.pos.y = stairs->warp_y;

    // Do not follow player to the world map.
    if (current_branch->name != "World")
    {
        std::vector<coord_t> free_coords;
        for (int y = player.pos.y - 1; y <= player.pos.y + 1; y++)
            for (int x = player.pos.x - 1; x <= player.pos.x + 1; x++)
                if (place_free(current_dungeon, x, y))
                    free_coords.push_back( coord_t { x, y} );

        std::vector<creature_t*> following_creatures;
        for (int y = stairs->y - 1; y <= stairs->y + 1; y++)
        {
            for (int x = stairs->x - 1; x <= stairs->x + 1; x++)
            {
                creature_t* creature = get_creature_at(prev_dungeon, x, y);

                if (creature && following_creatures.size() < free_coords.size())
                {
                    following_creatures.push_back(creature);
                    remove_creature_no_destroy(prev_dungeon, creature);
                }
            }
        }

        for (size_t i = 0; i < following_creatures.size(); i++)
        {
            add_creature_to_dungeon(current_dungeon, following_creatures[i], free_coords[i].x, free_coords[i].y);
        }

        if (following_creatures.size() == 1)
            append_msg_log("%s follows you.", capitalize(following_creatures.front()->get_full_name()).c_str());
        else if (following_creatures.size() > 1)
            append_msg_log("Some creatures follow you.");
    }

    clear_action_list();
    append_action_list(&player);
}