Lines Matching defs:state

38 inline bool isCurrentTopStatementBlock (const GeneratorState& state)
40 int stackDepth = state.getStatementDepth();
41 return dynamic_cast<const BlockStatement*>(state.getStatementStackEntry(stackDepth-1)) != DE_NULL;
44 template <class T> float getWeight (const GeneratorState& state) { return T::getWeight(state); }
45 template <class T> Statement* create (GeneratorState& state) { return new T(state); }
49 float (*getWeight) (const GeneratorState& state);
50 Statement* (*create) (GeneratorState& state);
53 const StatementSpec* chooseStatement (GeneratorState& state)
69 weights[ndx] = statementSpecs[ndx].getWeight(state);
76 float p = state.getRandom().getFloat(0.0f, sum);
101 Statement* createStatement (GeneratorState& state)
103 return chooseStatement(state)->create(state);
116 ExpressionStatement::ExpressionStatement (GeneratorState& state)
119 ExpressionGenerator generator(state);
128 float ExpressionStatement::getWeight (const GeneratorState& state)
130 DE_UNREF(state);
139 BlockStatement::BlockStatement (GeneratorState& state)
141 init(state);
144 void BlockStatement::init (GeneratorState& state)
147 m_numChildrenToCreate = state.getRandom().getInt(0, state.getShaderParameters().maxStatementsPerBlock);
150 state.getVariableManager().pushVariableScope(m_scope);
173 Statement* BlockStatement::createNextChild (GeneratorState& state)
178 Statement* child = createStatement(state);
185 state.getVariableManager().popVariableScope();
190 float BlockStatement::getWeight (const GeneratorState& state)
192 if (state.getStatementDepth()+1 < state.getShaderParameters().maxStatementDepth)
194 if (isCurrentTopStatementBlock(state))
203 void BlockStatement::tokenize (GeneratorState& state, TokenStream& str) const
208 (*i)->tokenize(state, str);
219 void ExpressionStatement::tokenize (GeneratorState& state, TokenStream& str) const
222 m_expression->tokenize(state, str);
247 DeclarationStatement::DeclarationStatement (GeneratorState& state, Variable* variable)
256 const vector<Variable*>& liveVars = state.getVariableManager().getLiveVariables();
265 variable = state.getRandom().choose<Variable*>(candidates.begin(), candidates.end());
271 const ValueEntry* value = state.getVariableManager().getValue(variable);
294 ExpressionGenerator generator(state);
300 state.getVariableManager().declareVariable(variable);
305 state.pushExpressionFlags(state.getExpressionFlags() | CONST_EXPR);
310 state.popExpressionFlags();
313 state.getVariableManager().declareVariable(variable);
321 float DeclarationStatement::getWeight (const GeneratorState& state)
323 if (!hasDeclarableVars(state.getVariableManager()))
326 if (!isCurrentTopStatementBlock(state))
329 return state.getProgramParameters().declarationStatementBaseWeight;
332 void DeclarationStatement::tokenize (GeneratorState& state, TokenStream& str) const
334 m_variable->tokenizeDeclaration(state, str);
339 m_expression->tokenize(state, str);
368 bool ConditionalStatement::isElseBlockRequired (const GeneratorState& state) const
373 int curStackNdx = state.getStatementDepth()-2;
377 const ConditionalStatement* curParent = dynamic_cast<const ConditionalStatement*>(state.getStatementStackEntry(curStackNdx));
393 Statement* ConditionalStatement::createNextChild (GeneratorState& state)
396 if (!m_falseStatement && !m_trueStatement && (isElseBlockRequired(state) || state.getRandom().getBool()))
399 state.getVariableManager().pushValueScope(m_conditionalScope);
400 m_falseStatement = createStatement(state);
409 state.getVariableManager().popValueScope();
414 state.getVariableManager().pushValueScope(m_conditionalScope);
415 m_trueStatement = createStatement(state);
422 state.getVariableManager().popValueScope();
428 ExpressionGenerator generator(state);
455 void ConditionalStatement::tokenize (GeneratorState& state, TokenStream& str) const
461 m_condition->tokenize(state, str);
468 m_trueStatement->tokenize(state, str);
472 m_trueStatement->tokenize(state, str);
480 m_falseStatement->tokenize(state, str);
485 m_falseStatement->tokenize(state, str);
490 m_falseStatement->tokenize(state, str);
526 float ConditionalStatement::getWeight (const GeneratorState& state)
528 if (!state.getProgramParameters().useConditionals)
531 int availableLevels = state.getShaderParameters().maxStatementDepth - state.getStatementDepth();
541 AssignStatement::AssignStatement (GeneratorState& state, const Variable* variable, ConstValueRangeAccess valueRange)
546 ExpressionGenerator generator(state);
555 void AssignStatement::tokenize (GeneratorState& state, TokenStream& str) const
558 m_valueExpr->tokenize(state, str);