// weakRef:Boolean = false):void
// {
// _bindingEventDispatcher.addEventListener(type, listener, useCapture,
// priority, weakRef);
// }
NodeFactory nodeFactory = context.getNodeFactory();
AttributeListNode attributeList = AbstractSyntaxTreeUtil.generatePublicAttribute(nodeFactory);
IdentifierNode addEventListenerIdentifier = nodeFactory.identifier(ADD_EVENT_LISTENER, false);
FunctionNameNode functionName = nodeFactory.functionName(Tokens.EMPTY_TOKEN, addEventListenerIdentifier);
ParameterNode typeParameter =
AbstractSyntaxTreeUtil.generateParameter(nodeFactory, TYPE, STRING, false);
ParameterListNode parameterList = nodeFactory.parameterList(null, typeParameter);
ParameterNode listenerParameter =
AbstractSyntaxTreeUtil.generateParameter(nodeFactory, LISTENER, FUNCTION, false);
parameterList = nodeFactory.parameterList(parameterList, listenerParameter);
LiteralBooleanNode literalBoolean = nodeFactory.literalBoolean(false);
ParameterNode useCaptureParameter =
AbstractSyntaxTreeUtil.generateParameter(nodeFactory, USE_CAPTURE, BOOLEAN,
false, literalBoolean);
parameterList = nodeFactory.parameterList(parameterList, useCaptureParameter);
LiteralNumberNode literalNumber = nodeFactory.literalNumber(0);
ParameterNode priorityParameter =
AbstractSyntaxTreeUtil.generateParameter(nodeFactory, PRIORITY, INT,
false, literalNumber);
parameterList = nodeFactory.parameterList(parameterList, priorityParameter);
literalBoolean = nodeFactory.literalBoolean(false);
ParameterNode weakRefParameter =
AbstractSyntaxTreeUtil.generateParameter(nodeFactory, WEAK_REF, BOOLEAN,
false, literalBoolean);
parameterList = nodeFactory.parameterList(parameterList, weakRefParameter);
FunctionSignatureNode functionSignature = nodeFactory.functionSignature(parameterList, null);
functionSignature.void_anno = true;
MemberExpressionNode _bindingEventDispatcherGetterSelector =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, _BINDING_EVENT_DISPATCHER, false);
IdentifierNode identifier = nodeFactory.identifier(ADD_EVENT_LISTENER, false);
MemberExpressionNode typeGetterSelector =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, TYPE, false);
ArgumentListNode argumentList = nodeFactory.argumentList(null, typeGetterSelector);
MemberExpressionNode listenerGetterSelector =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, LISTENER, false);
argumentList = nodeFactory.argumentList(argumentList, listenerGetterSelector);
MemberExpressionNode useCaptureGetterSelector =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, USE_CAPTURE, false);
argumentList = nodeFactory.argumentList(argumentList, useCaptureGetterSelector);
MemberExpressionNode priorityGetterSelector =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, PRIORITY, false);
argumentList = nodeFactory.argumentList(argumentList, priorityGetterSelector);
MemberExpressionNode weakRefGetterSelector =
AbstractSyntaxTreeUtil.generateGetterSelector(nodeFactory, WEAK_REF, false);
argumentList = nodeFactory.argumentList(argumentList, weakRefGetterSelector);
CallExpressionNode callExpression =
(CallExpressionNode) nodeFactory.callExpression(identifier, argumentList);
callExpression.setRValue(false);
MemberExpressionNode memberExpression =
nodeFactory.memberExpression(_bindingEventDispatcherGetterSelector, callExpression);
ListNode list = nodeFactory.list(null, memberExpression);
ExpressionStatementNode expressionStatement = nodeFactory.expressionStatement(list);
StatementListNode functionStatementList = nodeFactory.statementList(null, expressionStatement);
FunctionCommonNode functionCommon = nodeFactory.functionCommon(context, null, functionSignature,
functionStatementList);
functionCommon.setUserDefinedBody(true);
return nodeFactory.functionDefinition(context, attributeList, functionName, functionCommon);
}