Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
ce929fab
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ce929fab
编写于
5月 02, 2012
作者:
P
pTalanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename CompileEnvironmentConfiguration. Drop ArgsUtil class. Add CompilerSpecialMode.JS.
上级
c7d5f79e
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
75 addition
and
112 deletion
+75
-112
build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java
...c/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java
+5
-4
compiler/cli/src/org/jetbrains/jet/cli/common/ArgsUtil.java
compiler/cli/src/org/jetbrains/jet/cli/common/ArgsUtil.java
+0
-49
compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java
...ler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java
+24
-10
compiler/cli/src/org/jetbrains/jet/cli/common/CompileEnvironmentConfiguration.java
...rains/jet/cli/common/CompileEnvironmentConfiguration.java
+2
-2
compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompileEnvironmentConfiguration.java
...rains/jet/cli/js/K2JSCompileEnvironmentConfiguration.java
+2
-2
compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java
...iler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java
+8
-8
compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/CompileEnvironmentUtil.java
...etbrains/jet/cli/jvm/compiler/CompileEnvironmentUtil.java
+4
-4
compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/K2JVMCompileEnvironmentConfiguration.java
...li/jvm/compiler/K2JVMCompileEnvironmentConfiguration.java
+3
-12
compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java
...ins/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java
+10
-10
compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/CompilerSpecialMode.java
.../jetbrains/jet/lang/resolve/java/CompilerSpecialMode.java
+1
-0
compiler/tests/org/jetbrains/jet/codegen/CompileTextTest.java
...iler/tests/org/jetbrains/jet/codegen/CompileTextTest.java
+2
-2
compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java
compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java
+2
-2
idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java
idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java
+11
-6
libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt
.../src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt
+1
-1
未找到文件。
build-tools/core/src/org/jetbrains/jet/buildtools/core/BytecodeCompiler.java
浏览文件 @
ce929fab
...
...
@@ -42,17 +42,18 @@ public class BytecodeCompiler {
/**
* Creates new instance of {@link org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentConfiguration} instance using the arguments specified.
* Creates new instance of {@link org.jetbrains.jet.cli.jvm.compiler.
K2JVM
CompileEnvironmentConfiguration} instance using the arguments specified.
*
* @param stdlib path to "kotlin-runtime.jar", only used if not null and not empty
* @param classpath compilation classpath, only used if not null and not empty
*
* @return compile environment instance
*/
private
CompileEnvironmentConfiguration
env
(
String
stdlib
,
String
[]
classpath
)
{
private
K2JVM
CompileEnvironmentConfiguration
env
(
String
stdlib
,
String
[]
classpath
)
{
CompilerDependencies
dependencies
=
CompilerDependencies
.
compilerDependenciesForProduction
(
CompilerSpecialMode
.
REGULAR
);
JetCoreEnvironment
environment
=
new
JetCoreEnvironment
(
CompileEnvironmentUtil
.
createMockDisposable
(),
dependencies
);
CompileEnvironmentConfiguration
env
=
new
CompileEnvironmentConfiguration
(
environment
,
MessageCollector
.
PLAIN_TEXT_TO_SYSTEM_ERR
);
K2JVMCompileEnvironmentConfiguration
env
=
new
K2JVMCompileEnvironmentConfiguration
(
environment
,
MessageCollector
.
PLAIN_TEXT_TO_SYSTEM_ERR
);
if
((
stdlib
!=
null
)
&&
(
stdlib
.
trim
().
length
()
>
0
))
{
File
file
=
new
File
(
stdlib
);
...
...
@@ -140,7 +141,7 @@ public class BytecodeCompiler {
*/
public
void
moduleToJar
(
@NotNull
String
module
,
@NotNull
String
jar
,
boolean
includeRuntime
,
@Nullable
String
stdlib
,
@Nullable
String
[]
classpath
)
{
try
{
CompileEnvironmentConfiguration
env
=
env
(
stdlib
,
classpath
);
K2JVM
CompileEnvironmentConfiguration
env
=
env
(
stdlib
,
classpath
);
List
<
Module
>
modules
=
CompileEnvironmentUtil
.
loadModuleScript
(
module
,
env
.
getMessageCollector
());
File
directory
=
new
File
(
module
).
getParentFile
();
boolean
success
=
KotlinToJVMBytecodeCompiler
.
compileModules
(
env
,
modules
,
directory
,
jar
,
null
,
includeRuntime
);
...
...
compiler/cli/src/org/jetbrains/jet/cli/common/ArgsUtil.java
已删除
100644 → 0
浏览文件 @
c7d5f79e
/*
* Copyright 2010-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.jet.cli.common
;
import
com.sampullara.cli.Args
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
;
import
java.io.PrintStream
;
/**
* @author Pavel Talanov
*/
public
final
class
ArgsUtil
{
private
ArgsUtil
()
{
}
public
static
void
printUsage
(
@NotNull
PrintStream
target
,
@NotNull
CompilerArguments
exampleInstance
)
{
// We should say something like
// Args.usage(target, K2JVMCompilerArguments.class);
// but currently cli-parser we are using does not support that
// a corresponding patch has been sent to the authors
// For now, we are using this:
PrintStream
oldErr
=
System
.
err
;
System
.
setErr
(
target
);
try
{
// TODO: use proper argv0
Args
.
usage
(
exampleInstance
);
}
finally
{
System
.
setErr
(
oldErr
);
}
}
}
compiler/cli/src/org/jetbrains/jet/cli/common/CLICompiler.java
浏览文件 @
ce929fab
...
...
@@ -33,11 +33,11 @@ import static org.jetbrains.jet.cli.common.ExitCode.OK;
/**
* @author Pavel Talanov
*/
public
abstract
class
CLICompiler
<
CLArgs
extends
CompilerArguments
,
CEConf
extends
CompileEnvironmentConfig
>
{
public
abstract
class
CLICompiler
<
A
extends
CompilerArguments
,
C
extends
CompileEnvironmentConfiguration
>
{
@NotNull
public
ExitCode
exec
(
@NotNull
PrintStream
errStream
,
@NotNull
String
...
args
)
{
CLArgs
arguments
=
createArguments
();
A
arguments
=
createArguments
();
if
(!
parseArguments
(
errStream
,
arguments
,
args
))
{
return
INTERNAL_ERROR
;
}
...
...
@@ -47,7 +47,7 @@ public abstract class CLICompiler<CLArgs extends CompilerArguments, CEConf exten
/**
* Returns true if the arguments can be parsed correctly
*/
protected
boolean
parseArguments
(
@NotNull
PrintStream
errStream
,
@NotNull
CLArgs
arguments
,
@NotNull
String
[]
args
)
{
protected
boolean
parseArguments
(
@NotNull
PrintStream
errStream
,
@NotNull
A
arguments
,
@NotNull
String
[]
args
)
{
try
{
Args
.
parse
(
arguments
,
args
);
return
true
;
...
...
@@ -66,26 +66,40 @@ public abstract class CLICompiler<CLArgs extends CompilerArguments, CEConf exten
* Allow derived classes to add additional command line arguments
*/
protected
void
usage
(
@NotNull
PrintStream
target
)
{
ArgsUtil
.
printUsage
(
target
,
createArguments
());
// We should say something like
// Args.usage(target, K2JVMCompilerArguments.class);
// but currently cli-parser we are using does not support that
// a corresponding patch has been sent to the authors
// For now, we are using this:
PrintStream
oldErr
=
System
.
err
;
System
.
setErr
(
target
);
try
{
// TODO: use proper argv0
Args
.
usage
(
createArguments
());
}
finally
{
System
.
setErr
(
oldErr
);
}
}
/**
* Strategy method to configure the environment, allowing compiler
* based tools to customise their own plugins
*/
protected
void
configureEnvironment
(
@NotNull
CEConf
configuration
,
@NotNull
CLArgs
arguments
)
{
//TODO: add parameter annotations when KT-1863 is resolved
protected
void
configureEnvironment
(
C
configuration
,
A
arguments
)
{
List
<
CompilerPlugin
>
plugins
=
arguments
.
getCompilerPlugins
();
configuration
.
getCompilerPlugins
().
addAll
(
plugins
);
}
@NotNull
protected
abstract
CLArgs
createArguments
();
protected
abstract
A
createArguments
();
/**
* Executes the compiler on the parsed arguments
*/
@NotNull
public
ExitCode
exec
(
final
PrintStream
errStream
,
CLArgs
arguments
)
{
public
ExitCode
exec
(
final
PrintStream
errStream
,
A
arguments
)
{
if
(
arguments
.
isHelp
())
{
usage
(
errStream
);
return
OK
;
...
...
@@ -104,15 +118,15 @@ public abstract class CLICompiler<CLArgs extends CompilerArguments, CEConf exten
//TODO: can't declare parameters as not null due to KT-1863
@NotNull
protected
abstract
ExitCode
doExecute
(
PrintStream
stream
,
CLArgs
arguments
,
MessageRenderer
renderer
);
protected
abstract
ExitCode
doExecute
(
PrintStream
stream
,
A
arguments
,
MessageRenderer
renderer
);
@NotNull
private
MessageRenderer
getMessageRenderer
(
@NotNull
CLArgs
arguments
)
{
private
MessageRenderer
getMessageRenderer
(
@NotNull
A
arguments
)
{
return
arguments
.
isTags
()
?
MessageRenderer
.
TAGS
:
MessageRenderer
.
PLAIN
;
}
protected
void
printVersionIfNeeded
(
@NotNull
PrintStream
errStream
,
@NotNull
CLArgs
arguments
,
@NotNull
A
arguments
,
@NotNull
MessageRenderer
messageRenderer
)
{
if
(
arguments
.
isVersion
())
{
String
versionMessage
=
messageRenderer
.
render
(
CompilerMessageSeverity
.
INFO
,
...
...
compiler/cli/src/org/jetbrains/jet/cli/common/CompileEnvironmentConfig.java
→
compiler/cli/src/org/jetbrains/jet/cli/common/CompileEnvironmentConfig
uration
.java
浏览文件 @
ce929fab
...
...
@@ -26,7 +26,7 @@ import java.util.List;
/**
* @author Pavel Talanov
*/
public
abstract
class
CompileEnvironmentConfig
{
public
abstract
class
CompileEnvironmentConfig
uration
{
@NotNull
private
final
MessageCollector
messageCollector
;
...
...
@@ -38,7 +38,7 @@ public abstract class CompileEnvironmentConfig {
*
* @see Disposer
*/
public
CompileEnvironmentConfig
(
@NotNull
MessageCollector
messageCollector
)
{
public
CompileEnvironmentConfig
uration
(
@NotNull
MessageCollector
messageCollector
)
{
this
.
messageCollector
=
messageCollector
;
}
...
...
compiler/cli/src/org/jetbrains/jet/cli/js/K2JSCompileEnvironmentConfiguration.java
浏览文件 @
ce929fab
...
...
@@ -18,13 +18,13 @@ package org.jetbrains.jet.cli.js;
import
com.intellij.openapi.util.Disposer
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.cli.common.CompileEnvironmentConfig
;
import
org.jetbrains.jet.cli.common.CompileEnvironmentConfig
uration
;
import
org.jetbrains.jet.cli.common.messages.MessageCollector
;
/**
* @author Pavel Talanov
*/
public
class
K2JSCompileEnvironmentConfiguration
extends
CompileEnvironmentConfig
{
public
class
K2JSCompileEnvironmentConfiguration
extends
CompileEnvironmentConfig
uration
{
/**
* NOTE: It's very important to call dispose for every object of this class or there will be memory leaks.
*
...
...
compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java
浏览文件 @
ce929fab
...
...
@@ -25,7 +25,7 @@ import org.jetbrains.annotations.NotNull;
import
org.jetbrains.jet.cli.common.CLICompiler
;
import
org.jetbrains.jet.cli.common.ExitCode
;
import
org.jetbrains.jet.cli.common.messages.*
;
import
org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentConfiguration
;
import
org.jetbrains.jet.cli.jvm.compiler.
K2JVM
CompileEnvironmentConfiguration
;
import
org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil
;
import
org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment
;
import
org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler
;
...
...
@@ -45,7 +45,7 @@ import static org.jetbrains.jet.cli.common.ExitCode.*;
* @author alex.tkachman
*/
@SuppressWarnings
(
"UseOfSystemOutOrSystemErr"
)
public
class
K2JVMCompiler
extends
CLICompiler
<
K2JVMCompilerArguments
,
CompileEnvironmentConfiguration
>
{
public
class
K2JVMCompiler
extends
CLICompiler
<
K2JVMCompilerArguments
,
K2JVM
CompileEnvironmentConfiguration
>
{
public
static
void
main
(
String
...
args
)
{
doMain
(
new
K2JVMCompiler
(),
args
);
...
...
@@ -89,8 +89,8 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, CompileEn
Disposable
rootDisposable
=
CompileEnvironmentUtil
.
createMockDisposable
();
JetCoreEnvironment
environment
=
JetCoreEnvironment
.
getCoreEnvironmentForJVM
(
rootDisposable
,
dependencies
);
CompileEnvironmentConfiguration
configuration
=
new
CompileEnvironmentConfiguration
(
environment
,
dependencies
,
messageCollector
);
K2JVM
CompileEnvironmentConfiguration
configuration
=
new
K2JVMCompileEnvironmentConfiguration
(
environment
,
messageCollector
);
messageCollector
.
report
(
CompilerMessageSeverity
.
LOGGING
,
"Configuring the compilation environment"
,
CompilerMessageLocation
.
NO_LOCATION
);
...
...
@@ -175,16 +175,16 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, CompileEn
@Override
protected
void
configureEnvironment
(
@NotNull
CompileEnvironmentConfiguration
configuration
,
@NotNull
K2JVMCompilerArguments
arguments
)
{
protected
void
configureEnvironment
(
K2JVMCompileEnvironmentConfiguration
configuration
,
K2JVMCompilerArguments
arguments
)
{
super
.
configureEnvironment
(
configuration
,
arguments
);
if
(
configuration
.
getEnvironment
().
getCompilerDependencies
().
getRuntimeJar
()
!=
null
)
{
CompileEnvironmentUtil
.
addToClasspath
(
configuration
.
getEnvironment
(),
configuration
.
getEnvironment
().
getCompilerDependencies
().
getRuntimeJar
());
CompileEnvironmentUtil
.
addToClasspath
(
configuration
.
getEnvironment
(),
configuration
.
getEnvironment
().
getCompilerDependencies
().
getRuntimeJar
());
}
if
(
arguments
.
classpath
!=
null
)
{
final
Iterable
<
String
>
classpath
=
Splitter
.
on
(
File
.
pathSeparatorChar
).
split
(
arguments
.
classpath
);
Iterable
<
String
>
classpath
=
Splitter
.
on
(
File
.
pathSeparatorChar
).
split
(
arguments
.
classpath
);
CompileEnvironmentUtil
.
addToClasspath
(
configuration
.
getEnvironment
(),
Iterables
.
toArray
(
classpath
,
String
.
class
));
}
}
...
...
compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/CompileEnvironmentUtil.java
浏览文件 @
ce929fab
...
...
@@ -62,7 +62,7 @@ public class CompileEnvironmentUtil {
@Nullable
public
static
File
getUnpackedRuntimePath
()
{
URL
url
=
CompileEnvironmentConfiguration
.
class
.
getClassLoader
().
getResource
(
"jet/JetObject.class"
);
URL
url
=
K2JVM
CompileEnvironmentConfiguration
.
class
.
getClassLoader
().
getResource
(
"jet/JetObject.class"
);
if
(
url
!=
null
&&
url
.
getProtocol
().
equals
(
"file"
))
{
return
new
File
(
url
.
getPath
()).
getParentFile
().
getParentFile
();
}
...
...
@@ -71,7 +71,7 @@ public class CompileEnvironmentUtil {
@Nullable
public
static
File
getRuntimeJarPath
()
{
URL
url
=
CompileEnvironmentConfiguration
.
class
.
getClassLoader
().
getResource
(
"jet/JetObject.class"
);
URL
url
=
K2JVM
CompileEnvironmentConfiguration
.
class
.
getClassLoader
().
getResource
(
"jet/JetObject.class"
);
if
(
url
!=
null
&&
url
.
getProtocol
().
equals
(
"jar"
))
{
String
path
=
url
.
getPath
();
return
new
File
(
path
.
substring
(
path
.
indexOf
(
":"
)
+
1
,
path
.
indexOf
(
"!/"
)));
...
...
@@ -163,7 +163,7 @@ public class CompileEnvironmentUtil {
scriptEnvironment
.
addSources
(
moduleScriptFile
);
GenerationState
generationState
=
KotlinToJVMBytecodeCompiler
.
analyzeAndGenerate
(
new
CompileEnvironmentConfiguration
(
scriptEnvironment
,
messageCollector
),
false
);
.
analyzeAndGenerate
(
new
K2JVM
CompileEnvironmentConfiguration
(
scriptEnvironment
,
messageCollector
),
false
);
if
(
generationState
==
null
)
{
return
null
;
}
...
...
@@ -195,7 +195,7 @@ public class CompileEnvironmentUtil {
}
}
else
{
loader
=
new
GeneratedClassLoader
(
factory
,
CompileEnvironmentConfiguration
.
class
.
getClassLoader
());
loader
=
new
GeneratedClassLoader
(
factory
,
K2JVM
CompileEnvironmentConfiguration
.
class
.
getClassLoader
());
}
try
{
Class
namespaceClass
=
loader
.
loadClass
(
JvmAbi
.
PACKAGE_CLASS
);
...
...
compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/CompileEnvironmentConfiguration.java
→
compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/
K2JVM
CompileEnvironmentConfiguration.java
浏览文件 @
ce929fab
...
...
@@ -18,36 +18,27 @@ package org.jetbrains.jet.cli.jvm.compiler;
import
com.intellij.openapi.util.Disposer
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.jet.cli.common.CompileEnvironmentConfig
;
import
org.jetbrains.jet.cli.common.CompileEnvironmentConfig
uration
;
import
org.jetbrains.jet.cli.common.messages.MessageCollector
;
import
org.jetbrains.jet.lang.resolve.java.CompilerDependencies
;
/**
* @author abreslav
*/
public
class
CompileEnvironmentConfiguration
extends
CompileEnvironmentConfig
{
public
class
K2JVMCompileEnvironmentConfiguration
extends
CompileEnvironmentConfiguration
{
private
final
JetCoreEnvironment
environment
;
private
final
CompilerDependencies
compilerDependencies
;
/**
* NOTE: It's very important to call dispose for every object of this class or there will be memory leaks.
*
* @see Disposer
*/
public
CompileEnvironmentConfiguration
(
@NotNull
JetCoreEnvironment
environment
,
@NotNull
CompilerDependencies
compilerDependencies
,
public
K2JVMCompileEnvironmentConfiguration
(
@NotNull
JetCoreEnvironment
environment
,
@NotNull
MessageCollector
messageCollector
)
{
super
(
messageCollector
);
this
.
compilerDependencies
=
compilerDependencies
;
this
.
environment
=
environment
;
}
public
JetCoreEnvironment
getEnvironment
()
{
return
environment
;
}
@NotNull
public
CompilerDependencies
getCompilerDependencies
()
{
return
compilerDependencies
;
}
}
compiler/cli/src/org/jetbrains/jet/cli/jvm/compiler/KotlinToJVMBytecodeCompiler.java
浏览文件 @
ce929fab
...
...
@@ -59,7 +59,7 @@ public class KotlinToJVMBytecodeCompiler {
@Nullable
public
static
ClassFileFactory
compileModule
(
CompileEnvironmentConfiguration
configuration
,
K2JVM
CompileEnvironmentConfiguration
configuration
,
Module
moduleBuilder
,
File
directory
)
{
...
...
@@ -82,7 +82,7 @@ public class KotlinToJVMBytecodeCompiler {
}
public
static
boolean
compileModules
(
CompileEnvironmentConfiguration
configuration
,
K2JVM
CompileEnvironmentConfiguration
configuration
,
@NotNull
List
<
Module
>
modules
,
...
...
@@ -118,7 +118,7 @@ public class KotlinToJVMBytecodeCompiler {
}
private
static
boolean
compileBunchOfSources
(
CompileEnvironmentConfiguration
configuration
,
K2JVM
CompileEnvironmentConfiguration
configuration
,
String
jar
,
String
outputDir
,
boolean
includeRuntime
...
...
@@ -163,7 +163,7 @@ public class KotlinToJVMBytecodeCompiler {
}
public
static
boolean
compileBunchOfSources
(
CompileEnvironmentConfiguration
configuration
,
K2JVM
CompileEnvironmentConfiguration
configuration
,
String
sourceFileOrDir
,
String
jar
,
String
outputDir
,
boolean
includeRuntime
)
{
configuration
.
getEnvironment
().
addSources
(
sourceFileOrDir
);
...
...
@@ -172,7 +172,7 @@ public class KotlinToJVMBytecodeCompiler {
}
public
static
boolean
compileBunchOfSourceDirectories
(
CompileEnvironmentConfiguration
configuration
,
K2JVM
CompileEnvironmentConfiguration
configuration
,
List
<
String
>
sources
,
String
jar
,
String
outputDir
,
boolean
includeRuntime
)
{
for
(
String
source
:
sources
)
{
...
...
@@ -184,7 +184,7 @@ public class KotlinToJVMBytecodeCompiler {
@Nullable
public
static
ClassLoader
compileText
(
CompileEnvironmentConfiguration
configuration
,
K2JVM
CompileEnvironmentConfiguration
configuration
,
String
code
)
{
configuration
.
getEnvironment
()
.
addSources
(
new
LightVirtualFile
(
"script"
+
LocalTimeCounter
.
currentTime
()
+
".kt"
,
JetLanguage
.
INSTANCE
,
code
));
...
...
@@ -197,13 +197,13 @@ public class KotlinToJVMBytecodeCompiler {
}
@Nullable
public
static
GenerationState
analyzeAndGenerate
(
CompileEnvironmentConfiguration
configuration
)
{
public
static
GenerationState
analyzeAndGenerate
(
K2JVM
CompileEnvironmentConfiguration
configuration
)
{
return
analyzeAndGenerate
(
configuration
,
configuration
.
getEnvironment
().
getCompilerDependencies
().
getCompilerSpecialMode
().
isStubs
());
}
@Nullable
public
static
GenerationState
analyzeAndGenerate
(
CompileEnvironmentConfiguration
configuration
,
K2JVM
CompileEnvironmentConfiguration
configuration
,
boolean
stubs
)
{
AnalyzeExhaust
exhaust
=
analyze
(
configuration
,
stubs
);
...
...
@@ -219,7 +219,7 @@ public class KotlinToJVMBytecodeCompiler {
@Nullable
private
static
AnalyzeExhaust
analyze
(
final
CompileEnvironmentConfiguration
configuration
,
final
K2JVM
CompileEnvironmentConfiguration
configuration
,
boolean
stubs
)
{
final
JetCoreEnvironment
environment
=
configuration
.
getEnvironment
();
AnalyzerWithCompilerReport
analyzerWithCompilerReport
=
new
AnalyzerWithCompilerReport
(
configuration
.
getMessageCollector
());
...
...
@@ -243,7 +243,7 @@ public class KotlinToJVMBytecodeCompiler {
@NotNull
private
static
GenerationState
generate
(
final
CompileEnvironmentConfiguration
configuration
,
final
K2JVM
CompileEnvironmentConfiguration
configuration
,
AnalyzeExhaust
exhaust
,
boolean
stubs
)
{
JetCoreEnvironment
environment
=
configuration
.
getEnvironment
();
...
...
compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/CompilerSpecialMode.java
浏览文件 @
ce929fab
...
...
@@ -24,6 +24,7 @@ public enum CompilerSpecialMode {
BUILTINS
,
JDK_HEADERS
,
STDLIB
,
JS
;
public
boolean
includeJdkHeaders
()
{
...
...
compiler/tests/org/jetbrains/jet/codegen/CompileTextTest.java
浏览文件 @
ce929fab
...
...
@@ -16,7 +16,7 @@
package
org.jetbrains.jet.codegen
;
import
org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentConfiguration
;
import
org.jetbrains.jet.cli.jvm.compiler.
K2JVM
CompileEnvironmentConfiguration
;
import
org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler
;
import
org.jetbrains.jet.cli.common.messages.MessageCollector
;
...
...
@@ -27,7 +27,7 @@ public class CompileTextTest extends CodegenTestCase {
public
void
testMe
()
throws
ClassNotFoundException
,
NoSuchMethodException
,
InvocationTargetException
,
IllegalAccessException
{
createEnvironmentWithMockJdk
();
String
text
=
"import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()"
;
CompileEnvironmentConfiguration
configuration
=
new
CompileEnvironmentConfiguration
(
K2JVMCompileEnvironmentConfiguration
configuration
=
new
K2JVM
CompileEnvironmentConfiguration
(
myEnvironment
,
MessageCollector
.
PLAIN_TEXT_TO_SYSTEM_ERR
);
configuration
.
getEnvironment
().
addToClasspathFromClassLoader
(
getClass
().
getClassLoader
());
ClassLoader
classLoader
=
KotlinToJVMBytecodeCompiler
.
compileText
(
configuration
,
text
);
...
...
compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java
浏览文件 @
ce929fab
...
...
@@ -22,7 +22,7 @@ import junit.framework.Test;
import
junit.framework.TestCase
;
import
junit.framework.TestSuite
;
import
org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime
;
import
org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentConfiguration
;
import
org.jetbrains.jet.cli.jvm.compiler.
K2JVM
CompileEnvironmentConfiguration
;
import
org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler
;
import
org.jetbrains.jet.cli.common.messages.MessageCollector
;
import
org.jetbrains.jet.lang.descriptors.ClassDescriptor
;
...
...
@@ -87,7 +87,7 @@ public class TestlibTest extends CodegenTestCase {
myEnvironment
.
addSources
(
localFileSystem
.
findFileByPath
(
JetParsingTest
.
getTestDataDir
()
+
"/../../libraries/kunit/src"
));
GenerationState
generationState
=
KotlinToJVMBytecodeCompiler
.
analyzeAndGenerate
(
new
CompileEnvironmentConfiguration
(
myEnvironment
,
MessageCollector
.
PLAIN_TEXT_TO_SYSTEM_ERR
),
false
);
.
analyzeAndGenerate
(
new
K2JVM
CompileEnvironmentConfiguration
(
myEnvironment
,
MessageCollector
.
PLAIN_TEXT_TO_SYSTEM_ERR
),
false
);
if
(
generationState
==
null
)
{
throw
new
RuntimeException
(
"There were compilation errors"
);
...
...
idea/src/org/jetbrains/jet/plugin/compiler/K2JSCompiler.java
浏览文件 @
ce929fab
...
...
@@ -22,6 +22,7 @@ import com.intellij.openapi.compiler.CompilerMessageCategory;
import
com.intellij.openapi.compiler.TranslatingCompiler
;
import
com.intellij.openapi.module.Module
;
import
com.intellij.openapi.project.Project
;
import
com.intellij.openapi.roots.ModuleRootManager
;
import
com.intellij.openapi.vfs.VirtualFile
;
import
com.intellij.util.Chunk
;
import
jet.Function1
;
...
...
@@ -62,7 +63,7 @@ public final class K2JSCompiler implements TranslatingCompiler {
return
;
}
Module
module
=
moduleChunk
.
getNodes
().
iterator
().
next
();
final
Module
module
=
moduleChunk
.
getNodes
().
iterator
().
next
();
final
CompilerEnvironment
environment
=
CompilerEnvironment
.
getEnvironmentFor
(
context
,
module
,
/*tests = */
false
);
if
(!
environment
.
success
())
{
environment
.
reportErrorsTo
(
context
);
...
...
@@ -73,7 +74,7 @@ public final class K2JSCompiler implements TranslatingCompiler {
outputCompilerMessagesAndHandleExitCode
(
context
,
collector
,
new
Function1
<
PrintStream
,
Integer
>()
{
@Override
public
Integer
invoke
(
PrintStream
stream
)
{
return
execInProcess
(
context
,
environment
,
stream
);
return
execInProcess
(
context
,
environment
,
stream
,
module
);
}
});
sink
.
add
(
environment
.
getOutput
().
getPath
(),
collector
.
getOutputs
(),
collector
.
getSources
().
toArray
(
VirtualFile
.
EMPTY_ARRAY
));
...
...
@@ -81,11 +82,15 @@ public final class K2JSCompiler implements TranslatingCompiler {
@NotNull
private
static
Integer
execInProcess
(
@NotNull
CompileContext
context
,
@NotNull
CompilerEnvironment
environment
,
@NotNull
PrintStream
out
)
{
@NotNull
CompilerEnvironment
environment
,
@NotNull
PrintStream
out
,
@NotNull
Module
module
)
{
try
{
String
[]
commandLineArgs
=
{
"-tags"
,
"-verbose"
,
"-version"
};
Object
rc
=
invokeExecMethod
(
environment
,
out
,
context
,
commandLineArgs
,
"org.jetbrains.jet.cli.js.K2JSCompiler"
);
VirtualFile
[]
roots
=
ModuleRootManager
.
getInstance
(
module
).
getSourceRoots
();
if
(
roots
.
length
!=
1
)
{
context
.
addMessage
(
CompilerMessageCategory
.
ERROR
,
"K2JSCompiler does not support module source roots."
,
null
,
-
1
,
-
1
);
return
-
1
;
}
String
[]
commandLineArgs
=
{
"-tags"
,
"-verbose"
,
"-version"
,
"-srcdir"
,
roots
[
0
].
getPath
()};
Object
rc
=
invokeExecMethod
(
environment
,
out
,
context
,
commandLineArgs
,
"org.jetbrains.jet.cli.js.K2JSCompiler"
);
return
CompilerUtils
.
getReturnCodeFromObject
(
rc
);
}
catch
(
Throwable
e
)
{
...
...
libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt
浏览文件 @
ce929fab
...
...
@@ -5,7 +5,7 @@ import java.io.PrintStream
import
org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
import
org.jetbrains.jet.cli.jvm.K2JVMCompiler
import
org.jetbrains.jet.cli.common.CLICompiler
import
org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentConfiguration
import
org.jetbrains.jet.cli.jvm.compiler.
K2JVM
CompileEnvironmentConfiguration
import
org.jetbrains.kotlin.doc.highlighter.HtmlCompilerPlugin
import
org.jetbrains.jet.cli.common.ExitCode
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录