Created
May 27, 2011 14:03
-
-
Save bamboo/995311 to your computer and use it in GitHub Desktop.
Macro resolving a type argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Boo.Lang.Compiler | |
import Boo.Lang.Compiler.Ast | |
import Boo.Lang.Compiler.MetaProgramming // compile_ | |
import Boo.Lang.Compiler.TypeSystem | |
import Boo.Lang.Compiler.TypeSystem.Services | |
import Boo.Lang.Environments | |
struct Vector3: | |
x as single | |
y as single | |
z as single | |
macro swizzle(typeExpression as Expression): | |
def ResolveType(): | |
typeRef = TypeReference.Lift(typeExpression) | |
my(NameResolutionService).ResolveTypeReference(typeRef) | |
return typeRef.Entity cast IType | |
type = ResolveType() | |
for member in type.GetMembers(): | |
print member | |
code = [| | |
namespace Test | |
swizzle Vector3: | |
pass | |
|] | |
result = compile_(code, typeof(Vector3).Assembly) | |
print result.Errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment