public Function ConvertFunction(ME3Function obj) { VariableType returnType = null; if (obj.ReturnValue != null) { returnType = ConvertVariable(obj.ReturnValue).VarType; } var parameters = new List <FunctionParameter>(); foreach (var param in obj.Parameters) { var convert = ConvertVariable(param); parameters.Add(new FunctionParameter(convert.VarType, convert.Specifiers, convert.Variables.First(), null, null)); } var ByteCode = new ME3ByteCodeDecompiler(obj, parameters); var body = ByteCode.Decompile(); var func = new Function(obj.Name, returnType, body, new List <Specifier>(), parameters, null, null); var locals = new List <VariableDeclaration>(); foreach (var local in obj.LocalVariables) { var convert = ConvertVariable(local); convert.Outer = func; locals.Add(convert); } func.Locals = locals; return(func); }
public State ConvertState(ME3State obj) { // TODO: ignores and body/labels State parent = null; if (obj.SuperField != null) { parent = new State(obj.SuperField.Name, null, null, null, null, null, null, null, null); } var Funcs = new List <Function>(); var Ignores = new List <Function>(); foreach (var member in obj.DefinedFunctions) { if (member.FunctionFlags.HasFlag(FunctionFlags.Defined)) { Funcs.Add(ConvertFunction(member)); } else { Ignores.Add(new Function(member.Name, null, null, null, null, null, null)); } /* Ignored functions are not marked as defined, so we dont need to lookup the ignormask. * They are defined though, each being its own proper object with simply a return nothing for bytecode. * */ } var ByteCode = new ME3ByteCodeDecompiler(obj, new List <FunctionParameter>()); var body = ByteCode.Decompile(); return(new State(obj.Name, body, new List <Specifier>(), (State)parent, Funcs, new List <Function>(), new List <StateLabel>(), null, null)); }
public State ConvertState(ME3State obj) { // TODO: ignores and body/labels State parent = null; if (obj.SuperField != null) parent = new State(obj.SuperField.Name, null, null, null, null, null, null, null, null); var Funcs = new List<Function>(); var Ignores = new List<Function>(); foreach (var member in obj.DefinedFunctions) { if (member.FunctionFlags.HasFlag(FunctionFlags.Defined)) Funcs.Add(ConvertFunction(member)); else Ignores.Add(new Function(member.Name, null, null, null, null, null, null)); /* Ignored functions are not marked as defined, so we dont need to lookup the ignormask. * They are defined though, each being its own proper object with simply a return nothing for bytecode. * */ } var ByteCode = new ME3ByteCodeDecompiler(obj, new List<FunctionParameter>()); var body = ByteCode.Decompile(); return new State(obj.Name, body, new List<Specifier>(), (State)parent, Funcs, new List<Function>(), new List<StateLabel>(), null, null); }
public Function ConvertFunction(ME3Function obj) { VariableType returnType = null; if (obj.ReturnValue != null) returnType = ConvertVariable(obj.ReturnValue).VarType; var parameters = new List<FunctionParameter>(); foreach(var param in obj.Parameters) { var convert = ConvertVariable(param); parameters.Add(new FunctionParameter(convert.VarType, convert.Specifiers, convert.Variables.First(), null, null)); } var ByteCode = new ME3ByteCodeDecompiler(obj, parameters); var body = ByteCode.Decompile(); var func = new Function(obj.Name, returnType, body, new List<Specifier>(), parameters, null, null); var locals = new List<VariableDeclaration>(); foreach (var local in obj.LocalVariables) { var convert = ConvertVariable(local); convert.Outer = func; locals.Add(convert); } func.Locals = locals; return func; }