001 /*
002 * Copyright 2010-2013 JetBrains s.r.o.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017 package org.jetbrains.k2js.translate.reference;
018
019 import com.google.dart.compiler.backend.js.ast.JsExpression;
020 import org.jetbrains.annotations.NotNull;
021 import org.jetbrains.annotations.Nullable;
022
023 public final class CallParameters {
024
025 @Nullable
026 private final JsExpression receiver;
027
028 @NotNull
029 private final JsExpression functionReference;
030
031 @Nullable
032 private final JsExpression thisObject;
033
034 public CallParameters(@Nullable JsExpression receiver,
035 @NotNull JsExpression functionReference,
036 @Nullable JsExpression thisObject) {
037 this.receiver = receiver;
038 this.functionReference = functionReference;
039 this.thisObject = thisObject;
040 }
041
042 @NotNull
043 public JsExpression getFunctionReference() {
044 return functionReference;
045 }
046
047 @Nullable
048 public JsExpression getThisObject() {
049 return thisObject;
050 }
051
052 @Nullable
053 public JsExpression getReceiver() {
054 return receiver;
055 }
056
057 @Nullable
058 public JsExpression getThisOrReceiverOrNull() {
059 if (thisObject == null) {
060 return receiver;
061 }
062 assert receiver == null;
063 return thisObject;
064 }
065 }