public static EscapeIdentifier ( string identifier ) : string | ||
identifier | string | |
Результат | string |
private void EmitLabelledBlock(string label, Action <JavascriptFormatter> writeBody) { if (label == null) { writeBody(Formatter); return; } Formatter.WriteSExpr( "label", (_) => { _.WriteRaw("${0} ", WasmUtil.EscapeIdentifier(label)); _.NewLine(); writeBody(_); }, lineBreakAfter: true ); }
public void EmitFunctionBody(IAstEmitter astEmitter, MethodDefinition method, JSFunctionExpression function) { // Skip Main() and emit it at the footer if (Assembly.EntryPoint == method) { // HACK: Store this so we can use it to emit the entry point's body later EntryPointAstEmitter = astEmitter; return; } var name = WasmUtil.FormatMemberName(method); Switch(PrecedingType.Function, true); Formatter.WriteRaw("(func ${0}", name); Formatter.Indent(); Formatter.NewLine(); int v = 0; foreach (var kvp in function.AllVariables) { var variable = kvp.Value; var type = WasmUtil.PickTypeKeyword(variable.IdentifierType); if (type != null) { Formatter.WriteRaw( "({0} ${1} {2}) ", variable.IsParameter ? "param" : "local", WasmUtil.EscapeIdentifier(kvp.Key), type ); if (v++ >= 3) { v = 0; Formatter.NewLine(); } } } if (function.LabelGroupCount > 0) { Formatter.NewLine(); } for (var i = 0; i < function.LabelGroupCount; i++) { Formatter.WriteRaw("(local $currentLabel_{0} i32) ", i); } var returnType = WasmUtil.PickTypeKeyword(method.ReturnType); if (returnType != "void") { Formatter.NewLine(); Formatter.WriteRaw("(result {0})", returnType); } Formatter.ConditionalNewLine(); Formatter.NewLine(); astEmitter.Emit(function.Body); Formatter.ConditionalNewLine(); Formatter.Unindent(); Formatter.WriteRaw(")"); Formatter.NewLine(); }
private string EscapedName(FieldInfo fi) { return(WasmUtil.EscapeIdentifier(fi.Name)); }