Skip to content

Commit

Permalink
Fix broken build from a bad rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhardy committed Mar 13, 2013
1 parent d77c947 commit c1f30ef
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
Expand Up @@ -39,3 +39,4 @@
[assembly: SecurityTransparent]
[assembly: AllowPartiallyTrustedCallers]
[assembly: SecurityRules(SecurityRuleSet.Level1)]
#endif
Expand Up @@ -660,7 +660,7 @@ private static CustomAttributeBuilder MakeCab(ClrAttributeInfo attrib)
attributes = new List();
func.__dict__["clr_attributes__"] = attributes;
}
attributes.AddRange(attribs);
attributes.extend(attribs);
return func;
};
Expand Down
41 changes: 29 additions & 12 deletions Runtime/Microsoft.Dynamic/Runtime/SavableScriptCode.cs
Expand Up @@ -84,14 +84,22 @@ class CodeInfo {

// build the assembly & type gen that all the script codes will live in...
AssemblyGen ag = new AssemblyGen(new AssemblyName(name), dir, ext, /*emitSymbols*/false);
GenerateAssemblyCode(ag, codes);
ag.SaveAssembly();
}

public static void GenerateAssemblyCode(AssemblyGen ag, SavableScriptCode[] codes)
{
TypeBuilder tb = ag.DefinePublicType("DLRCachedCode", typeof(object), true);
TypeGen tg = new TypeGen(ag, tb);
// then compile all of the code

Dictionary<Type, List<CodeInfo>> langCtxBuilders = new Dictionary<Type, List<CodeInfo>>();
foreach (SavableScriptCode sc in codes) {
foreach (SavableScriptCode sc in codes)
{
List<CodeInfo> builders;
if (!langCtxBuilders.TryGetValue(sc.LanguageContext.GetType(), out builders)) {
if (!langCtxBuilders.TryGetValue(sc.LanguageContext.GetType(), out builders))
{
langCtxBuilders[sc.LanguageContext.GetType()] = builders = new List<CodeInfo>();
}

Expand All @@ -111,16 +119,19 @@ class CodeInfo {
var langsWithBuilders = langCtxBuilders.ToArray();

// lang ctx array
ilgen.EmitArray(typeof(Type), langsWithBuilders.Length, (index) => {
ilgen.EmitArray(typeof(Type), langsWithBuilders.Length, (index) =>
{
ilgen.Emit(OpCodes.Ldtoken, langsWithBuilders[index].Key);
ilgen.EmitCall(typeof(Type).GetMethod("GetTypeFromHandle", new[] { typeof(RuntimeTypeHandle) }));
});

// builders array of array
ilgen.EmitArray(typeof(Delegate[]), langsWithBuilders.Length, (index) => {
ilgen.EmitArray(typeof(Delegate[]), langsWithBuilders.Length, (index) =>
{
List<CodeInfo> builders = langsWithBuilders[index].Value;
ilgen.EmitArray(typeof(Delegate), builders.Count, (innerIndex) => {
ilgen.EmitArray(typeof(Delegate), builders.Count, (innerIndex) =>
{
ilgen.EmitNull();
ilgen.Emit(OpCodes.Ldftn, builders[innerIndex].Builder);
ilgen.EmitNew(
Expand All @@ -131,23 +142,30 @@ class CodeInfo {
});

// paths array of array
ilgen.EmitArray(typeof(string[]), langsWithBuilders.Length, (index) => {
ilgen.EmitArray(typeof(string[]), langsWithBuilders.Length, (index) =>
{
List<CodeInfo> builders = langsWithBuilders[index].Value;
ilgen.EmitArray(typeof(string), builders.Count, (innerIndex) => {
ilgen.EmitArray(typeof(string), builders.Count, (innerIndex) =>
{
ilgen.EmitString(builders[innerIndex].Code.SourceUnit.Path);
});
});

// 4th element in tuple - custom per-language data
ilgen.EmitArray(typeof(string[]), langsWithBuilders.Length, (index) => {
ilgen.EmitArray(typeof(string[]), langsWithBuilders.Length, (index) =>
{
List<CodeInfo> builders = langsWithBuilders[index].Value;
ilgen.EmitArray(typeof(string), builders.Count, (innerIndex) => {
ilgen.EmitArray(typeof(string), builders.Count, (innerIndex) =>
{
ICustomScriptCodeData data = builders[innerIndex].Code as ICustomScriptCodeData;
if (data != null) {
if (data != null)
{
ilgen.EmitString(data.GetCustomScriptCodeData());
} else {
}
else
{
ilgen.Emit(OpCodes.Ldnull);
}
});
Expand All @@ -165,7 +183,6 @@ class CodeInfo {
));

tg.FinishType();
ag.SaveAssembly();
}

/// <summary>
Expand Down
6 changes: 0 additions & 6 deletions Runtime/Microsoft.Scripting/Properties/AssemblyInfo.cs
Expand Up @@ -48,9 +48,6 @@
[assembly: SecurityTransparent]
[assembly: AllowPartiallyTrustedCallers]
[assembly: SecurityRules(SecurityRuleSet.Level1)]

#if !WIN8
[assembly: SecurityTransparent]
#endif

#if !SILVERLIGHT
Expand All @@ -59,6 +56,3 @@
[assembly: AssemblyInformationalVersion("1.1")]
#endif

#if !SILVERLIGHT && !WP75 && !WIN8
[assembly: AllowPartiallyTrustedCallers]
#endif

0 comments on commit c1f30ef

Please sign in to comment.