Unverified Commit 5b09cb15 by Enkelmann Committed by GitHub

Fix pcode mnemonic parsing for CEIL and FLOOR (#147)

parent b8b08a42
......@@ -354,7 +354,7 @@ impl<'a> GraphBuilder<'a> {
.term
.jmps
.iter()
.find(|jump| matches!(jump.term, Jmp::Call{..}))
.find(|jump| matches!(jump.term, Jmp::Call { .. }))
.unwrap();
let return_combine_node = self.graph.add_node(Node::CallReturn {
call: (call_block, caller_sub),
......
......@@ -129,7 +129,7 @@ impl<'a> Context<'a> {
mut state: State,
call: &Term<Jmp>,
extern_symbol: &ExternSymbol,
) -> Option<State> {
) -> State {
match extern_symbol.get_unique_return_register() {
Ok(return_register) => {
let object_id = AbstractIdentifier::new(
......@@ -148,12 +148,12 @@ impl<'a> Context<'a> {
Bitvector::zero(apint::BitWidth::from(address_bytesize)).into(),
);
state.set_register(return_register, pointer.into());
Some(state)
state
}
Err(err) => {
// We cannot track the new object, since we do not know where to store the pointer to it.
self.log_debug(Err(err), Some(&call.tid));
Some(state)
state
}
}
}
......@@ -167,7 +167,7 @@ impl<'a> Context<'a> {
mut new_state: State,
call: &Term<Jmp>,
extern_symbol: &ExternSymbol,
) -> Option<State> {
) -> State {
match extern_symbol.get_unique_parameter() {
Ok(parameter) => {
let parameter_value = state.eval_parameter_arg(
......@@ -205,18 +205,18 @@ impl<'a> Context<'a> {
);
}
new_state.remove_unreferenced_objects();
Some(new_state)
new_state
}
Err(err) => {
self.log_debug(Err(err), Some(&call.tid));
Some(new_state)
new_state
}
}
}
Err(err) => {
// We do not know which memory object to free
self.log_debug(Err(err), Some(&call.tid));
Some(new_state)
new_state
}
}
}
......@@ -310,7 +310,7 @@ impl<'a> Context<'a> {
mut new_state: State,
call: &Term<Jmp>,
extern_symbol: &ExternSymbol,
) -> Option<State> {
) -> State {
self.log_debug(
new_state.clear_stack_parameter(
extern_symbol,
......@@ -349,7 +349,7 @@ impl<'a> Context<'a> {
.memory
.assume_arbitrary_writes_to_object(id, &possible_referenced_ids);
}
Some(new_state)
new_state
}
/// Handle a generic call whose target function is unknown.
......
......@@ -274,12 +274,16 @@ impl<'a> crate::analysis::forward_interprocedural_fixpoint::Context<'a> for Cont
match extern_symbol.name.as_str() {
malloc_like_fn if self.allocation_symbols.iter().any(|x| x == malloc_like_fn) => {
self.add_new_object_in_call_return_register(new_state, call, extern_symbol)
Some(self.add_new_object_in_call_return_register(
new_state,
call,
extern_symbol,
))
}
free_like_fn if self.deallocation_symbols.iter().any(|x| x == free_like_fn) => {
self.mark_parameter_object_as_freed(state, new_state, call, extern_symbol)
Some(self.mark_parameter_object_as_freed(state, new_state, call, extern_symbol))
}
_ => self.handle_generic_extern_call(state, new_state, call, extern_symbol),
_ => Some(self.handle_generic_extern_call(state, new_state, call, extern_symbol)),
}
} else {
panic!("Extern symbol not found.");
......
......@@ -42,7 +42,7 @@ where
/// the finalizer must be attached to it on the Ocaml side!
trait OcamlSendable: std::marker::Sized {
/// Pack the object into an Ocaml value
fn to_ocaml(self) -> ocaml::Value {
fn into_ocaml(self) -> ocaml::Value {
let boxed_val = Rc::new(self);
ocaml::Value::nativeint(Rc::into_raw(boxed_val) as isize)
}
......
......@@ -83,7 +83,7 @@ caml!(rs_finalize_json_builder(builder_val) {
/// Build JsonBuilder::Null as Ocaml value
fn build_serde_null() -> ocaml::Value {
JsonBuilder::Null.to_ocaml()
JsonBuilder::Null.into_ocaml()
}
caml!(rs_build_serde_null(_unit) {
......@@ -95,7 +95,7 @@ caml!(rs_build_serde_null(_unit) {
/// Build JsonBuilder::Bool as Ocaml value
fn build_serde_bool(bool_val: ocaml::Value) -> ocaml::Value {
let boolean: bool = bool::from_value(bool_val);
JsonBuilder::Bool(boolean).to_ocaml()
JsonBuilder::Bool(boolean).into_ocaml()
}
caml!(rs_build_serde_bool(bool_val) {
......@@ -107,7 +107,7 @@ caml!(rs_build_serde_bool(bool_val) {
/// Build JsonBuilder::Number as Ocaml value
fn build_serde_number(num: ocaml::Value) -> ocaml::Value {
let num: isize = ocaml::Value::isize_val(&num);
JsonBuilder::Number(num).to_ocaml()
JsonBuilder::Number(num).into_ocaml()
}
caml!(rs_build_serde_number(number) {
......@@ -154,7 +154,7 @@ fn build_serde_bitvector(bitvector_string_val: ocaml::Value) -> ocaml::Value {
("width".to_string(), Rc::new(JsonBuilder::Array(width_list))),
]);
result.to_ocaml()
result.into_ocaml()
}
caml!(rs_build_serde_bitvector(bitvector_string) {
......@@ -166,7 +166,7 @@ caml!(rs_build_serde_bitvector(bitvector_string) {
/// Build JsonBuilder::String as Ocaml value
fn build_serde_string(string_val: ocaml::Value) -> ocaml::Value {
let string = String::from_value(string_val);
JsonBuilder::String(string).to_ocaml()
JsonBuilder::String(string).into_ocaml()
}
caml!(rs_build_serde_string(string_val) {
......@@ -183,7 +183,7 @@ fn build_serde_array_from_list(list_val: ocaml::Value) -> ocaml::Value {
.into_iter()
.map(|ocaml_val| unsafe { JsonBuilder::from_ocaml_rc(&ocaml_val) })
.collect();
JsonBuilder::Array(vec).to_ocaml()
JsonBuilder::Array(vec).into_ocaml()
}
caml!(rs_build_serde_array_from_list(list_val) {
......@@ -211,7 +211,7 @@ fn build_serde_object(tuple_list_val: ocaml::Value) -> ocaml::Value {
(key, data)
})
.collect();
JsonBuilder::Object(pairs).to_ocaml()
JsonBuilder::Object(pairs).into_ocaml()
}
caml!(rs_build_serde_object(tuple_list_val) {
......
......@@ -80,22 +80,24 @@ impl Term<Def> {
output_sub_register: String,
) -> Option<Tid> {
match &self.term {
Def::Assign { var, value } if output_name == var.name => match value {
Expression::Cast { op, arg, .. } => {
Def::Assign {
var,
value:
Expression::Cast {
op: CastOpType::IntZExt,
arg,
..
},
} if output_name == var.name => {
let argument: &Expression = arg;
match op {
CastOpType::IntZExt => match argument {
match argument {
Expression::Var(var) if var.name == output_sub_register => {
Some(self.tid.clone())
}
_ => None,
},
_ => None,
}
}
_ => None,
},
_ => None,
}
}
}
......
......@@ -210,7 +210,9 @@ pub enum ExpressionType {
FLOAT_NEG,
FLOAT_ABS,
FLOAT_SQRT,
#[serde(alias = "CEIL")]
FLOAT_CEIL,
#[serde(alias = "FLOOR")]
FLOAT_FLOOR,
#[serde(alias = "ROUND")]
FLOAT_ROUND,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment