Example #1
0
        private static void HandleNewObject(LocalOperation operation, StringBuilder bodySb,
                                            MidRepresentationVariables vars,
                                            TypeDescriptionTable typeTable, MethodInterpreter interpreter)
        {
            var value      = (Assignment)operation.Value;
            var rightValue = (NewConstructedObject)value.Right;
            var localValue = rightValue.Info;

            var declaringType = localValue.DeclaringType;
            var cppName       = declaringType.ToDeclaredVariableType(true, EscapingMode.Stack);
            var assignedData  = interpreter.AnalyzeProperties.GetVariableData(value.AssignedTo);
            var isStack       = assignedData == EscapingMode.Stack;

            if (isStack)
            {
                bodySb
                .AppendFormat("{1} {0};", value.AssignedTo.Name, cppName);
            }
            else
            {
                bodySb.AppendFormat("{0} = std::make_shared<{1}>();", value.AssignedTo.Name, cppName);
            }
            bodySb.AppendLine();
            typeTable.SetIdOfInstance(bodySb, value.AssignedTo, declaringType, isStack);
        }
        static void HandleNewObject(LocalOperation operation, CodeOutput bodySb, TypeDescriptionTable typeTable,
                                    MethodInterpreter interpreter, ClosureEntities crRuntime)
        {
            var value      = (NewConstructedObject)operation;
            var rightValue = value;
            var localValue = rightValue.Info;

            var declaringType = localValue.DeclaringType;
            var targetType    = declaringType.GetMappedType(crRuntime);
            var cppName       = declaringType.ToDeclaredVariableType(EscapingMode.Stack);
            var assignedData  = interpreter.AnalyzeProperties.GetVariableData(value.AssignedTo);
            var isStack       = assignedData == EscapingMode.Stack;

            if (isStack)
            {
                bodySb
                .AppendFormat("{1} {0};", value.AssignedTo.Name, cppName);
            }
            else
            {
                bodySb.AppendFormat("{0} = std::make_shared<{1}>();", value.AssignedTo.Name, cppName);
            }
            typeTable.SetIdOfInstance(bodySb, value.AssignedTo, targetType, isStack);
        }