org.jetbrains.kotlin.js.backend.ast.JsName Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-compiler-embeddable Show documentation
Show all versions of kotlin-compiler-embeddable Show documentation
the Kotlin compiler embeddable
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package org.jetbrains.kotlin.js.backend.ast;
import org.jetbrains.kotlin.js.backend.ast.metadata.HasMetadata;
import org.jetbrains.kotlin.js.common.Symbol;
import org.jetbrains.annotations.NotNull;
/**
* An abstract base class for named JavaScript objects.
*/
public class JsName extends HasMetadata implements Symbol {
private static int ordinalGenerator;
private final JsScope enclosing;
private final int ordinal;
@NotNull
private final String ident;
private final boolean temporary;
/**
* @param ident the unmangled ident to use for this name
*/
JsName(JsScope enclosing, @NotNull String ident, boolean temporary) {
this.enclosing = enclosing;
this.ident = ident;
this.temporary = temporary;
ordinal = temporary ? ordinalGenerator++ : 0;
}
public int getOrdinal() {
return ordinal;
}
public JsScope getEnclosing() {
return enclosing;
}
public boolean isTemporary() {
return temporary;
}
@NotNull
public String getIdent() {
return ident;
}
@NotNull
public JsNameRef makeRef() {
return new JsNameRef(this);
}
@Override
public String toString() {
return ident;
}
}