Added toDouble() method to support wd examples.

This commit is contained in:
pTalanov
2012-03-01 16:23:11 +04:00
parent 256b813edb
commit 30ba240bda
2 changed files with 44 additions and 0 deletions
@@ -44,6 +44,8 @@ import static org.jetbrains.jet.lang.types.expressions.OperatorConventions.*;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getFunctionByName;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getPropertyByName;
//TODO: class is monstrous, should be refactored.
/**
* @author Pavel Talanov
* <p/>
@@ -79,6 +81,8 @@ public final class Intrinsics {
declareStringIntrinsics();
declareTuplesIntrinsics();
declareArrayIntrinsics();
FunctionDescriptor intToDouble = getFunctionByName(library.getInt().getDefaultType().getMemberScope(), "toDouble");
functionIntrinsics.put(intToDouble, ReturnReceiverIntrinsic.INSTANCE);
}
@NotNull
@@ -0,0 +1,40 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.k2js.translate.intrinsic;
import com.google.dart.compiler.backend.js.ast.JsExpression;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.k2js.translate.context.TranslationContext;
import java.util.List;
/**
* @author Pavel Talanov
*/
public enum ReturnReceiverIntrinsic implements Intrinsic {
INSTANCE;
@NotNull
@Override
public JsExpression apply(@Nullable JsExpression receiver, @NotNull List<JsExpression> arguments,
@NotNull TranslationContext context) {
assert receiver != null;
return receiver;
}
}