@@ -29,10 +29,14 @@ function inferExpr(scope::Scope, expr::Expr)
2929 return binaryOp (scope, :-= , a, b)
3030 elseif @capture (expr, f_ (args__))
3131 return callExpr (scope, f, args)
32+ elseif @capture (expr, a_:: b_ )
33+ return declExpr (scope, a, b)
3234 elseif @capture (expr, a_[b_])
3335 return indexExpr (scope, a, b)
3436 elseif @capture (expr, a_. b_)
3537 return accessExpr (scope, a, b)
38+ elseif @capture (expr, a_{b__})
39+ return typeExpr (scope, a, b)
3640 elseif @capture (expr, for idx_ in range_ block__ end )
3741 return rangeBlock (scope, idx, range, block)
3842 elseif @capture (expr, if cond_ block__ end )
@@ -52,15 +56,37 @@ function inferExpr(scope::Scope, expr::Expr)
5256 end
5357end
5458
59+ function declExpr (scope, a:: Val{:hello} )
60+ @error " Not implemented yet"
61+ end
62+
63+ function declExpr (scope, a:: Symbol , b:: Symbol )
64+ aExpr = inferExpr (scope, a)
65+ inferScope! (scope, aExpr)
66+ bExpr = eval (b)
67+ return DeclExpr (aExpr, bExpr)
68+ end
69+
70+ function typeExpr (scope, a:: Symbol , b:: Vector{Any} )
71+ aExpr = inferExpr (scope, a)
72+ bExpr = map (x -> inferExpr (scope, x), b)
73+ return TypeExpr (aExpr, bExpr)
74+ end
75+
76+ function declExpr (scope, a:: Symbol , b:: Expr )
77+ bExpr = inferExpr (scope, b)
78+ aExpr = inferExpr (scope, a)
79+ return DeclExpr (aExpr, bExpr)
80+ end
81+
82+
5583function inferVariable (scope, expr:: Expr )
5684 if @capture (expr, a_:: b_{t__} )
5785 push! (scope. locals, a)
5886 return WGPUVariable (a, eval (b), Generic, nothing , ) # TODO t is ignored
5987 elseif @capture (expr, a_:: b_ )
6088 push! (scope. locals, a)
6189 return WGPUVariable (a, eval (b), Generic, nothing , )
62- elseif @capture (expr, a_[b_])
63- return indexExpr (scope, a, b)
6490 else
6591 error (" This expression $expr type is not captured yet" )
6692 end
0 commit comments