public void EmitInitializeLocal(int index, Type type)
        {
            object value = ScriptingRuntimeHelpers.GetPrimitiveDefaultValue(type);

            if (value != null)
            {
                Emit(new InitializeLocalInstruction.ImmutableValue(index, value));
            }
            else if (type.IsValueType)
            {
                Emit(new InitializeLocalInstruction.MutableValue(index, type));
            }
            else
            {
                Emit(InitReference(index));
            }
        }
Beispiel #2
0
        public void EmitInitializeLocal(int index, Type type)
        {
            object primitiveDefaultValue = ScriptingRuntimeHelpers.GetPrimitiveDefaultValue(type);

            if (primitiveDefaultValue == null)
            {
                if (!type.IsValueType)
                {
                    this.Emit(InstructionList.InitReference(index));
                    return;
                }
                else
                {
                    this.Emit(new InitializeLocalInstruction.MutableValue(index, type));
                    return;
                }
            }
            else
            {
                this.Emit(new InitializeLocalInstruction.ImmutableValue(index, primitiveDefaultValue));
                return;
            }
        }