//----------------------------------------------------------------------------------------------------------------------------------------------------- public HappilLocal <T> Local <T>(IHappilOperand <T> initialValue) { var local = new HappilLocal <T>(this); local.Assign(initialValue); return(local); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- #region IHappilMember Members void IHappilMember.DefineBody() { m_ReturnValueLocal = null; m_CurrentBodyDefinitionIndex = 0; var outermostDefinition = m_BodyDefinitions.First(); using (CreateTypeTemplateScope()) { using (CreateBodyScope()) { outermostDefinition(); } } DefineReturnAttributes(); }
//----------------------------------------------------------------------------------------------------------------------------------------------------- internal protected void AddReturnStatement(IHappilOperand <TypeTemplate.TReturn> returnValue) { if (m_CurrentBodyDefinitionIndex > 0) { if (object.ReferenceEquals(m_ReturnValueLocal, null)) { m_ReturnValueLocal = this.Local <TypeTemplate.TReturn>(); } m_ReturnValueLocal.Assign(returnValue.OrNullConstant()); } else { //TODO: verify that current scope belongs to this method StatementScope.Current.AddStatement(new ReturnStatement <TypeTemplate.TReturn>(returnValue)); } }
//----------------------------------------------------------------------------------------------------------------------------------------------------- public IHappilForeachInSyntax <T> Foreach <T>(HappilLocal <T> element) { return(AddStatement(new ForeachStatement <T>(element))); }