コード例 #1
0
        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 );
        }
コード例 #2
0
ファイル: ASTExpr.cs プロジェクト: bszafko/antlrcs
 /** <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;
 }
コード例 #3
0
ファイル: StringTemplateAST.cs プロジェクト: ymf1/webgrease
 public StringTemplateAST(StringTemplateAST tree)
     : base(tree)
 {
     st = tree.st;
 }
コード例 #4
0
 public StringTemplateAST( StringTemplateAST tree )
     : base(tree)
 {
     st = tree.st;
 }