Ejemplo n.º 1
0
 @Override
 public void parseSelf(MethodVisitorProxy mv, int local, VariableManager vm) {
   mv.visitTypeInsn(NEW, "java/util/HashMap");
   mv.visitInsn(DUP);
   mv.visitMethodInsn(INVOKESPECIAL, "java/util/HashMap", "<init>", "()V");
   for (Map.Entry<String, Expression> entry : value.entrySet()) {
     mv.visitInsn(DUP);
     mv.visitLdcInsn(entry.getKey());
     entry.getValue().parseObject(mv, local, vm);
     mv.visitMethodInsn(
         INVOKEVIRTUAL,
         "java/util/HashMap",
         "put",
         "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
     mv.visitInsn(POP);
   }
 }
Ejemplo n.º 2
0
 /**
  * 将函数对象放入语句栈中,提供给LineFunction与BlockFunction使用。
  *
  * @see com.ruixus.smarty4j.statement.LineFunction
  * @see com.ruixus.smarty4j.statement.BlockFunction
  * @param mv ASM方法操作者
  * @param local ASM语句栈的局部变量起始位置
  * @param index 函数在Template中保存的位置
  */
 protected String parseNode(MethodVisitorProxy mv, int local, int index) {
   String name = this.getClass().getName().replace('.', '/');
   mv.visitVarInsn(ALOAD, TEMPLATE);
   mv.visitLdcInsn(index);
   mv.visitMethodInsn(INVOKEVIRTUAL, Template.NAME, "getNode", "(I)Ljava/lang/Object;");
   mv.visitTypeInsn(CHECKCAST, name);
   return name;
 }