static void EmitTemplateInclude(ILGenerator gen, StringTemplateAST args) { var name = gen.DeclareLocal(typeof(string)); var ldnull = gen.DefineLabel(); var endinclude = gen.DefineLabel(); gen.Emit(OpCodes.Dup); gen.Emit(OpCodes.Brfalse_S, endinclude); // the dup of a null object already loaded null back on the stack gen.Emit(OpCodes.Call, GetFuncMethodInfo <object, string>((o) => o.ToString())); // at this point, the name is the top item on the evaluation stack gen.Emit(OpCodes.Dup); gen.Emit(OpCodes.Brfalse_S, endinclude); gen.Emit(OpCodes.Stloc, name); // $value = chunk.GetTemplateInclude(self, name, args); EmitLoadChunk(gen); EmitLoadSelf(gen); gen.Emit(OpCodes.Ldloc, name); // TODO: handle args throw new System.NotImplementedException(); //gen.Emit( OpCodes.Callvirt, typeof( ASTExpr ).GetMethod( "GetTemplateInclude", new System.Type[] { typeof( StringTemplate ), typeof( string ), typeof( StringTemplateAST ) } ) ); //gen.MarkLabel( endinclude ); }
/** <summary> * Call a string template with args and return result. Do not convert * to a string yet. It may need attributes that will be available after * this is inserted into another template. * </summary> */ public virtual StringTemplate GetTemplateInclude( StringTemplate enclosing, string templateName, StringTemplateAST argumentsAST ) { //System.out.println("getTemplateInclude: look up "+enclosing.getGroup().getName()+"::"+templateName); StringTemplateGroup group = enclosing.Group; StringTemplate embedded = group.GetEmbeddedInstanceOf( enclosing, templateName ); if ( embedded == null ) { enclosing.Error( "cannot make embedded instance of " + templateName + " in template " + enclosing.Name ); return null; } embedded.ArgumentsAST = argumentsAST; EvaluateArguments( embedded ); return embedded; }
public StringTemplateAST(StringTemplateAST tree) : base(tree) { st = tree.st; }
public StringTemplateAST( StringTemplateAST tree ) : base(tree) { st = tree.st; }