Hello,
> I have added define block inside class block so corresponding code should be generate inside class block right?
Sadly no, it's not quite that simple :/ Blockly implements something called "function hoisting" where all of the function definitions are defined (in the generated code-string) before any of the "driver code".
If you want your definition to be generated inside of the class block, you'll want to modify the block-code generator definition you're using so that it returns a code string, instead of appending to the `definitions_` map =)