示例#1
0
    llvm::GlobalVariable *Property::GetMemberInfo()
    {
        if(!propertyInfo)
        {
            // Only create the property info variable when reflection is enabled.
            Module *module = GetModule();
            if(!module->HasReflection())
                return NULL;

            // Get the property info class.
            VirtualMachine *vm = module->GetVirtualMachine();
            Class *propInfoClass = vm->GetPropertyInfoClass();
            llvm::Module *targetModule = module->GetTargetModule();
            propertyInfo = new llvm::GlobalVariable(*targetModule, propInfoClass->GetTargetType(),
                                    false, ComputeMetadataLinkage(), NULL, GetMangledName() + "_propinfo_");
        }

        return propertyInfo;
    }
示例#2
0
void Layout::SerializeTo(SerializerElement & element) const
{
    element.SetAttribute( "name", GetName());
    element.SetAttribute( "mangledName", GetMangledName());
    element.SetAttribute( "r", (int)GetBackgroundColorRed() );
    element.SetAttribute( "v", (int)GetBackgroundColorGreen() );
    element.SetAttribute( "b", (int)GetBackgroundColorBlue() );
    element.SetAttribute( "title", GetWindowDefaultTitle());
    element.SetAttribute( "oglFOV", oglFOV );
    element.SetAttribute( "oglZNear", oglZNear );
    element.SetAttribute( "oglZFar", oglZFar );
    element.SetAttribute( "standardSortMethod", standardSortMethod);
    element.SetAttribute( "stopSoundsOnStartup", stopSoundsOnStartup);
    element.SetAttribute( "disableInputWhenNotFocused", disableInputWhenNotFocused);

    #if defined(GD_IDE_ONLY) && !defined(GD_NO_WX_GUI)
    GetAssociatedLayoutEditorCanvasOptions().SerializeTo(element.AddChild("uiSettings"));
    #endif

    ObjectGroup::SerializeTo(GetObjectGroups(), element.AddChild("objectsGroups"));
    GetVariables().SerializeTo(element.AddChild("variables"));
    GetInitialInstances().SerializeTo(element.AddChild("instances"));
    SerializeObjectsTo(element.AddChild("objects"));
    gd::EventsListSerialization::SerializeEventsTo(events, element.AddChild("events"));

    SerializerElement & layersElement = element.AddChild("layers");
    layersElement.ConsiderAsArrayOf("layer");
    for ( std::size_t j = 0;j < GetLayersCount();++j )
        GetLayer(j).SerializeTo(layersElement.AddChild("layer"));

    SerializerElement & behaviorDatasElement = element.AddChild("behaviorsSharedData");
    behaviorDatasElement.ConsiderAsArrayOf("behaviorSharedData");
    for (std::map<gd::String, std::shared_ptr<gd::BehaviorsSharedData> >::const_iterator it = behaviorsInitialSharedDatas.begin();
         it != behaviorsInitialSharedDatas.end();++it)
    {
        SerializerElement & dataElement = behaviorDatasElement.AddChild("behaviorSharedData");

        dataElement.SetAttribute("type", it->second->GetTypeName());
        dataElement.SetAttribute("name", it->second->GetName());
        it->second->SerializeTo(dataElement);
    }
}
	/**
	 * Returns source filename for particular callstack depth (or NULL).
	 * Caller doesn't have to deallocate that.
	 */
	const char * GetFunctionName(FGenericCrashContext* Context, int32 CurrentCallDepth)
	{
		static char DemangledName[MaxDemangledNameLength + 1];
		if (Context == NULL || CurrentCallDepth < 0)
		{
			return NULL;
		}

		FLinuxCrashContext* LinuxContext = static_cast< FLinuxCrashContext* >( Context );

		if (LinuxContext->BacktraceSymbols == NULL)
		{
			return NULL;
		}

		const char * SourceInfo = LinuxContext->BacktraceSymbols[CurrentCallDepth];
		if (SourceInfo == NULL)
		{
			return NULL;
		}

		// see http://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-html-USERS-4.3/a01696.html for C++ demangling
		int DemangleStatus = 0xBAD;
		char * Demangled = abi::__cxa_demangle(GetMangledName( SourceInfo ), NULL, NULL, &DemangleStatus);
		if (Demangled != NULL && DemangleStatus == 0)
		{
			FCStringAnsi::Strncpy(DemangledName, Demangled, ARRAY_COUNT(DemangledName) - 1);
		}
		else
		{
			FCStringAnsi::Strncpy(DemangledName, SourceInfo, ARRAY_COUNT(DemangledName) - 1);
		}

		if (Demangled)
		{
			free(Demangled);
		}
		return DemangledName;
	}
示例#4
0
    Expression ESolver::CreateExpression(const OperatorBase* OpInfo,
                                         const vector<Expression>& Children)
    {
        Expression NewExp;
        // Type checks
        if (Children.size() > 0) {
            auto FuncOp = OpInfo->As<FuncOperatorBase>();
            const uint32 NumChildren = Children.size();
            vector<const ESFixedTypeBase*> ArgTypes(NumChildren);
            for (uint32 i = 0; i < NumChildren; ++i) {
                ArgTypes[i] = Children[i]->GetType();
            }
            // Quick type check using name mangling
            auto const& ExpectedName = FuncOp->GetMangledName();
            auto const&& ActualName = FuncOperatorBase::MangleName(OpInfo->GetName(), ArgTypes);
            if (ExpectedName != ActualName) {
                throw TypeException((string)"Error in application of function \"" + OpInfo->GetName() + "\".\n" + 
                                    "This could be due to mismatched numbers or types of parameters");
            }
            // We're good. Create the expression
            if (OpInfo->As<InterpretedFuncOperator>() != nullptr) {
                NewExp = new UserInterpretedFuncExpression(OpInfo->As<InterpretedFuncOperator>(),
                                                           Children);
            } else {
                NewExp = new UserSynthFuncExpression(OpInfo->As<SynthFuncOperator>(),
                                                     Children);
            }
        } else {
            
            // This could be a constant, a UQVariable, an aux variable, 
            // a formal param or a let bound variable
            if (OpInfo->As<VarOperatorBase>() != nullptr) {
                if (OpInfo->As<UQVarOperator>() != nullptr) {
                    NewExp = new UserUQVarExpression(OpInfo->As<UQVarOperator>());
                } else if (OpInfo->As<FormalParamOperator>() != nullptr) {
                    NewExp = new UserFormalParamExpression(OpInfo->As<FormalParamOperator>());
                } else if (OpInfo->As<AuxVarOperator>() != nullptr) {
                    NewExp = new UserAuxVarExpression(OpInfo->As<AuxVarOperator>());
                } else if (OpInfo->As<LetBoundVarOperator>() != nullptr) {
                    NewExp = new UserLetBoundVarExpression(OpInfo->As<LetBoundVarOperator>());
                } else {
                    throw InternalError((string)"BUG: Unhandled operator type at " + __FILE__ + ":" + 
                                        to_string(__LINE__));
                }
            } else {
                // This can only be a const operator now
                if (OpInfo->As<ConstOperator>() != nullptr) {
                    NewExp = new UserConstExpression(OpInfo->As<ConstOperator>());
                } else if (OpInfo->As<MacroOperator>() != nullptr) {
                    // OR it can be a constant macro expression
                    NewExp = new UserInterpretedFuncExpression(OpInfo->As<MacroOperator>(), Children);
                } else {
                    throw TypeException((string)"Error: Could not find a meaningful way to construct " +
                                        "an expression with operator having name \"" + OpInfo->GetName() + 
                                        "\".\nPerhaps you provided arguments where none were expected, " + 
                                        "or this could be a bug");
                }
            }
        }

        ExpMgr->GC();
        return ExpMgr->GetExp(NewExp);
    }