예제 #1
0
		void SymbolAstResult::MergeForStatement(const SymbolAstResult& result, AstDeclaration::Ptr& state)
		{
			AppendStatement(result.statement);
			if (result.RequireCps())
			{
				continuation = result.continuation;
			}

			if (continuation)
			{
				state = continuation->arguments[0];
			}
		}
예제 #2
0
		void SymbolAstResult::MergeForExpression(const SymbolAstResult& result, SymbolAstContext& context, vector<AstExpression::Ptr>& exprs, int& exprStart, AstDeclaration::Ptr& state)
		{
			if (result.RequireCps())
			{
				auto block = make_shared<AstBlockStatement>();
				for (int i = exprStart; (size_t)i < exprs.size(); i++)
				{
					auto var = make_shared<AstDeclarationStatement>();
					{
						auto decl = make_shared<AstSymbolDeclaration>();
						decl->composedName = T("$var") + context.GetUniquePostfix();
						var->declaration = decl;

						auto declstat = make_shared<AstDeclarationStatement>();
						declstat->declaration = decl;
						block->statements.push_back(declstat);

						auto assign = make_shared<AstAssignmentStatement>();
						block->statements.push_back(assign);

						auto ref = make_shared<AstReferenceExpression>();
						ref->reference = decl;
						assign->target = ref;

						assign->value = exprs[i];
					}
					
					auto ref = make_shared<AstReferenceExpression>();
					ref->reference = var->declaration;
					exprs[i] = ref;
				}
				block->statements.push_back(result.statement);

				if (continuation)
				{
					continuation->statement = block;
				}
				else
				{
					statement = block;
				}
				continuation = result.continuation;
				exprStart = exprs.size();
				state = continuation->arguments[0];
			}
			exprs.push_back(result.value);
		}