Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
67b5f248
提交
67b5f248
authored
15 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
A Java parser / Java to C converter.
上级
3f377668
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
31 行增加
和
12 行删除
+31
-12
JavaParser.java
h2/src/tools/org/h2/java/JavaParser.java
+3
-0
TestApp.java
h2/src/tools/org/h2/java/TestApp.java
+2
-2
PrintStream.java
h2/src/tools/org/h2/java/io/PrintStream.java
+2
-4
String.java
h2/src/tools/org/h2/java/lang/String.java
+7
-5
System.java
h2/src/tools/org/h2/java/lang/System.java
+17
-1
没有找到文件。
h2/src/tools/org/h2/java/JavaParser.java
浏览文件 @
67b5f248
...
@@ -1280,6 +1280,9 @@ public class JavaParser {
...
@@ -1280,6 +1280,9 @@ public class JavaParser {
if
(
m
.
block
!=
null
)
{
if
(
m
.
block
!=
null
)
{
out
.
print
(
m
.
block
.
toString
());
out
.
print
(
m
.
block
.
toString
());
}
}
if
(
m
.
isConstructor
)
{
out
.
println
(
indent
(
"return this;"
));
}
out
.
println
(
"}"
);
out
.
println
(
"}"
);
out
.
println
();
out
.
println
();
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/java/TestApp.java
浏览文件 @
67b5f248
...
@@ -13,7 +13,7 @@ public class TestApp {
...
@@ -13,7 +13,7 @@ public class TestApp {
/* c:
/* c:
int main(
char** args
) {
int main(
int argc, char** argv
) {
org_h2_java_TestApp_main(null);
org_h2_java_TestApp_main(null);
}
}
...
@@ -25,8 +25,8 @@ int main(char** args) {
...
@@ -25,8 +25,8 @@ int main(char** args) {
* @param args the command line arguments
* @param args the command line arguments
*/
*/
public
static
void
main
(
String
...
args
)
{
public
static
void
main
(
String
...
args
)
{
// c:printf("Hello\n");
System
.
out
.
println
(
"Hello World"
);
System
.
out
.
println
(
"Hello World"
);
System
.
out
.
println
(
"Hello!"
);
}
}
/**
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/java/io/PrintStream.java
浏览文件 @
67b5f248
package
org
.
h2
.
java
.
io
;
package
org
.
h2
.
java
.
io
;
import
org.h2.java.lang.System
;
/**
/**
* A print stream.
* A print stream.
*/
*/
...
@@ -13,8 +11,8 @@ public class PrintStream {
...
@@ -13,8 +11,8 @@ public class PrintStream {
* @param s the string
* @param s the string
*/
*/
public
void
println
(
String
s
)
{
public
void
println
(
String
s
)
{
System
.
arraycopy
(
null
,
0
,
null
,
0
,
1
);
// c: int x = LENGTH(s->chars
);
// c: printf("%
s\n"
);
// c: printf("%
.*S\n", x, s->chars
);
}
}
}
}
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/java/lang/String.java
浏览文件 @
67b5f248
...
@@ -5,11 +5,12 @@ package org.h2.java.lang;
...
@@ -5,11 +5,12 @@ package org.h2.java.lang;
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <wchar.h>
#define jvoid void
#define jvoid void
#define jboolean int8_t
#define jboolean int8_t
#define jbyte int8_t
#define jbyte int8_t
#define jchar
int16
_t
#define jchar
wchar
_t
#define jint int32_t
#define jint int32_t
#define jlong int64_t
#define jlong int64_t
#define jfloat float
#define jfloat float
...
@@ -18,7 +19,7 @@ package org.h2.java.lang;
...
@@ -18,7 +19,7 @@ package org.h2.java.lang;
#define false 0
#define false 0
#define null 0
#define null 0
#define LENGTH(a) (*(((jint*)(a))-
1
))
#define LENGTH(a) (*(((jint*)(a))-
2
))
#define NEW_ARRAY(size, length) new_array(0, size, length)
#define NEW_ARRAY(size, length) new_array(0, size, length)
#define NEW_OBJ_ARRAY(length) new_array(1, sizeof(void*), length)
#define NEW_OBJ_ARRAY(length) new_array(1, sizeof(void*), length)
#define NEW_OBJ(typeId, typeName) new_object(typeId, sizeof(struct typeName))
#define NEW_OBJ(typeId, typeName) new_object(typeId, sizeof(struct typeName))
...
@@ -42,7 +43,7 @@ public class String {
...
@@ -42,7 +43,7 @@ public class String {
void* new_array(jint object, jint size, jint length) {
void* new_array(jint object, jint size, jint length) {
int count = sizeof(jint) * 2 + size * length;
int count = sizeof(jint) * 2 + size * length;
int* m = (jint*) calloc(1, count);
int* m = (jint*) calloc(1, count);
*m =
object << 31
+ length;
*m =
(object << 31)
+ length;
*(m+1) = 1;
*(m+1) = 1;
return m + 2;
return m + 2;
}
}
...
@@ -67,11 +68,12 @@ void* set_object(void** target, void* o) {
...
@@ -67,11 +68,12 @@ void* set_object(void** target, void* o) {
if (o != 0) {
if (o != 0) {
(*(m - 2))++;
(*(m - 2))++;
}
}
return m;
}
}
void* string(char* s) {
void* string(char* s) {
int len = strlen(s);
int len = strlen(s);
jchar* chars = NEW_ARRAY(sizeof(
char), 1 * LENGTH(chars)
);
jchar* chars = NEW_ARRAY(sizeof(
jchar), len
);
for (int i = 0; i < len; i++) {
for (int i = 0; i < len; i++) {
chars[i] = s[i];
chars[i] = s[i];
}
}
...
@@ -85,7 +87,7 @@ void* string(char* s) {
...
@@ -85,7 +87,7 @@ void* string(char* s) {
public
String
(
char
[]
chars
)
{
public
String
(
char
[]
chars
)
{
this
.
chars
=
new
char
[
chars
.
length
];
this
.
chars
=
new
char
[
chars
.
length
];
System
.
arraycopy
(
chars
,
0
,
this
.
chars
,
0
,
chars
.
length
);
System
.
arraycopy
Chars
(
chars
,
0
,
this
.
chars
,
0
,
chars
.
length
);
}
}
public
int
hashCode
()
{
public
int
hashCode
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/tools/org/h2/java/lang/System.java
浏览文件 @
67b5f248
...
@@ -23,6 +23,22 @@ public class System {
...
@@ -23,6 +23,22 @@ public class System {
* @param length the number of element to copy
* @param length the number of element to copy
*/
*/
public
static
void
arraycopy
(
java
.
lang
.
Object
src
,
int
srcPos
,
java
.
lang
.
Object
dest
,
int
destPos
,
int
length
)
{
public
static
void
arraycopy
(
java
.
lang
.
Object
src
,
int
srcPos
,
java
.
lang
.
Object
dest
,
int
destPos
,
int
length
)
{
// c: memmove(src + srcPos, dest + destPos, length);
// TODO
// c: memmove(dest + destPos, src + srcPos, length);
}
}
/**
* Copy data from the source to the target.
* Source and target may overlap.
*
* @param src the source array
* @param srcPos the first element in the source array
* @param dest the destination
* @param destPos the first element in the destination
* @param length the number of element to copy
*/
public
static
void
arraycopyChars
(
char
[]
src
,
int
srcPos
,
char
[]
dest
,
int
destPos
,
int
length
)
{
// c: memmove(((jchar*)dest) + destPos, ((jchar*)src) + srcPos, sizeof(jchar) * length);
}
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论