blob: ee9f64d0feb2f2929b58fd0fcb668190e47d7a8d [file] [log] [blame]
-------------------------------------------------------------------------------
-- Copyright (c) 2006-2013 Fabien Fleutot and others.
--
-- All rights reserved.
--
-- This program and the accompanying materials are made available
-- under the terms of the Eclipse Public License v1.0 which
-- accompanies this distribution, and is available at
-- http://www.eclipse.org/legal/epl-v10.html
--
-- This program and the accompanying materials are also made available
-- under the terms of the MIT public license which accompanies this
-- distribution, and is available at http://www.lua.org/license.html
--
-- Contributors:
-- Fabien Fleutot - API and implementation
--
-------------------------------------------------------------------------------
-{ block:
-{ extension 'log' }
-{ extension 'H' }
require 'metalua.dollar'
local H = H:new()
print("initial H.alpha", H.alpha)
function dollar.Q(cond, iftrue, iffalse)
local b = +{ block:
local v
if -{!cond} then v = -{!iftrue}
else v = -{!iffalse} end }
local r = `Stat{ b, +{v} }
H(r)
return r
end
$log(H)
return H.alpha }
x=1 ; y=$Q(x==1, 'one', 'two') ; print(y)
x=2 ; y=$Q(x==1, 'one', 'two') ; print(y)