Exemplo n.º 1
0
CAMLexport
int triunsuitable(vertex triorg, vertex tridest, vertex triapex, REAL area)
{
  CAMLparam0();
  CAMLlocal1(vd);
  static value * closure = NULL;
  value args[NARGS_TRIUNSUITABLE];
  if (closure == NULL) {
    closure = caml_named_value("triunsuitable_callback");
  }

#define COPY_DOUBLE(dest, d) \
  vd = caml_copy_double(d);  \
  dest = vd

  COPY_DOUBLE(args[0], triorg[0]);
  COPY_DOUBLE(args[1], triorg[1]);
  COPY_DOUBLE(args[2], tridest[0]);
  COPY_DOUBLE(args[3], tridest[1]);
  COPY_DOUBLE(args[4], triapex[0]);
  COPY_DOUBLE(args[5], triapex[1]);
  COPY_DOUBLE(args[6], area);
  CAMLreturn(Bool_val(callbackN(*closure, NARGS_TRIUNSUITABLE, args)));

#undef COPY_DOUBLE
}
Exemplo n.º 2
0
Arquivo: cp.c Projeto: lorian1333/hjvm
u8int read_constant_pool(FILE* f, u16int *i, u16int *cpcount, cp_info** cpinfo)
{

     u16int *j= (u16int*) malloc(sizeof(u16int));
	s32int* integer, *i2;
	u8int *raw = malloc(4), *raw2 = malloc(8);

     
     cp_info* info;

   
	debugmsg("Constant pool: \n");
	for(*i=0;*i < ((*cpcount)-1); (*i)++)
	{
        info = (cp_info*) malloc(sizeof(cp_info));
        memset(info, 0, sizeof(cp_info));
		info->tag = fgetc(f);
	
		switch(info->tag)
		{
			case CONSTANT_Class: 
			{
				read_class(f, j, info);
				debugmsg("#%d Class #%d\n", (*i)+1, MAKE_U16( ((CONSTANT_Class_info*) info->data)->name_index ));
				break;
			}
			
			case CONSTANT_Fieldref:
			{
				read_fieldref(f, j, info);
				 debugmsg("#%d Fieldref #%d.#%d\n", (*i)+1,
				MAKE_U16( ((CONSTANT_Fieldref_info*)info->data)->class_index  ),
				MAKE_U16( ((CONSTANT_Fieldref_info*)info->data)->name_and_type_index ));
				break;
			}
			case CONSTANT_Methodref:
			{
				read_methodref(f, j, info);
				 debugmsg("#%d Methodref #%d.#%d\n", (*i)+1,
				MAKE_U16( ((CONSTANT_Methodref_info*)info->data)->class_index ),
				MAKE_U16( ((CONSTANT_Methodref_info*)info->data)->name_and_type_index ));
				break;
			}
			case CONSTANT_InterfaceMethodref:
			{
				read_interfacemethodref(f, j, info);
				 debugmsg("#%d InterfaceMethodref #%d.#%d\n", (*i)+1,
				MAKE_U16( ((CONSTANT_InterfaceMethodref_info*)info->data)->class_index  ),
				MAKE_U16( ((CONSTANT_InterfaceMethodref_info*)info->data)->name_and_type_index  ));
				break;
			}
			case CONSTANT_String:
			{
				read_string(f, j, info);
				debugmsg("#%d String #%d\n", (*i)+1, MAKE_U16( ((CONSTANT_String_info*)info->data)->string_index));
				break;
			}
			case CONSTANT_Integer:
			{
				read_integer(f, j, info);
				
				MAKE_S32(raw, ((CONSTANT_Integer_info*)info->data)->bytes);
				integer = (s32int*) raw;
				debugmsg("#%d Integer %d\n", (*i) + 1, *integer);
				break;
			}
			case CONSTANT_Float:
			{	
				read_float(f, j, info);
				COPY_FLOAT(raw, ((CONSTANT_Float_info*)info->data)->bytes);
				debugmsg("#%d Float %f\n", (*i)+1, *((float32*) raw));
				break;
			}
			case CONSTANT_Long:
			{
				read_long(f, j, info);
				MAKE_S64(raw2, ((CONSTANT_Long_info*)info->data)->high_bytes );
				debugmsg("#%d Long %ld\n", (*i)+1,  *( (s64int*) raw2));
                    cpinfo[(*i)++] = NULL;
				break;
			}
			case CONSTANT_Double:
			{
				read_double(f, j, info);
				COPY_DOUBLE(raw2, ((CONSTANT_Double_info*) info->data)->high_bytes);
				debugmsg("#%d Double %f\n", (*i)+1, *( (float64*) raw2));
				cpinfo[(*i)++] = NULL;
				break;
			}
			case CONSTANT_NameAndType:
			{
				read_nameandtype(f, j, info);
				debugmsg("#%d NameAndType #%d.#%d\n", (*i)+1, MAKE_U16( ((CONSTANT_NameAndType_info*) info->data)->name_index) , MAKE_U16(((CONSTANT_NameAndType_info*) info->data)->descriptor_index ) );
				break;
			}
			case CONSTANT_Utf8:
			{
				read_utf8(f, j, info);
                    debugmsg("#%d Utf8 %s\n", (*i)+1, utf8_to_cstring(((CONSTANT_Utf8_info*) info->data)->bytes));
				break;
			}
               case CONSTANT_MethodHandle:
               {
                    read_methodhandle(f, j, info);
                    debugmsg("#%d MethodHandle Kind:%d #%d\n", *(i)+1, ((CONSTANT_MethodHandle_info*) info->data)->reference_kind, MAKE_U16(((CONSTANT_MethodHandle_info*) info->data)->reference_index));
                    break;
               }
               
               case CONSTANT_MethodType:
               {
                    read_methodtype(f, j, info);
                    debugmsg("#%d MethodType #%d\n", *(i)+1, MAKE_U16(((CONSTANT_MethodType_info*) info->data)->descriptor_index));
                    break;
               }
               
               case CONSTANT_InvokeDynamic:
               {
                    read_invokedynamic(f,j,info);
                    debugmsg("#%d InvokeDynamic #%d.#%d\n", *(i)+1, MAKE_U16(((CONSTANT_InvokeDynamic_info*) info->data)->bootstrap_method_attr_index),
                              MAKE_U16(((CONSTANT_InvokeDynamic_info*) info->data)->name_and_type_index));
                    break;
               }
               
			default: {
				debugerr("Unrecognized tag: %02X!\n", info->tag);
				free(info);
				return 0;
					}
		}
          cpinfo[(*i)] = info;       
	}
     
	 debugmsg("Done reading Constant Pool\n");
      

	free(j);
	free(raw);
	free(raw2);
     
     
	return 1;
}