/* * * Copyright (C) 1997, 1998 Yuuji ICHISUGI * * Permission to use, copy, modify and redistribution this software in * whole and in part, for evaluation or research purposes and without fee * is hereby granted provided this copyright notice. * See CopyrightAndLicensing.txt for licensing condition. */ /* BUG: if (c) SWAP(); else foo(); causes syntax error. */ #epp "Symbol" #epp "SystemMixin" #epp "AutoSplitFiles" #epp "BackQuote" package SWAP; import epp.*; SystemMixin SWAP { class Epp { extend void initInvokeStyleMacroTable() { original(); defineInvokeStyleMacro(:SWAP, new SWAPMacro()); } } } class SWAPMacro extends InvokeStyleMacro { public Tree call(Tree tree, Tree[] args){ Tree tmp = new Identifier(genTemp("_T")); return `(block (decl (modifiers) ,(args[0]) (vardecls (varInit ,tmp ,(args[1])))) (expressionStatement (= ,(args[1]) ,(args[2]))) (expressionStatement (= ,(args[2]) ,tmp))); } }