break;
}
}
Pair script = m_script;
if (m_transformation != null && getArgumentCount() > 0)
{
// (#transformer'transformNested TOBJ <Transformation> <Arguments>)
m_script = Pair.list(
Pair.list(
Transformation.TRANSFORMER,
Pair.quote(TRANSFORM_NESTED),
(m_transformationInput == null) ? Symbol.define(getArgument(0).getName()) : m_transformationInput,
m_transformation,
m_transformationArguments
)
);
}
if (m_condition != Boolean.TRUE || m_script != null)
{
Pair args = null;
for (int i = getArgumentCount() - 1; i >= 0; --i)
{
args = new Pair(Symbol.define(getArgument(i).getName()), args);
}
if (bMapping)
{
if (m_condition == Boolean.TRUE)
{
m_condition = null;
}
else
{
m_condition = new Pair(m_condition);
}
for (int i = getArgumentCount() - 1; i >= 0; --i)
{
TransformationArgument arg = getArgument(i);
if (arg.getMapping() != null)
{
m_condition = new Pair(Pair.binary(Symbol.EQ_P, Symbol.define(arg.getName()),
Pair.quote(Undefined.VALUE)).not(), m_condition);
}
}
if (((Pair)m_condition).getTail() == null)
{
m_condition = ((Pair)m_condition).getHead();
}
else
{
m_condition = new Pair(Symbol.AND, m_condition);
}
}
if (m_script != null)
{
if (m_condition != Boolean.TRUE)
{
m_script = Pair.list(Pair.list(Symbol.IF, m_condition,
new Pair(new Pair(Symbol.LAMBDA, new Pair(null, m_script))),
Pair.quote(Undefined.VALUE)));
}
}
else
{
m_script = Pair.list(Pair.list(Symbol.IF, m_condition,
args.getHead(), Pair.quote(Undefined.VALUE)));
}
m_script = new Pair(Symbol.LAMBDA, new Pair(args, m_script));
}
if (bMapping)
{
int nNewArgCount = 0;
Pair args = null;
for (int nArg = getArgumentCount() - 1; nArg >= 0; --nArg)
{
TransformationArgument arg = getArgument(nArg);
TransformationMapping mapping = arg.getMapping();
if (mapping != null)
{
removeArgument(nArg);
mapping.generate(transformation);
Object code = null;
TransformationArgument srcArg = null;
for (int i = mapping.getArgumentCount() - 1; i >= 0 ; --i)
{
TransformationArgument mapArg = mapping.getArgument(i);
TransformationSource src = mapArg.getSource();
int nSrc;
for (nSrc = getArgumentCount() - 1; nSrc >= 0; --nSrc)
{
srcArg = getArgument(nSrc);
if (srcArg.getSource() == src)
{
break;
}
}
if (nSrc < 0)
{
srcArg = new TransformationArgument("#" + nNewArgCount++);
srcArg.setSource(src);
srcArg.setNull(mapArg.isNull());
srcArg.setDefaultValue(mapArg.getDefaultValue());
srcArg.setDefaultValueFunction(mapArg.getDefaultValueFunction());
addArgument(nArg, srcArg);
}
if (arg.isNull())
{
src.setNull(true);
}
if (arg.isDefault())
{
src.setDefault(true);
}
code = new Pair(Symbol.define(srcArg.getName()), code);
}
if (mapping.getOrdinal() == 0)
{
code = ((Pair)code).getHead();
}
else
{
code = new Pair(Pair.list(Symbol.VECTOR_REF, Transformation.MAPPERS,
Primitive.createInteger(mapping.getOrdinal())), code);
}
args = new Pair(code, args);
}
else
{
args = new Pair(Symbol.define(arg.getName()), args);
}
}
Pair code = null;
for (int i = getArgumentCount() - 1; i >= 0; --i)
{
code = new Pair(Symbol.define(getArgument(i).getName()), code);
}
if (m_script == null)
{
m_script = Pair.list(Symbol.LAMBDA, code, args.getHead());
}
else
{
m_script = Pair.list(Symbol.LAMBDA, code, new Pair(m_script, args));
}
}
if (m_script != null)
{