Beispiel #1
0
        //-----------------------------------------------------------------------------------------------------------------------------------------------------

        public NewStructExpression(IOperand[] constructorArguments = null)
        {
            m_StatementScope = StatementScope.Current;

            m_StructType           = TypeTemplate.Resolve <TStruct>();
            m_ConstructorArguments = (constructorArguments ?? new IOperand[0]);

            if (m_ConstructorArguments.Length > 0)
            {
                var argumentTypes = m_ConstructorArguments.Select(arg => arg.OperandType).ToArray();
                m_Constructor = m_StructType.GetConstructor(argumentTypes);

                if (m_Constructor == null)
                {
                    throw new ArgumentException("Could not find constructor with specified argument types.");
                }

                foreach (var argument in m_ConstructorArguments.Reverse())
                {
                    m_StatementScope.Consume(argument);
                }
            }

            m_StatementScope.RegisterExpressionStatement(this);
        }
Beispiel #2
0
        public void RegisterNonExpressionOperand_NothingHappens()
        {
            //-- Arrange

            var statements = new StatementBlock();
            var rootScope  = new StatementScope(m_Class, m_Method, statements);

            //-- Act

            rootScope.RegisterExpressionStatement(expression: null);

            //-- Assert

            Assert.That(statements.Count, Is.EqualTo(0));
        }