public IEmitVal EmitAttributeRef( MidAttributeDecl decl, IEmitBlock block, EmitEnv env) { if (env.ContainsKey(decl)) { return(env.Lookup(decl, block)); } IEmitVal attributeVal = null; if (decl.Exp != null) { attributeVal = block.Temp( decl.Name.ToString(), EmitExp(decl.Exp, block, env)); } else { // \todo: This is a *huge* hack, // since we use @Constant attributes // to make various D3D constants visible... :( attributeVal = block.BuiltinApp( EmitType(decl.Type, env), decl.Name.ToString(), null); } env.Insert(decl, (b) => attributeVal); return(attributeVal); }
private IEmitVal EmitExpImpl( MidBuiltinApp app, IEmitBlock block, EmitEnv env) { var template = app.Decl.GetTemplate(Target.TargetName); if (template == null) { Diagnostics.Add( Severity.Error, new SourceRange(), "No builtin function implementation defined for \"{0}\" for target \"{1}\"", app.Decl.Name, Target.TargetName); return(block.Local("error", EmitType(app.Type, env))); } var args = (from a in app.Args select EmitExp(a, block, env)).ToArray(); return(block.BuiltinApp( EmitType(app.Type, env), template, args)); }