-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #272 from NoiseStudio/feature/271/replace-nesl-def…
…ault-by-compiled-shader Replace NESL default by compiled shader
- Loading branch information
Showing
57 changed files
with
656 additions
and
497 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
18 changes: 18 additions & 0 deletions
18
NoiseEngine/Nesl/CompilerTools/Generics/NotFullyConstructedGenericNeslField.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace NoiseEngine.Nesl.CompilerTools.Generics; | ||
|
||
internal sealed class NotFullyConstructedGenericNeslField : NeslField { | ||
|
||
private readonly NeslField genericMaked; | ||
|
||
public override IEnumerable<NeslAttribute> Attributes => genericMaked.Attributes; | ||
public override IReadOnlyList<byte>? DefaultData => genericMaked.DefaultData; | ||
|
||
public NotFullyConstructedGenericNeslField( | ||
NotFullyConstructedGenericNeslType parentType, NeslField genericMaked, NeslType fieldType | ||
) : base(parentType, genericMaked.Name, fieldType) { | ||
this.genericMaked = genericMaked; | ||
} | ||
|
||
} |
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
22 changes: 22 additions & 0 deletions
22
NoiseEngine/Nesl/CompilerTools/Generics/NotFullyConstructedGenericNeslMethodForType.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace NoiseEngine.Nesl.CompilerTools.Generics; | ||
|
||
internal sealed class NotFullyConstructedGenericNeslMethodForType : NeslMethod { | ||
|
||
public NeslMethod ParentMethod { get; } | ||
|
||
public override IEnumerable<NeslAttribute> Attributes => ParentMethod.Attributes; | ||
public override IEnumerable<NeslAttribute> ReturnValueAttributes => ParentMethod.ReturnValueAttributes; | ||
public override IReadOnlyList<IEnumerable<NeslAttribute>> ParameterAttributes => ParentMethod.ParameterAttributes; | ||
public override IEnumerable<NeslGenericTypeParameter> GenericTypeParameters => ParentMethod.GenericTypeParameters; | ||
protected override IlContainer IlContainer => ParentMethod.GetIlContainer(); | ||
|
||
public NotFullyConstructedGenericNeslMethodForType( | ||
NotFullyConstructedGenericNeslType type, NeslMethod parentMethod, NeslType? returnType, | ||
NeslType[] parameterTypes | ||
) : base(type, parentMethod.Name, returnType, parameterTypes) { | ||
ParentMethod = parentMethod; | ||
} | ||
|
||
} |
56 changes: 46 additions & 10 deletions
56
NoiseEngine/Nesl/CompilerTools/Generics/NotFullyConstructedGenericNeslType.cs
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,64 @@ | ||
using System; | ||
using NoiseEngine.Nesl.Serialization; | ||
using NoiseEngine.Serialization; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
|
||
namespace NoiseEngine.Nesl.CompilerTools.Generics; | ||
|
||
internal class NotFullyConstructedGenericNeslType : NeslType { | ||
internal sealed class NotFullyConstructedGenericNeslType : NeslType { | ||
|
||
public NeslType ParentType { get; } | ||
public ImmutableArray<NeslType> TypeArguments { get; } | ||
|
||
public override IEnumerable<NeslAttribute> Attributes => ParentType.Attributes; | ||
public override IEnumerable<NeslGenericTypeParameter> GenericTypeParameters => ParentType.GenericTypeParameters; | ||
public override IReadOnlyList<NeslField> Fields => ParentType.Fields; | ||
public override IEnumerable<NeslMethod> Methods => ParentType.Methods; | ||
public override IEnumerable<NeslAttribute> Attributes => GenericMakedFrom!.Attributes; | ||
public override IEnumerable<NeslGenericTypeParameter> GenericTypeParameters => | ||
GenericMakedFrom!.GenericTypeParameters; | ||
public override IReadOnlyList<NeslField> Fields { get; } | ||
public override IEnumerable<NeslMethod> Methods { get; } | ||
public override NeslType? GenericMakedFrom { get; } | ||
|
||
public NotFullyConstructedGenericNeslType(NeslType parentType, ImmutableArray<NeslType> typeArguments) : base( | ||
public NotFullyConstructedGenericNeslType( | ||
NeslType parentType, Dictionary<NeslGenericTypeParameter, NeslType> targetTypes, | ||
ImmutableArray<NeslType> typeArguments | ||
) : base( | ||
parentType.Assembly, parentType.FullName | ||
) { | ||
ParentType = parentType; | ||
GenericMakedFrom = parentType; | ||
TypeArguments = typeArguments; | ||
|
||
Fields = GenericMakedFrom.Fields.Select(field => new NotFullyConstructedGenericNeslField( | ||
this, field, GenericHelper.GetFinalType(GenericMakedFrom, this, field.FieldType, targetTypes) | ||
)).ToArray(); | ||
|
||
Methods = GenericMakedFrom.Methods.Select(method => new NotFullyConstructedGenericNeslMethodForType( | ||
this, method, | ||
method.ReturnType is null ? null : GenericHelper.GetFinalType( | ||
GenericMakedFrom, this, method.ReturnType, targetTypes | ||
), | ||
method.ParameterTypes.Select(x => GenericHelper.GetFinalType( | ||
GenericMakedFrom, this, x, targetTypes | ||
)).ToArray() | ||
)).ToArray(); | ||
} | ||
|
||
public override NeslType MakeGeneric(params NeslType[] typeArguments) { | ||
return ParentType.MakeGeneric(typeArguments); | ||
return GenericMakedFrom!.MakeGeneric(typeArguments); | ||
} | ||
|
||
internal override void PrepareHeader(SerializationUsed used, NeslAssembly serializedAssembly) { | ||
used.Add(this, GenericMakedFrom!); | ||
used.Add(this, TypeArguments); | ||
} | ||
|
||
internal override bool SerializeHeader(NeslAssembly serializedAssembly, SerializationWriter writer) { | ||
Debug.Assert(serializedAssembly == Assembly); | ||
|
||
writer.WriteBool(true); | ||
writer.WriteUInt8((byte)NeslTypeUsageKind.GenericNotFullyConstructed); | ||
writer.WriteUInt64(Assembly.GetLocalTypeId(GenericMakedFrom!)); | ||
writer.WriteEnumerable(TypeArguments.Select(Assembly.GetLocalTypeId)); | ||
return false; | ||
} | ||
|
||
} |
Oops, something went wrong.