Real classes for arrays, initialization order
This commit is contained in:
parent
70a11283db
commit
5cf17d5ca3
4 changed files with 160 additions and 35 deletions
|
@ -364,6 +364,17 @@ impl JavaLangDouble {
|
|||
struct JavaLangObject {}
|
||||
|
||||
impl JavaLangObject {
|
||||
fn clone(jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
let frame = {
|
||||
let frame_index = jvm.stack_frames.len() - 1;
|
||||
&mut jvm.stack_frames[frame_index]
|
||||
};
|
||||
let this = frame.load_local_reference(0).unwrap();
|
||||
|
||||
let clone = jvm.heap_area.object_area.clone_(this);
|
||||
|
||||
Ok(JVMCallbackOperation::ReturnFrame(clone.into()))
|
||||
}
|
||||
|
||||
fn get_class(jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
let frame = {
|
||||
|
@ -455,6 +466,23 @@ impl JavaLangStringUTF16 {
|
|||
struct JavaLangSystem {}
|
||||
|
||||
impl JavaLangSystem {
|
||||
fn set_in_0(jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
let frame = {
|
||||
let frame_index = jvm.stack_frames.len() - 1;
|
||||
&mut jvm.stack_frames[frame_index]
|
||||
};
|
||||
let input_stream = frame.load_local_reference(0).unwrap();
|
||||
|
||||
// TODO: Bypass final
|
||||
jvm.heap_area.static_area.set(
|
||||
&String::from("java/lang/System"),
|
||||
&String::from("in"),
|
||||
FieldValue::Reference(input_stream)
|
||||
)?;
|
||||
|
||||
Ok(JVMCallbackOperation::PopFrame())
|
||||
}
|
||||
|
||||
pub fn arraycopy(jvm: &mut JVM) -> Result<JVMCallbackOperation, Error> {
|
||||
let frame = {
|
||||
let frame_index = jvm.stack_frames.len() - 1;
|
||||
|
@ -1401,7 +1429,7 @@ pub fn function_for(class_name: &str, m: &crate::classfile::MethodInfo) -> Resul
|
|||
argument_types: Box::new([]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname(String::from("java/lang/Object"))},
|
||||
},
|
||||
todo_call
|
||||
JavaLangObject::clone
|
||||
),
|
||||
|
||||
(
|
||||
|
@ -1588,7 +1616,7 @@ pub fn function_for(class_name: &str, m: &crate::classfile::MethodInfo) -> Resul
|
|||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void()},
|
||||
},
|
||||
todo_call
|
||||
JavaLangSystem::set_in_0
|
||||
),
|
||||
|
||||
(
|
||||
|
@ -3766,6 +3794,58 @@ pub fn function_for(class_name: &str, m: &crate::classfile::MethodInfo) -> Resul
|
|||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/io/FileOutputStream",
|
||||
"open0",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Classname("java/lang/String".to_string())},
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() },
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/io/FileOutputStream",
|
||||
"write",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() },
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/io/FileOutputStream",
|
||||
"writeBytes",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
AbstractTypeDescription { array_level: 1, kind: AbstractTypeKind::Byte() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Int() },
|
||||
AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Boolean() },
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
todo_call
|
||||
),
|
||||
|
||||
(
|
||||
"java/io/FileOutputStream",
|
||||
"initIDs",
|
||||
MethodDescriptor {
|
||||
argument_types: Box::new([
|
||||
]),
|
||||
return_type: AbstractTypeDescription { array_level: 0, kind: AbstractTypeKind::Void() },
|
||||
},
|
||||
ignore_call
|
||||
),
|
||||
];
|
||||
|
||||
for (classname, methodname, methoddescriptor, binding) in native_mappings {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue