示例#1
0
文件: Vyquon.c 项目: overzeroe/Vyquon
int main(){
    /* Load library */
    LoadCoreLibrary();

    /* Open our file and lexify it */
    FILE* file = fopen("test/test.vy", "r");
    TokenList* tokens = LexFile(file);

    TokenList* last = tokens;
    while(last){
        VyObj parsed = Parse(last, &last);

        printf("|");
        PrintObj(stdout, parsed);
        printf("|\nevaluates to\n");

        VyObj val = Eval(parsed);

        PrintObj(stdout, val);
        printf("\n\n");
    }

    FreeTokens(tokens);

    /* Finalize */
    FinishRuntime();

    /* Exit */
    return 0;
}
示例#2
0
文件: objset.c 项目: dimpase/gap
static void PrintObjMap(Obj map) {
  UInt i, size = CONST_ADDR_WORD(map)[OBJSET_SIZE];
  Int comma = 0;
  Pr("OBJ_MAP([ ", 0L, 0L);
  for (i=0; i < size; i++) {
    Obj obj = CONST_ADDR_OBJ(map)[OBJSET_HDRSIZE + i * 2 ];
    if (obj && obj != Undefined) {
      if (comma) {
        Pr(", ", 0L, 0L);
      } else {
        comma = 1;
      }
      PrintObj(obj);
      Pr(", ", 0L, 0L);
      PrintObj(CONST_ADDR_OBJ(map)[OBJSET_HDRSIZE + i * 2 + 1]);
    }
  }
  Pr(" ])", 0L, 0L);
}
示例#3
0
文件: objset.c 项目: dimpase/gap
static void PrintObjSet(Obj set) {
  UInt i, size = CONST_ADDR_WORD(set)[OBJSET_SIZE];
  Int comma = 0;
  Pr("OBJ_SET([ ", 0L, 0L);
  for (i=0; i < size; i++) {
    Obj obj = CONST_ADDR_OBJ(set)[OBJSET_HDRSIZE + i ];
    if (obj && obj != Undefined) {
      if (comma) {
        Pr(", ", 0L, 0L);
      } else {
        comma = 1;
      }
      PrintObj(obj);
    }
  }
  Pr(" ])", 0L, 0L);
}
int main() {
  std::deque<double> dat01{ 2.11, 5.551, 3.2, 4.12 };
  for_each(dat01.begin(),dat01.end(), PrintObj());
}
示例#5
0
/* handler for function 2 */
static Obj  HdlrFunc2 (
 Obj  self )
{
 Obj t_1 = 0;
 Obj t_2 = 0;
 Obj t_3 = 0;
 Bag oldFrame;
 
 /* allocate new stack frame */
 SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
 
 /* Print( AssertionLevel(  ), "\n" ); */
 t_1 = GF_Print;
 t_3 = GF_AssertionLevel;
 t_2 = CALL_0ARGS( t_3 );
 CHECK_FUNC_RESULT( t_2 )
 t_3 = MakeString( "\n" );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(1)) ) {
  t_2 = False;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   t_2 = MakeString( "fail-A" );
   if ( t_2 != (Obj)(UInt)0 ){
     if ( IS_STRING_REP ( t_2 ) )
       PrintString1( t_2);
     else
       PrintObj(t_2);
   }
  }
 }
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(1)) ) {
  t_2 = False;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   ErrorReturnVoid("Assertion failure",0L,0L,"you may 'return;'");
  }
 }
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(0)) ) {
  t_2 = True;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   t_2 = MakeString( "fail-B" );
   if ( t_2 != (Obj)(UInt)0 ){
     if ( IS_STRING_REP ( t_2 ) )
       PrintString1( t_2);
     else
       PrintObj(t_2);
   }
  }
 }
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(0)) ) {
  t_2 = True;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   ErrorReturnVoid("Assertion failure",0L,0L,"you may 'return;'");
  }
 }
 
 /* SetAssertionLevel( 2 ); */
 t_1 = GF_SetAssertionLevel;
 CALL_1ARGS( t_1, INTOBJ_INT(2) );
 
 /* Print( AssertionLevel(  ), "\n" ); */
 t_1 = GF_Print;
 t_3 = GF_AssertionLevel;
 t_2 = CALL_0ARGS( t_3 );
 CHECK_FUNC_RESULT( t_2 )
 t_3 = MakeString( "\n" );
 CALL_2ARGS( t_1, t_2, t_3 );
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(3)) ) {
  t_2 = False;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   t_2 = MakeString( "fail-C" );
   if ( t_2 != (Obj)(UInt)0 ){
     if ( IS_STRING_REP ( t_2 ) )
       PrintString1( t_2);
     else
       PrintObj(t_2);
   }
  }
 }
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(3)) ) {
  t_2 = False;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   ErrorReturnVoid("Assertion failure",0L,0L,"you may 'return;'");
  }
 }
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(2)) ) {
  t_2 = True;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   t_2 = MakeString( "fail-D" );
   if ( t_2 != (Obj)(UInt)0 ){
     if ( IS_STRING_REP ( t_2 ) )
       PrintString1( t_2);
     else
       PrintObj(t_2);
   }
  }
 }
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(2)) ) {
  t_2 = True;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   ErrorReturnVoid("Assertion failure",0L,0L,"you may 'return;'");
  }
 }
 
 /* Assert( ... ); */
 if ( ! LT(CurrentAssertionLevel, INTOBJ_INT(2)) ) {
  t_2 = False;
  t_1 = (Obj)(UInt)(t_2 != False);
  if ( ! t_1 ) {
   t_2 = MakeString( "pass!\n" );
   if ( t_2 != (Obj)(UInt)0 ){
     if ( IS_STRING_REP ( t_2 ) )
       PrintString1( t_2);
     else
       PrintObj(t_2);
   }
  }
 }
 
 /* Print( "end of function\n" ); */
 t_1 = GF_Print;
 t_2 = MakeString( "end of function\n" );
 CALL_1ARGS( t_1, t_2 );
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
 
 /* return; */
 SWITCH_TO_OLD_FRAME(oldFrame);
 return 0;
}
示例#6
0
文件: IO.c 项目: overzeroe/Vyquon
VyObj PrintObjFun(VyObj* args, int num_args){
    PrintObj(stdout, args[0]);
    printf(" ");
    fflush(stdout);
    return args[0];
}
示例#7
0
void myDrawOFF(){
	 PrintObj(&object);
  	 obj = &object;


 	//glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,
        //    material_diffuse);
        //glDisable(GL_LIGHTING);
	for(i=0; i<obj->Nfaces; i++){
	if (i == 0) {
	glEnable(GL_TEXTURE_2D);
	glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
        glBindTexture(GL_TEXTURE_2D, TextureName);
	}
	glBegin(GL_TRIANGLE_FAN);
	 // glFrontFace(GL_CW);
	for(j=0; j<obj->nv_face[i]; j++) {
   	
	p.x = obj->vertices[obj->faces[i][1]].x - obj->vertices[obj->faces[i][0]].x;
	p.y = obj->vertices[obj->faces[i][1]].y - obj->vertices[obj->faces[i][0]].y;
	p.z = obj->vertices[obj->faces[i][1]].z - obj->vertices[obj->faces[i][0]].z;
	
	q.x = obj->vertices[obj->faces[i][2]].x - obj->vertices[obj->faces[i][1]].x;
	q.y = obj->vertices[obj->faces[i][2]].y - obj->vertices[obj->faces[i][1]].y;
	q.z = obj->vertices[obj->faces[i][2]].z - obj->vertices[obj->faces[i][1]].z;
	
	r = V3cross(p,q);
	rlength = V3Length(r);	
	fprintf(stderr,"\n\n(Nx,Ny,Nz)  = (%f,%f,%f) %d\n\n",(r.x)/rlength,(r.y)/rlength,(r.z)/rlength,i);
	//if(i == 0 ) glTexCoord2f(1.0,1.0,);
	glNormal3f((r.x)/rlength,(r.y)/rlength,(r.z)/rlength);
	//fprintf(stderr,"%d ", obj->faces[i][j]);
	// fprintf(stderr,"\n\n(Nx,Ny,Nz) = (%f,%f,%f)\n\n",(r.x)/rlength,(r.y)/rlength,(r.z)/rlength);
	//glColor3f(1,1,0);

	if (i == 0 && j == 0) glTexCoord2f(0.0,0.0);
	if( i == 0 && j == 1) glTexCoord2f(1.0,0.0);
	if( i == 0 && j == 2) glTexCoord2f(1.0,1.0);
	if( i == 0 && j == 3) glTexCoord2f(0.0,1.0);
	glVertex3f(obj->vertices[obj->faces[i][j]].x,obj->vertices[obj->faces[i][j]].y,obj->vertices[obj->faces[i][j]].z);
	}
   	glEnd();
	//glFrontFace(GL_CCW);
	if(i == 0) glDisable(GL_TEXTURE_2D);
	//fprintf(stderr,"\n\n(Nx,Ny,Nz)  = (%f,%f,%f) %d\n\n",(r.x),(r.y),(r.z),i);
	} 
	//glColor3f(0,0,1);
 	//glMaterialf(GL_FRONT,GL_SHININESS,
               //0.5);
	for(i=0; i<obj->Nfaces; i++){
		
		for(j=0; j<obj->nv_face[i]; j++) {
		glLineWidth(3.0);
		if(j == 2) { l = 0;m = 3; n = 2;}
		if(j == 3) { l = 1;m = 0; n = 3;} 
		else { l = j+2 ;m = j+1 ; n = j;}
		
		p.x = obj->vertices[obj->faces[i][1]].x - obj->vertices[obj->faces[i][0]].x;
		p.y = obj->vertices[obj->faces[i][1]].y - obj->vertices[obj->faces[i][0]].y;
		p.z = obj->vertices[obj->faces[i][1]].z - obj->vertices[obj->faces[i][0]].z;
	
		q.x = obj->vertices[obj->faces[i][2]].x - obj->vertices[obj->faces[i][1]].x;
		q.y = obj->vertices[obj->faces[i][2]].y - obj->vertices[obj->faces[i][1]].y;
		q.z = obj->vertices[obj->faces[i][2]].z - obj->vertices[obj->faces[i][1]].z;
		glColor3f(0,1,1);
		r = V3cross(p,q);
		rlength = V3Length(r);	
		glDisable(GL_LIGHTING);
		glBegin(GL_LINES);
		
		glVertex3f(obj->vertices[obj->faces[i][j]].x,obj->vertices[obj->faces[i][j]].y,obj->vertices[obj->faces[i][j]].z);
		glVertex3f(obj->vertices[obj->faces[i][j]].x +(r.x)/rlength,obj->vertices[obj->faces[i][j]].y+(r.y)/rlength,obj->vertices[obj->faces[i][j]].z+(r.z)/rlength);
	//glVertex3f((r.x)/rlength,(r.y)/rlength,(r.z)/rlength);
	//	glVertex3f((r.x),(r.y),(r.z));
		//glVertex3f((r.x)/rlength,(r.y)/rlength,(r.z)/rlength);
		//glVertex3f((r.x)+5.0,(r.y)+5.0,(r.z)+5.0);
		glEnd();
		glEnable(GL_LIGHTING);
		}	
	}
}