Ejemplo n.º 1
0
void
print_my_defines(lf *file,
		 insn_bits *expanded_bits,
		 table_entry *file_entry)
{
  /* #define MY_INDEX xxxxx */
  lf_indent_suppress(file);
  lf_printf(file, "#undef MY_INDEX\n");
  lf_indent_suppress(file);
  lf_printf(file, "#define MY_INDEX ");
  print_function_name(file,
                      file_entry->fields[insn_name],
                      NULL,
                      function_name_prefix_itable);
  lf_printf(file, "\n");
  /* #define MY_PREFIX xxxxxx */
  lf_indent_suppress(file);
  lf_printf(file, "#undef MY_PREFIX\n");
  lf_indent_suppress(file);
  lf_printf(file, "#define MY_PREFIX ");
  print_function_name(file,
		      file_entry->fields[insn_name],
		      expanded_bits,
		      function_name_prefix_none);
  lf_printf(file, "\n");
}
Ejemplo n.º 2
0
void test_set_autoShiftCur()
{
	ChewingContext *ctx;
	int value;
	int mode;

	print_function_name();

	ctx = chewing_new();

	for ( value = 0; value < 2; ++value ) {
		chewing_set_autoShiftCur( ctx, value );
		mode = chewing_get_autoShiftCur( ctx );
		ok( mode = chewing_get_autoShiftCur( ctx ) == value,
			"autoShiftCur shall be `%d'", value );

		chewing_set_autoShiftCur( ctx, -1 );
		mode = chewing_get_autoShiftCur( ctx );
		ok( mode = chewing_get_autoShiftCur( ctx ) == value,
			"autoShiftCur shall be `%d'", value );

		chewing_set_autoShiftCur( ctx, 2 );
		mode = chewing_get_autoShiftCur( ctx );
		ok( mode = chewing_get_autoShiftCur( ctx ) == value,
			"autoShiftCur shall be `%d'", value );
	}

	chewing_delete( ctx );
}
Ejemplo n.º 3
0
void test_set_escCleanAllBuf()
{
	ChewingContext *ctx;
	int value;
	int mode;

	print_function_name();

	ctx = chewing_new();

	for ( value = 0; value < 2; ++value ) {
		chewing_set_escCleanAllBuf( ctx, value );
		mode = chewing_get_escCleanAllBuf( ctx );
		ok( mode == value,
			"escCleanAllBuf shall be `%d'", value );

		chewing_set_escCleanAllBuf( ctx, -1 );
		mode = chewing_get_escCleanAllBuf( ctx );
		ok( mode == value,
			"escCleanAllBuf shall be `%d'", value );

		chewing_set_escCleanAllBuf( ctx, 2 );
		mode = chewing_get_escCleanAllBuf( ctx );
		ok( mode == value,
			"escCleanAllBuf shall be `%d'", value );
	}

	chewing_delete( ctx );
}
Ejemplo n.º 4
0
void test_set_spaceAsSelection()
{
	ChewingContext *ctx;
	int value;
	int mode;

	print_function_name();

	ctx = chewing_new();

	for ( value = 0; value < 2; ++value ) {
		chewing_set_spaceAsSelection( ctx, value );
		mode = chewing_get_spaceAsSelection( ctx );
		ok( mode == value,
			"spaceAsSelection `%d' shall be `%d'", mode, value );

		chewing_set_spaceAsSelection( ctx, -1 );
		mode = chewing_get_spaceAsSelection( ctx );
		ok( mode == value,
			"spaceAsSelection `%d' shall be `%d'", mode, value );

		chewing_set_spaceAsSelection( ctx, 2 );
		mode = chewing_get_spaceAsSelection( ctx );
		ok( mode == value,
			"spaceAsSelection `%d' shall be `%d'", mode, value );
	}

	chewing_delete( ctx );
}
Ejemplo n.º 5
0
void test_set_selKey()
{
	ChewingContext *ctx;
	int *select_key;

	print_function_name();

	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );

	// XXX: chewing_set_selKey shall accept const char *.
	chewing_set_selKey( ctx,
		ALTERNATE_SELECT_KEY, ARRAY_SIZE( ALTERNATE_SELECT_KEY ));
	select_key = chewing_get_selKey( ctx );
	ok( select_key, "chewing_get_selKey shall not return NULL" );
	ok( !memcmp( select_key, ALTERNATE_SELECT_KEY,
		sizeof( ALTERNATE_SELECT_KEY )),
		"select key shall be ALTERNATE_SELECT_KEY");

	type_keystroke_by_string( ctx, DATA.token );
	ok_preedit_buffer( ctx, DATA.expected );

	chewing_free( select_key );

	chewing_delete( ctx );
}
Ejemplo n.º 6
0
void test_set_ShapeMode()
{
	const int VALUE[] = {
		HALFSHAPE_MODE,
		FULLSHAPE_MODE,
	};

	const int INVALID_VALUE[] = {
		-1,
		2,
	};

	ChewingContext *ctx;
	size_t i;
	size_t j;

	print_function_name();

	ctx = chewing_new();

	for ( i = 0; i < ARRAY_SIZE( VALUE ); ++i ) {
		chewing_set_ShapeMode( ctx, VALUE[i] );
		ok( chewing_get_ShapeMode( ctx ) == VALUE[i],
			"ShapeMode shall be `%d'", VALUE[i] );

		for ( j = 0; j < ARRAY_SIZE( INVALID_VALUE ); ++j ) {
			// mode shall not change when set mode has invalid value.
			chewing_set_ShapeMode( ctx, INVALID_VALUE[j] );
			ok( chewing_get_ShapeMode( ctx ) == VALUE[i],
				"ShapeMode shall be `%d'", VALUE[i] );
		}
	}

	chewing_delete( ctx );
}
Ejemplo n.º 7
0
void test_set_candPerPage()
{
	const int VALUE[] = {
		MIN_CAND_PER_PAGE,
		MAX_CAND_PER_PAGE,
	};

	const int INVALID_VALUE[] = {
		MIN_CAND_PER_PAGE - 1,
		MAX_CAND_PER_PAGE + 1,
	};

	ChewingContext *ctx;
	size_t i;
	size_t j;

	print_function_name();

	ctx = chewing_new();

	for ( i = 0; i < ARRAY_SIZE( VALUE ); ++i ) {
		chewing_set_candPerPage( ctx, VALUE[i] );
		ok( chewing_get_candPerPage( ctx ) == VALUE[i],
			"candPerPage shall be `%d'", VALUE[i] );

		for ( j = 0; j < ARRAY_SIZE( INVALID_VALUE ); ++j ) {
			// mode shall not change when set mode has invalid value.
			chewing_set_candPerPage( ctx, INVALID_VALUE[j] );
			ok( chewing_get_candPerPage( ctx ) == VALUE[i],
				"candPerPage shall be `%d'", VALUE[i] );
		}
	}

	chewing_delete( ctx );
}
Ejemplo n.º 8
0
void test_UnitFromPlatMmap()
{
	unsigned int idx;
	plat_mmap m_mmap;
	size_t offset = 0;
	size_t csize;
	char *data_buf;
	char hard_copy[] = "ji3cp3vu3cj0 vup dj4up <E>";
	int i;

	print_function_name();

	idx = plat_mmap_create(&m_mmap, TESTDATA, FLAG_ATTRIBUTE_READ);
	ok (idx == 28, "plat_mmap_create");
	if (idx > 0) {
		csize = idx;
		data_buf = (char *) plat_mmap_set_view(&m_mmap, &offset, &csize);
		for (i = 0; i < 26; i++) {
			if (data_buf[i] != hard_copy[i])
				break;
		}
		ok (i == 26, "plat_mmap_set_view");
	}
	plat_mmap_close( &m_mmap );
}
Ejemplo n.º 9
0
static void
print_support_function_name(lf *file,
			    table_entry *function,
			    int is_function_definition)
{
  if (it_is("internal", function->fields[insn_flags])) {
    lf_print_function_type(file, SEMANTIC_FUNCTION_TYPE, "PSIM_INLINE_SUPPORT",
			   (is_function_definition ? "\n" : " "));
    print_function_name(file,
			function->fields[function_name],
			NULL,
			function_name_prefix_semantics);
    lf_printf(file, "\n(%s)", SEMANTIC_FUNCTION_FORMAL);
    if (!is_function_definition)
      lf_printf(file, ";");
    lf_printf(file, "\n");
  }
  else {
    lf_print_function_type(file,
			   function->fields[function_type],
			   "PSIM_INLINE_SUPPORT",
			   (is_function_definition ? "\n" : " "));
    lf_printf(file, "%s\n(%s)%s",
	      function->fields[function_name],
	      function->fields[function_param],
	      (is_function_definition ? "\n" : ";\n"));
  }
}
Ejemplo n.º 10
0
static void
itable_c_insn (lf *file,
	       insn_table *isa, insn_entry * instruction, void *data)
{
  lf_printf (file, "{ ");
  lf_indent (file, +2);
  print_function_name (file,
		       instruction->name,
		       instruction->format_name,
		       NULL, NULL, function_name_prefix_itable);
  lf_printf (file, ",\n");
  lf_printf (file, "\"");
  print_insn_words (file, instruction);
  lf_printf (file, "\",\n");
  lf_printf (file, "\"%s\",\n", instruction->format_name);

  itable_print_set (file, isa->flags, instruction->flags);
  itable_print_set (file, isa->options, instruction->options);
  itable_print_set (file, isa->model->processors, instruction->processors);

  lf_printf (file, "\"%s\",\n", instruction->name);
  lf_printf (file, "\"%s\",\n",
	     filter_filename (instruction->line->file_name));
  lf_printf (file, "%d,\n", instruction->line->line_nr);
  lf_printf (file, "},\n");
  lf_indent (file, -2);
}
Ejemplo n.º 11
0
static void
print_semantic_function_header(lf *file,
			       const char *basename,
			       insn_bits *expanded_bits,
			       int is_function_definition)
{
  int indent;
  lf_printf(file, "\n");
  lf_print_function_type(file, SEMANTIC_FUNCTION_TYPE, "PSIM_EXTERN_SEMANTICS",
			 (is_function_definition ? "\n" : " "));
  indent = print_function_name(file,
			       basename,
			       expanded_bits,
			       function_name_prefix_semantics);
  if (is_function_definition)
    lf_indent(file, +indent);
  else
    lf_printf(file, "\n");
  lf_printf(file, "(%s)", SEMANTIC_FUNCTION_FORMAL);
  if (is_function_definition)
    lf_indent(file, -indent);
  else
    lf_printf(file, ";");
  lf_printf(file, "\n");
}
Ejemplo n.º 12
0
void test_set_easySymbolInput()
{
	ChewingContext *ctx;
	int value;
	int mode;

	print_function_name();

	ctx = chewing_new();

	for ( value = 0; value < 2; ++value ) {
		chewing_set_easySymbolInput( ctx, value );
		mode = chewing_get_easySymbolInput( ctx );
		ok( mode == value,
			"easySymbolInput `%d', shall be `%d'", mode, value );

		chewing_set_easySymbolInput( ctx, -1 );
		mode = chewing_get_easySymbolInput( ctx );
		ok( mode == value,
			"easySymbolInput `%d', shall be `%d'", mode, value );

		chewing_set_easySymbolInput( ctx, 2 );
		mode = chewing_get_easySymbolInput( ctx );
		ok( mode == value,
			"easySymbolInput `%d', shall be `%d'", mode, value );
	}

	chewing_delete( ctx );
}
Ejemplo n.º 13
0
void test_set_phraseChoiceRearward()
{
	ChewingContext *ctx;
	int value;
	int mode;

	print_function_name();

	ctx = chewing_new();

	for ( value = 0; value < 2; ++value ) {
		chewing_set_phraseChoiceRearward( ctx, value );
		mode = chewing_get_phraseChoiceRearward( ctx );
		ok(  mode == value,
			"phraseChoiceRearward `%d' shall be `%d'", mode, value );

		chewing_set_phraseChoiceRearward( ctx, -1 );
		mode = chewing_get_phraseChoiceRearward( ctx );
		ok(  mode == value,
			"phraseChoiceRearward `%d' shall be `%d'", mode, value );

		chewing_set_phraseChoiceRearward( ctx, 2 );
		mode = chewing_get_phraseChoiceRearward( ctx );
		ok(  mode == value,
			"phraseChoiceRearward `%d' shall be `%d'", mode, value );
	}

	chewing_delete( ctx );
}
Ejemplo n.º 14
0
void
print_my_defines (lf *file,
		  const char *basename,
		  const char *format_name,
		  opcode_bits *expanded_bits)
{
  /* #define MY_INDEX xxxxx */
  lf_indent_suppress (file);
  lf_printf (file, "#undef MY_INDEX\n");
  lf_indent_suppress (file);
  lf_printf (file, "#define MY_INDEX ");
  print_function_name (file,
		       basename, format_name, NULL,
		       NULL,
		       function_name_prefix_itable);
  lf_printf (file, "\n");
  /* #define MY_PREFIX xxxxxx */
  lf_indent_suppress (file);
  lf_printf (file, "#undef ");
  print_function_name (file,
		       basename, format_name, NULL,
		       expanded_bits,
		       function_name_prefix_none);
  lf_printf (file, "\n");
  lf_indent_suppress (file);
  lf_printf (file, "#undef MY_PREFIX\n");
  lf_indent_suppress (file);
  lf_printf (file, "#define MY_PREFIX ");
  print_function_name (file,
		       basename, format_name, NULL,
		       expanded_bits,
		       function_name_prefix_none);
  lf_printf (file, "\n");
  /* #define MY_NAME xxxxxx */
  lf_indent_suppress (file);
  lf_indent_suppress (file);
  lf_printf (file, "#undef MY_NAME\n");
  lf_indent_suppress (file);
  lf_printf (file, "#define MY_NAME \"");
  print_function_name (file,
		       basename, format_name, NULL,
		       expanded_bits,
		       function_name_prefix_none);
  lf_printf (file, "\"\n");
}
Ejemplo n.º 15
0
Archivo: gen-icache.c Proyecto: 5kg/gdb
void
print_icache_internal_function_definition (lf *file,
					   function_entry * function,
					   void *data)
{
  ASSERT (options.gen.icache);
  if (function->is_internal)
    {
      lf_printf (file, "\n");
      lf_print__function_type_function (file, print_icache_function_type,
					"INLINE_ICACHE", "\n");
      print_function_name (file,
			   function->name,
			   NULL, NULL, NULL, function_name_prefix_icache);
      lf_printf (file, "\n(");
      print_icache_function_formal (file, 0);
      lf_printf (file, ")\n");
      lf_printf (file, "{\n");
      lf_indent (file, +2);
      lf_printf (file, "/* semantic routine */\n");
      if (options.gen.semantic_icache)
	{
	  lf_print__line_ref (file, function->code->line);
	  table_print_code (file, function->code);
	  lf_printf (file,
		     "error (\"Internal function must longjump\\n\");\n");
	  lf_printf (file, "return 0;\n");
	}
      else
	{
	  lf_printf (file, "return ");
	  print_function_name (file,
			       function->name,
			       NULL,
			       NULL, NULL, function_name_prefix_semantics);
	  lf_printf (file, ";\n");
	}

      lf_print__internal_ref (file);
      lf_indent (file, -2);
      lf_printf (file, "}\n");
    }
}
Ejemplo n.º 16
0
static void
print_support_function_name (lf *file,
			     function_entry * function,
			     int is_function_definition)
{
  if (function->is_internal)
    {
      lf_print__function_type_function (file, print_semantic_function_type,
					"INLINE_SUPPORT",
					(is_function_definition ? "\n" :
					 " "));
      print_function_name (file, function->name, NULL, NULL, NULL,
			   function_name_prefix_semantics);
      lf_printf (file, "\n(");
      lf_indent (file, +1);
      print_semantic_function_formal (file, 0);
      lf_indent (file, -1);
      lf_printf (file, ")");
      if (!is_function_definition)
	lf_printf (file, ";");
      lf_printf (file, "\n");
    }
  else
    {
      /* map the name onto a globally valid name */
      if (!is_function_definition
	  && strcmp (options.module.support.prefix.l, "") != 0)
	{
	  lf_indent_suppress (file);
	  lf_printf (file, "#define %s %s%s\n",
		     function->name,
		     options.module.support.prefix.l, function->name);
	}
      lf_print__function_type (file,
			       function->type,
			       "INLINE_SUPPORT",
			       (is_function_definition ? "\n" : " "));
      lf_printf (file, "%s%s\n(",
		 options.module.support.prefix.l, function->name);
      if (options.gen.smp)
	lf_printf (file,
		   "sim_cpu *cpu, %sinstruction_address cia, int MY_INDEX",
		   options.module.support.prefix.l);
      else
	lf_printf (file,
		   "SIM_DESC sd, %sinstruction_address cia, int MY_INDEX",
		   options.module.support.prefix.l);
      if (function->param != NULL && strlen (function->param) > 0)
	lf_printf (file, ", %s", function->param);
      lf_printf (file, ")%s", (is_function_definition ? "\n" : ";\n"));
    }
}
Ejemplo n.º 17
0
void
print_icache_internal_function_definition(insn_table *table,
					  lf *file,
					  void *data,
					  table_entry *function)
{
  ASSERT((code & generate_with_icache) != 0);
  if (it_is("internal", function->fields[insn_flags])) {
    lf_printf(file, "\n");
    lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "INLINE_ICACHE",
			   "\n");
    print_function_name(file,
			function->fields[insn_name],
			NULL,
			function_name_prefix_icache);
    lf_printf(file, "\n(%s)\n", ICACHE_FUNCTION_FORMAL);
    lf_printf(file, "{\n");
    lf_indent(file, +2);
    lf_printf(file, "/* semantic routine */\n");
    table_entry_print_cpp_line_nr(file, function);
    if ((code & generate_with_semantic_icache)) {
      lf_print__c_code(file, function->annex);
      lf_printf(file, "error(\"Internal function must longjump\\n\");\n");
      lf_printf(file, "return 0;\n");
    }
    else {
      lf_printf(file, "return ");
      print_function_name(file,
			  function->fields[insn_name],
			  NULL,
			  function_name_prefix_semantics);
      lf_printf(file, ";\n");
    }
    
    lf_print__internal_reference(file);
    lf_indent(file, -2);
    lf_printf(file, "}\n");
  }
}
Ejemplo n.º 18
0
void test_default_value()
{
	int *select_key;
	ChewingContext *ctx;

	print_function_name();

	ctx = chewing_new();

	select_key = chewing_get_selKey( ctx );
	ok( select_key, "chewing_get_selKey shall not return NULL" );
	ok( !memcmp( select_key, DEFAULT_SELECT_KEY,
		sizeof( DEFAULT_SELECT_KEY )),
		"default select key shall be default value" );
	chewing_free( select_key );

	ok( chewing_get_candPerPage( ctx ) == DEFAULT_CAND_PER_PAGE,
		"default candPerPage shall be %d", DEFAULT_CAND_PER_PAGE );

	ok( chewing_get_maxChiSymbolLen( ctx ) == MAX_CHI_SYMBOL_LEN,
		"default maxChiSymbolLen shall be %d", MAX_CHI_SYMBOL_LEN );

	ok( chewing_get_addPhraseDirection( ctx ) == 0,
		"default addPhraseDirection shall be 0" );

	ok( chewing_get_spaceAsSelection( ctx ) == 0,
		"default spaceAsSelection shall be 0" );

	ok( chewing_get_escCleanAllBuf( ctx ) == 0,
		"default escCleanAllBuf shall be 0" );

	ok( chewing_get_hsuSelKeyType( ctx ) == 0,
		"default hsuSelKeyType shall be 0" );

	ok( chewing_get_autoShiftCur( ctx ) == 0,
		"default autoShiftCur shall be 0" );

	ok( chewing_get_easySymbolInput( ctx ) == 0,
		"default easySymbolInput shall be 0" );

	ok( chewing_get_phraseChoiceRearward( ctx ) == 0,
		"default phraseChoiceRearward shall be 0" );

	ok( chewing_get_ChiEngMode( ctx ) == CHINESE_MODE,
		"default ChiEngMode shall be CHINESE_MODE" );

	ok( chewing_get_ShapeMode( ctx ) == HALFSHAPE_MODE,
		"default ShapeMode shall be HALFSHAPE_MODE" );

	chewing_delete( ctx );
}
Ejemplo n.º 19
0
void
print_semantic_body(lf *file,
		    insn *instruction,
		    insn_bits *expanded_bits,
		    opcode_field *opcodes)
{
  print_itrace(file, instruction->file_entry, 0/*put_value_in_cache*/);

  /* validate the instruction, if a cache this has already been done */
  if (!(code & generate_with_icache))
    print_idecode_validate(file, instruction, opcodes);

  /* generate the profiling call - this is delayed until after the
     instruction has been verified */
  lf_printf(file, "\n");
  lf_printf(file, "/* monitoring: */\n");
  lf_printf(file, "if (WITH_MON & MONITOR_INSTRUCTION_ISSUE) {\n");
  lf_printf(file, "  mon_issue(");
  print_function_name(file,
		      instruction->file_entry->fields[insn_name],
		      NULL,
		      function_name_prefix_itable);
  lf_printf(file, ", processor, cia);\n");
  lf_printf(file, "}\n");

  /* generate the code (or at least something */
  lf_printf(file, "\n");
  lf_printf(file, "/* semantics: */\n");
  lf_printf(file, "nia = cia + %d;\n", insn_bit_size / 8);
  if (instruction->file_entry->annex != NULL) {
    /* true code */
    table_entry_print_cpp_line_nr(file, instruction->file_entry);
    lf_printf(file, "{\n");
    lf_indent(file, +2);
    lf_print__c_code(file, instruction->file_entry->annex);
    lf_indent(file, -2);
    lf_printf(file, "}\n");
    lf_print__internal_reference(file);
  }
  else if (it_is("nop", instruction->file_entry->fields[insn_flags])) {
    lf_print__internal_reference(file);
  }
  else {
    /* abort so it is implemented now */
    table_entry_print_cpp_line_nr(file, instruction->file_entry);
    lf_putstr(file, "error(\"%s:%d:0x%08lx:%s unimplemented\\n\",\n");
    lf_printf(file, "      itable[MY_INDEX].file, itable[MY_INDEX].line_nr, (long)cia, itable[MY_INDEX].name);\n");
    lf_print__internal_reference(file);
  }
}
Ejemplo n.º 20
0
static void
print_icache_function_header(lf *file,
			     const char *basename,
			     insn_bits *expanded_bits,
			     int is_function_definition)
{
  lf_printf(file, "\n");
  lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "EXTERN_ICACHE", " ");
  print_function_name(file,
		      basename,
		      expanded_bits,
		      function_name_prefix_icache);
  lf_printf(file, "\n(%s)", ICACHE_FUNCTION_FORMAL); 
  if (!is_function_definition)
    lf_printf(file, ";");
  lf_printf(file, "\n");
}
Ejemplo n.º 21
0
void
print_icache_internal_function_declaration(insn_table *table,
					   lf *file,
					   void *data,
					   table_entry *function)
{
  ASSERT((code & generate_with_icache) != 0);
  if (it_is("internal", function->fields[insn_flags])) {
    lf_printf(file, "\n");
    lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "INLINE_ICACHE",
			   "\n");
    print_function_name(file,
			function->fields[insn_name],
			NULL,
			function_name_prefix_icache);
    lf_printf(file, "\n(%s);\n", ICACHE_FUNCTION_FORMAL);
  }
}
Ejemplo n.º 22
0
Archivo: gen-icache.c Proyecto: 5kg/gdb
void
print_icache_internal_function_declaration (lf *file,
					    function_entry * function,
					    void *data)
{
  ASSERT (options.gen.icache);
  if (function->is_internal)
    {
      lf_printf (file, "\n");
      lf_print__function_type_function (file, print_icache_function_type,
					"INLINE_ICACHE", "\n");
      print_function_name (file,
			   function->name,
			   NULL, NULL, NULL, function_name_prefix_icache);
      lf_printf (file, "\n(");
      print_icache_function_formal (file, 0);
      lf_printf (file, ");\n");
    }
}
Ejemplo n.º 23
0
static int
print_symbol(FILE *outfile, int line, struct output_symbol *s)
{
     int has_subtree = s->direct ? 
 	                  s->sym->callee != NULL :
	                  s->sym->caller != NULL;
     
     print_level(s->level, s->last);
     print_function_name(s->sym, has_subtree);
	  
     if (brief_listing) {
	  if (s->sym->expand_line) {
	       fprintf(outfile, " [see %d]", s->sym->expand_line);
	       return 1;
	  } else if (s->sym->callee)
	       s->sym->expand_line = line;
     }
     return 0;
}
Ejemplo n.º 24
0
static void
print_semantic_function_header (lf *file,
				const char *basename,
				const char *format_name,
				opcode_bits *expanded_bits,
				int is_function_definition,
				int nr_prefetched_words)
{
  int indent;
  lf_printf (file, "\n");
  lf_print__function_type_function (file, print_semantic_function_type,
				    "EXTERN_SEMANTICS",
				    (is_function_definition ? "\n" : " "));
  indent = print_function_name (file,
				basename,
				format_name,
				NULL,
				expanded_bits,
				function_name_prefix_semantics);
  if (is_function_definition)
    {
      indent += lf_printf (file, " ");
      lf_indent (file, +indent);
    }
  else
    {
      lf_printf (file, "\n");
    }
  lf_printf (file, "(");
  lf_indent (file, +1);
  print_semantic_function_formal (file, nr_prefetched_words);
  lf_indent (file, -1);
  lf_printf (file, ")");
  if (is_function_definition)
    {
      lf_indent (file, -indent);
    }
  else
    {
      lf_printf (file, ";");
    }
  lf_printf (file, "\n");
}
Ejemplo n.º 25
0
void test_deprecated()
{
	ChewingContext *ctx;
	int type;
	ChewingConfigData configure;
	memset( &configure, 0, sizeof( ChewingConfigData ) );

	print_function_name();

	ctx = chewing_new();

	chewing_set_hsuSelKeyType( ctx, HSU_SELKEY_TYPE1 );
	type = chewing_get_hsuSelKeyType( ctx );
	ok( type == HSU_SELKEY_TYPE1, "`%d' shall be `%d'", type, HSU_SELKEY_TYPE1 );

	chewing_Configure( ctx, &configure );

	chewing_delete( ctx );
}
Ejemplo n.º 26
0
void test_set_maxChiSymbolLen()
{
	ChewingContext *ctx;
	int i;

	print_function_name();

	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, 16 );
	ok( chewing_get_maxChiSymbolLen( ctx ) == 16,
		"maxChiSymbolLen shall be 16" );

	chewing_set_maxChiSymbolLen( ctx, MIN_CHI_SYMBOL_LEN - 1 );
	ok( chewing_get_maxChiSymbolLen( ctx ) == 16,
		"maxChiSymbolLen shall not change when set to %d",
		MIN_CHI_SYMBOL_LEN - 1 );

	chewing_set_maxChiSymbolLen( ctx, MAX_CHI_SYMBOL_LEN + 1 );
	ok( chewing_get_maxChiSymbolLen( ctx ) == 16,
		"maxChiSymbolLen shall not change when set to %d",
		MAX_CHI_SYMBOL_LEN + 1 );


	// Test auto commit
	chewing_set_maxChiSymbolLen( ctx, MAX_CHI_SYMBOL_LEN );

	// In boundary
	for ( i = 0; i < MAX_CHI_SYMBOL_LEN; ++i )
		type_keystroke_by_string( ctx, "hk4" );
	ok( chewing_commit_Check( ctx ) == 0,
		"auto commit shall not be triggered when entering %d symbols",
		MAX_CHI_SYMBOL_LEN );

	// Out of boundary
	type_keystroke_by_string( ctx, "hk4" );
	ok( chewing_commit_Check( ctx ) == 1,
		"auto commit shall be triggered when entering %d symbols",
		MAX_CHI_SYMBOL_LEN + 1);

	chewing_delete( ctx );
}
Ejemplo n.º 27
0
Archivo: gen-icache.c Proyecto: 5kg/gdb
static void
print_icache_function_header (lf *file,
			      const char *basename,
			      const char *format_name,
			      opcode_bits *expanded_bits,
			      int is_function_definition,
			      int nr_prefetched_words)
{
  lf_printf (file, "\n");
  lf_print__function_type_function (file, print_icache_function_type,
				    "EXTERN_ICACHE", " ");
  print_function_name (file,
		       basename, format_name, NULL,
		       expanded_bits, function_name_prefix_icache);
  lf_printf (file, "\n(");
  print_icache_function_formal (file, nr_prefetched_words);
  lf_printf (file, ")");
  if (!is_function_definition)
    lf_printf (file, ";");
  lf_printf (file, "\n");
}
Ejemplo n.º 28
0
void test_maxChiSymbolLen()
{
	ChewingContext *ctx;
	int i;

	print_function_name();

	ctx = chewing_new();

	chewing_set_maxChiSymbolLen( ctx, MAX_CHI_SYMBOL_LEN );

	for ( i = 0; i < MAX_CHI_SYMBOL_LEN; ++i ) {
		type_keystroke_by_string( ctx, "hk4" );
	}

	// Use easy symbol 'Orz' as last input for worst case scenario.
	chewing_set_easySymbolInput( ctx, 1 );
	type_keystroke_by_string( ctx, "L" );

	chewing_delete( ctx );
}
Ejemplo n.º 29
0
static void
itable_h_insn (lf *file,
	       insn_table *entry, insn_entry * instruction, void *data)
{
  int len;
  itable_info *info = data;
  lf_print__line_ref (file, instruction->line);
  lf_printf (file, "  ");
  print_function_name (file,
		       instruction->name,
		       instruction->format_name,
		       NULL, NULL, function_name_prefix_itable);
  lf_printf (file, ",\n");
  /* update summary info */
  len = strlen (instruction->format_name);
  if (info->sizeof_form <= len)
    info->sizeof_form = len + 1;
  len = strlen (instruction->name);
  if (info->sizeof_name <= len)
    info->sizeof_name = len + 1;
  len = strlen (filter_filename (instruction->line->file_name));
  if (info->sizeof_file <= len)
    info->sizeof_file = len + 1;
}
Ejemplo n.º 30
0
static void
print_icache_function(lf *file,
		      insn *instruction,
		      insn_bits *expanded_bits,
		      opcode_field *opcodes,
		      cache_table *cache_rules)
{
  int indent;

  /* generate code to enter decoded instruction into the icache */
  lf_printf(file, "\n");
  lf_print_function_type(file, ICACHE_FUNCTION_TYPE, "EXTERN_ICACHE", "\n");
  indent = print_function_name(file,
			       instruction->file_entry->fields[insn_name],
			       expanded_bits,
			       function_name_prefix_icache);
  lf_indent(file, +indent);
  lf_printf(file, "(%s)\n", ICACHE_FUNCTION_FORMAL);
  lf_indent(file, -indent);
  
  /* function header */
  lf_printf(file, "{\n");
  lf_indent(file, +2);
  
  print_my_defines(file, expanded_bits, instruction->file_entry);
  print_itrace(file, instruction->file_entry, 1/*putting-value-in-cache*/);
  
  print_idecode_validate(file, instruction, opcodes);
  
  lf_printf(file, "\n");
  lf_printf(file, "{\n");
  lf_indent(file, +2);
  if ((code & generate_with_semantic_icache))
    lf_printf(file, "unsigned_word nia;\n");
  print_icache_body(file,
		    instruction,
		    expanded_bits,
		    cache_rules,
		    ((code & generate_with_direct_access)
		     ? define_variables
		     : declare_variables),
		    ((code & generate_with_semantic_icache)
		     ? both_values_and_icache
		     : put_values_in_icache));
  
  lf_printf(file, "\n");
  lf_printf(file, "cache_entry->address = cia;\n");
  lf_printf(file, "cache_entry->semantic = ");
  print_function_name(file,
		      instruction->file_entry->fields[insn_name],
		      expanded_bits,
		      function_name_prefix_semantics);
  lf_printf(file, ";\n");
  lf_printf(file, "\n");

  if ((code & generate_with_semantic_icache)) {
    lf_printf(file, "/* semantic routine */\n");
    print_semantic_body(file,
			instruction,
			expanded_bits,
			opcodes);
    lf_printf(file, "return nia;\n");
  }
  
  if (!(code & generate_with_semantic_icache)) {
    lf_printf(file, "/* return the function proper */\n");
    lf_printf(file, "return ");
    print_function_name(file,
			instruction->file_entry->fields[insn_name],
			expanded_bits,
			function_name_prefix_semantics);
    lf_printf(file, ";\n");
  }
  
  if ((code & generate_with_direct_access))
    print_icache_body(file,
		      instruction,
		      expanded_bits,
		      cache_rules,
		      undef_variables,
		      ((code & generate_with_semantic_icache)
		       ? both_values_and_icache
		       : put_values_in_icache));

  lf_indent(file, -2);
  lf_printf(file, "}\n");
  lf_indent(file, -2);
  lf_printf(file, "}\n");
}