* @param value CSS property value.
* @return AET instructions.
*/
private InstructionList getInstructionListForPropertyValue(final ICSSPropertyValue value)
{
final InstructionList valueInstructions = new InstructionList();
// push property value on the stack
if (value instanceof CSSStringPropertyValue)
{
valueInstructions.addInstruction(ABCConstants.OP_pushstring, ((CSSStringPropertyValue)value).getValue());
}
else if (value instanceof CSSColorPropertyValue)
{
valueInstructions.addInstruction(ABCConstants.OP_pushint, new Integer(((CSSColorPropertyValue)value).getColorAsInt()));
}
else if (value instanceof CSSRgbColorPropertyValue)
{
valueInstructions.addInstruction(ABCConstants.OP_pushint, new Integer(((CSSRgbColorPropertyValue)value).getColorAsInt()));
}
else if (value instanceof CSSKeywordPropertyValue)
{
CSSKeywordPropertyValue keywordValue = (CSSKeywordPropertyValue)value;
String keywordString = keywordValue.getKeyword();
if (IASLanguageConstants.TRUE.equals(keywordString))
valueInstructions.addInstruction(ABCConstants.OP_pushtrue);
else if (IASLanguageConstants.FALSE.equals(keywordString))
valueInstructions.addInstruction(ABCConstants.OP_pushfalse);
else
valueInstructions.addInstruction(ABCConstants.OP_pushstring, ((CSSKeywordPropertyValue)value).getKeyword());
}
else if (value instanceof CSSNumberPropertyValue)
{
valueInstructions.addInstruction(ABCConstants.OP_pushdouble, new Double(((CSSNumberPropertyValue)value).getNumber().doubleValue()));
}
else if (value instanceof CSSFunctionCallPropertyValue)
{
final CSSFunctionCallPropertyValue functionCall = (CSSFunctionCallPropertyValue)value;
if ("ClassReference".equals(functionCall.name))
{
final String className = CSSFunctionCallPropertyValue.getSingleArgumentFromRaw(functionCall.rawArguments);
if ("null".equals(className))
{
// ClassReference(null) resets the property's class reference.
valueInstructions.addInstruction(ABCConstants.OP_pushnull);
}
else
{
final IResolvedQualifiersReference reference = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), className);
valueInstructions.addInstruction(ABCConstants.OP_getlex, reference.getMName());
}
}
else if ("url".equals(functionCall.name))
{
final String urlString = CSSFunctionCallPropertyValue.getSingleArgumentFromRaw(functionCall.rawArguments);
valueInstructions.addInstruction(ABCConstants.OP_pushstring, urlString);
}
else if ("PropertyReference".equals(functionCall.name))
{
// TODO: implement me
}
else if ("Embed".equals(functionCall.name))
{
final EmbedCompilationUnit embedCompilationUnit = session.resolvedEmbedProperties.get(functionCall);
if (embedCompilationUnit == null)
{
final ICompilerProblem e = new CSSCodeGenProblem(
new IllegalStateException("Unable to find compilation unit for " + functionCall));
problems.add(e);
}
else
{
final String qName = embedCompilationUnit.getName();
final IResolvedQualifiersReference reference = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), qName);
valueInstructions.addInstruction(ABCConstants.OP_getlex, reference.getMName());
}
}
else
{
assert false : "CSS parser bug: unexpected function call property value: " + functionCall;
throw new IllegalStateException("Unexpected function call property value: " + functionCall);
}
}
else if (value instanceof CSSArrayPropertyValue)
{
final CSSArrayPropertyValue arrayValue = (CSSArrayPropertyValue)value;
for (final ICSSPropertyValue elementValue : arrayValue.getElements())
{
valueInstructions.addAll(getInstructionListForPropertyValue(elementValue));
}
valueInstructions.addInstruction(ABCConstants.OP_newarray, arrayValue.getElements().size());
}
else
{
assert false : "Unsupported property value: " + value;
}