public static void ShellCodeCmd(CodeConverter C, CodeWriter writer, EocCallExpression expr) { if (expr.ParamList.Count != 1) { throw new Exception("置入代码 必须提供 字节集/文本型常量"); } byte[] shellCode; object value; if (expr.ParamList[0].TryGetConstValueWithCast(ProjectConverter.CppTypeName_Bin, out value)) { shellCode = ((object[])value).Cast <byte>().ToArray(); } else if (expr.ParamList[0].TryGetConstValueWithCast(ProjectConverter.CppTypeName_String, out value)) { shellCode = File.ReadAllBytes((string)value); } else { throw new Exception("置入代码 必须提供 字节集/文本型常量"); } writer.Write("__asm"); using (writer.NewBlock()) { foreach (var codeByte in shellCode) { writer.NewLine(); writer.Write($"_emit {codeByte}"); } } }
public static void IsNullParameterCmd(CodeConverter C, CodeWriter writer, EocCallExpression expr) { if (expr.ParamList[0] is EocVariableExpression x && x.VariableInfo is EocParameterInfo paramInfo && paramInfo.Optional) { writer.Write("eoc_isNull_"); writer.Write(paramInfo.CppName); }
public static void IsNullParameterCmd(CodeConverter C, CodeWriter writer, EocCallExpression expr) { if (expr.ParamList[0] is EocVariableExpression x && x.VariableInfo is MethodParameterInfo paramInfo && paramInfo.OptionalParameter) { var name = C.P.GetUserDefinedName_SimpleCppName(x.VariableInfo.Id); writer.Write("eoc_isNull_"); writer.Write(name); }
public static void ReturnCmd(CodeConverter C, CodeWriter writer, EocCallExpression expr) { if (expr.ParamList.Count == 1 && expr.ParamList[0] != null) { writer.Write("return "); expr.ParamList[0].WriteTo(writer); } else { writer.Write("return"); } }
public static void LetMutilCmd(CodeConverter C, CodeWriter writer, EocCallExpression callExpr) { var source = callExpr.ParamList[0]; for (int i = 1; i < callExpr.ParamList.Count; i++) { var cur = callExpr.ParamList[i]; source = new EocCallExpression(C, C.P.GetEocCmdInfo(0, 54), null, new List <EocExpression> { cur, source }, C.P.EocLibs[0].SuperTemplateAssembly); } source.WriteTo(writer); }
public static void LetCmd(CodeConverter C, CodeWriter writer, EocCallExpression callExpr) { var target = callExpr.ParamList[0]; C.WriteLetExpression(writer, target, () => callExpr.ParamList[1].WriteToWithCast(writer, target.GetResultType())); }
public static void ContinueCmd(CodeConverter C, CodeWriter writer, EocCallExpression expr) { writer.Write("continue"); }
public static void BreakCmd(CodeConverter C, CodeWriter writer, EocCallExpression expr) { writer.Write("break"); }