예제 #1
0
Function _buildFunction( AST nodeFunc ) {
	CTE cte;
	AST child;
	Function function;
	_func = Function_New( AST_GetStringValue( nodeFunc ) );

	child = AST_GetFirstChild( nodeFunc ) ;

	if ( AST_GetType( child ) == AST_PARAM_LIST ) {
		_addArgs( child );
		child = AST_GetNextSibling( child );
	}
	
	if ( AST_GetType( child ) != AST_BLOCK ) {
		child = AST_GetNextSibling( child ); // skip function's type	
	}


	_addBlock( child );

	cte = Function_GetLastCTE( _func );
	if ( cte && cte->cmd != RET && cte->cmd != RET_VAL ) {
		cte = CTE_New( RET, args );
		Function_AddCTE( _func, cte );
	}
	return _func;
}
예제 #2
0
파일: world_editor.cpp 프로젝트: sKabYY/SMC
void cEditor_World :: Activate_Menu_Item( cEditor_Menu_Object *entry )
{
	// If Function
	if( entry->bfunction )
	{
		if( entry->tags.compare( "new" ) == 0 )
		{
			Function_New();
		}
		else if( entry->tags.compare( "load" ) == 0 )
		{
			Function_Load();
		}
		else if( entry->tags.compare( "save" ) == 0 )
		{
			Function_Save();
		}
		/*else if( entry->tags.compare( "save_as" ) == 0 )
		{
			Function_Save_as();
		}*/
		else if( entry->tags.compare( "reload" ) == 0 )
		{
			Function_Reload();
		}
		/*else if( entry->tags.compare( "settings" ) == 0 )
		{
			Function_Settings();
		}*/
		// unknown level function
		else
		{
			cEditor::Activate_Menu_Item( entry );
		}
	}
	// unknown level function
	else
	{
		cEditor::Activate_Menu_Item( entry );
	}
}
예제 #3
0
//-------------------------------------------------------------------
int             FunctionTable_Init(void)
{
    int i;
    TFunctionId Id;
    
    if(!g_Initialized)
    {
        g_FunctionList = List_New(CompareFunctionPtr);
        g_Initialized = 1;
    }
    else
    {
        DEBUG_msg("Trying to Init FunctionTable having Init it!");
        ASSERT("Trying to Init FunctionTable having Init it!" != NULL);
    }

    for(i=0; g_IntrinsicFunctionDef1[i].Nombre != NULL; i++)
    {
        TFunctionId FuncId;

	DEBUG_msg_str("Añadiendo funcion ",g_IntrinsicFunctionDef1[i].Nombre);

        FuncId = Function_New(g_IntrinsicFunctionDef1[i].Nombre,
                              g_IntrinsicFunctionDef1[i].CallAddress,
                              Type_RealId);
        Function_AddParameterType(FuncId, Type_RealId);
        
        DEBUG_msg_dec("Numero de parametros ",List_Length(FuncId->Args));
        
        
        FunctionTable_Register(FuncId);
    }

    for(i=0; g_IntrinsicFunctionDef2i[i].Nombre != NULL; i++)
    {
        TFunctionId FuncId;
        FuncId = Function_New(g_IntrinsicFunctionDef2i[i].Nombre,
                              g_IntrinsicFunctionDef2i[i].CallAddress,
                              Type_IntegerId);
        Function_AddParameterType(FuncId, Type_IntegerId);
        Function_AddParameterType(FuncId, Type_IntegerId);
        FunctionTable_Register(FuncId);
    }

    for(i=0; g_IntrinsicFunctionDef2f[i].Nombre != NULL; i++)
    {
        TFunctionId FuncId;
        FuncId = Function_New(g_IntrinsicFunctionDef2f[i].Nombre,
                              g_IntrinsicFunctionDef2f[i].CallAddress,
                              Type_RealId);
        Function_AddParameterType(FuncId, Type_RealId);
        Function_AddParameterType(FuncId, Type_RealId);
        FunctionTable_Register(FuncId);
    }

    // Mas funciones
    Id = Function_New("GetTimeMs", &Epopeia_GetTimeMs, Type_IntegerId);
    FunctionTable_Register(Id);
    Id = Function_New("GetTime", &GetTime, Type_RealId);
    FunctionTable_Register(Id);
    Id = Function_New("GetResX", &Epopeia_GetResX, Type_IntegerId);
    FunctionTable_Register(Id);
    Id = Function_New("GetResY", &Epopeia_GetResY, Type_IntegerId);
    FunctionTable_Register(Id);
    Id = Function_New("Random", &Random, Type_RealId);
    Function_AddParameterType(Id, Type_RealId);
    Function_AddParameterType(Id, Type_RealId);
    FunctionTable_Register(Id);
    srand(Epopeia_GetTimeMs());
    return 0;
}