  One of the currently favored scenarios for the formation of globular clusters
(GCs) with multiple stellar populations is that an initial massive stellar
system forms (`first generation', FG), subsequently giving rise to gaseous
ejecta which is converted into a second generation (SG) of stars to form a GC.
We investigate, for the first time, the sequential formation processes of both
FG and SG stars from star-forming massive gas clumps in gas-rich dwarf disk
galaxies. We adopt a novel approach to resolve the two-stage formation of GCs
in hydrodynamical simulations of dwarf galaxies.In the new simulations, new gas
particles that are much less massive than their parent star particle are
generated around each new star particle when the new star enters into the
asymptotic giant branch (AGB) phase. Furthermore, much finer maximum time step
width (<10^5 yr) and smaller softening length (<2 pc) are adopted for such AGB
gas particles to properly resolve the ejection of gas from AGB stars and AGB
feedback effects. Therefore, secondary star formation from AGB ejecta can be
properly investigated in galaxy-scale simulations. An FG stellar system can
first form from a massive gas clump developing due to gravitational instability
within its host gas-rich dwarf galaxy. Initially the FG stellar system is not a
single massive cluster, but instead is composed of several irregular stellar
clumps (or filaments) with a total mass larger than 10^6 Msun. While the FG
system is dynamically relaxing, gaseous ejecta from AGB stars can be
gravitationally trapped by the FG system and subsequently converted into new
stars to form a compact SG stellar system within the FG system. Interestingly,
about 40% of AGB ejecta is from stars that do not belong to the FG system
(`external gas accretion'). The mass-density relation for SG stellar systems
can be approximated as rho_SG ~ M_SG^1.5.
