Esempio n. 1
0
 internal Builder([DisallowNull] ES_InterfaceData *data, ES_AccessModifier accessMod,
                  ES_FullyQualifiedName fullyQualifiedName, ArrayPointer <byte> sourceUnit
                  )
 {
     InterfaceData  = data;
     data->TypeInfo = new ES_TypeInfo(ES_TypeTag.Interface, accessMod, ES_TypeFlag.NoNew, sourceUnit, fullyQualifiedName);
 }
Esempio n. 2
0
    private void CreateFunctions_Function(
        ref TranslationUnitData transUnit, ES_NamespaceData.Builder namespaceBuilder,
        SymbolStack <FrontendSymbol> symbols, SourceData unitSrc,
        ES_TypeInfo *parentType, ES_AstFunctionDefinition funcDef
        )
    {
        Debug.Assert(Environment is not null);
        Debug.Assert(EnvironmentBuilder is not null);

        var sourceUnit = transUnit.Name;
        var idPool     = Environment.IdPool;

        // Get the namespace and function names.
        var funcName = Environment.IdPool.GetIdentifier(funcDef.Name.Text.Span);

        // Get the fully-qualified name.
        ES_FullyQualifiedName fullyQualifiedName;

        if (parentType == null)
        {
            var namespaceName = namespaceBuilder.NamespaceData.NamespaceName;
            fullyQualifiedName = new ES_FullyQualifiedName(namespaceName, funcName);
        }
        else
        {
            using var namespaceBytes = UnmanagedArray <byte> .GetArray(parentType->Name.NamespaceName.Length + 2 + parentType->Name.TypeName.Length);

            var span = namespaceBytes.Span;

            parentType->Name.NamespaceName.Span.CopyTo(span);
            span = span [parentType->Name.NamespaceName.Length..];
Esempio n. 3
0
    public ES_ArrayTypeData(ES_FullyQualifiedName fullyQualifiedName, [NotNull] ES_TypeInfo *elemType, int dims)
    {
        TypeInfo             = new (ES_TypeTag.Array, ES_AccessModifier.Public, ES_TypeFlag.None, ArrayPointer <byte> .Null, fullyQualifiedName);
        TypeInfo.RuntimeSize = sizeof(void *) + sizeof(int);

        elementType = elemType;
        dimCount    = dims;
    }
Esempio n. 4
0
    public ES_ConstData(
        ES_FullyQualifiedName fullyQualifiedName, ES_TypeInfo *innerType, bool immutable
        )
    {
        var tag = immutable ? ES_TypeTag.Immutable : ES_TypeTag.Const;

        TypeInfo = new ES_TypeInfo(tag, ES_AccessModifier.Public, ES_TypeFlag.None, ArrayPointer <byte> .Null, fullyQualifiedName);

        InnerType = innerType;
    }
Esempio n. 5
0
    private Pointer <ES_TypeInfo> GenerateBuiltinTypes_Float(ES_FloatSize size)
    {
        var floatDataPtr = EnvironmentBuilder !.MemoryManager.GetMemory <ES_FloatTypeData> ();
        var namePtr      = Environment !.IdPool.GetIdentifier(ES_PrimitiveTypes.GetFloatName(size));
        var fqn          = new ES_FullyQualifiedName(Environment.GlobalTypesNamespace, namePtr);

        *floatDataPtr = new ES_FloatTypeData(ES_AccessModifier.Public, ArrayPointer <byte> .Null, fqn, size);

        return(new Pointer <ES_TypeInfo> (&floatDataPtr->TypeInfo));
    }
Esempio n. 6
0
    public ES_FunctionPrototypeData(ES_AccessModifier accessMod,
                                    ES_TypeInfo *retType, ArrayPointer <ES_FunctionPrototypeArgData> argsList,
                                    ES_FullyQualifiedName fullyQualifiedName, ArrayPointer <byte> sourceUnit
                                    )
    {
        TypeInfo             = new (ES_TypeTag.Function, accessMod, ES_TypeFlag.NoNew, sourceUnit, fullyQualifiedName);
        TypeInfo.RuntimeSize = IntPtr.Size;

        returnType    = retType;
        argumentsList = argsList;
    }
Esempio n. 7
0
    private Pointer <ES_TypeInfo> GenerateBuiltinTypes_Simple(ReadOnlySpan <char> name, ES_TypeTag tag, int runtimeSize)
    {
        var voidDataPtr = EnvironmentBuilder !.MemoryManager.GetMemory <ES_TypeInfo> ();
        var namePtr     = Environment !.IdPool.GetIdentifier(name);
        var fqn         = new ES_FullyQualifiedName(Environment.GlobalTypesNamespace, namePtr);

        *voidDataPtr = new ES_TypeInfo(tag, ES_AccessModifier.Public, ES_TypeFlag.NoRefs | ES_TypeFlag.NoNew, ArrayPointer <byte> .Null, fqn);
        voidDataPtr->RuntimeSize = runtimeSize;

        return(new Pointer <ES_TypeInfo> (voidDataPtr));
    }
Esempio n. 8
0
 public ES_MemberData_Function(
     ES_MemberFlags flags, ES_FullyQualifiedName fqn,
     ES_AccessModifier accessMod, ArrayPointer <byte> srcUnit,
     ES_FunctionPrototypeData *funcType, ArrayPointer <ES_FunctionArgData> args, int optArgCount
     )
 {
     Info         = new ES_MemberData(accessMod, ES_MemberType.Field, flags, fqn.TypeName, srcUnit);
     FunctionData = new ES_FunctionData(
         fqn, accessMod, srcUnit,
         funcType, args, optArgCount
         );
 }
Esempio n. 9
0
    public ES_ReferenceData(
        ES_FullyQualifiedName fullyQualifiedName, ES_TypeInfo *pointedType
        )
    {
        TypeInfo = new (ES_TypeTag.Reference, ES_AccessModifier.Public, ES_TypeFlag.None, ArrayPointer <byte> .Null, fullyQualifiedName) {
            RuntimeSize = sizeof(void *)
        };

        PointedType = pointedType;
    }

    #endregion
}
Esempio n. 10
0
    public ES_FloatTypeData(
        ES_AccessModifier accessMod, ArrayPointer <byte> sourceUnit, ES_FullyQualifiedName fullyQualifiedName,
        ES_FloatSize size
        )
    {
        TypeInfo = new ES_TypeInfo(ES_TypeTag.Float, accessMod, ES_TypeFlag.NoRefs, sourceUnit, fullyQualifiedName);

        FloatSize = size;

        TypeInfo.RuntimeSize = size switch {
            ES_FloatSize.Single => 4,
            ES_FloatSize.Double => 8,

            _ => throw new NotImplementedException("Size not implemented."),
        };
    }
Esempio n. 11
0
    public ES_FunctionData(
        ES_FullyQualifiedName fqn, ES_AccessModifier accessMod, ArrayPointer <byte> sourceUnit,
        ES_FunctionPrototypeData *functionType, ArrayPointer <ES_FunctionArgData> args, int optArgCount
        )
    {
        Debug.Assert(functionType is not null);
        Debug.Assert(args.Length == functionType->ArgumentsList.Length);

        Name = fqn;

        AccessModifier = accessMod;
        SourceUnit     = sourceUnit;

        FunctionType      = functionType;
        Arguments         = args;
        OptionalArgsCount = optArgCount;
    }
Esempio n. 12
0
    public ES_TypeInfo(
        ES_TypeTag typeTag, ES_AccessModifier accessMod, ES_TypeFlag flags,
        ArrayPointer <byte> sourceUnit,
        ES_FullyQualifiedName fullyQualifiedName
        )
    {
        TypeTag     = typeTag;
        RuntimeSize = -1;

        AccessModifier = accessMod;
        Flags          = flags;

        Name       = fullyQualifiedName;
        SourceUnit = sourceUnit;

        RefsList    = ArrayPointer <nint> .Null;
        MembersList = new ES_TypeMembers();
    }
Esempio n. 13
0
    public ES_IntTypeData(
        ES_AccessModifier accessMod, ArrayPointer <byte> sourceUnit, ES_FullyQualifiedName fullyQualifiedName,
        ES_IntSize size, bool unsigned
        )
    {
        TypeInfo = new ES_TypeInfo(ES_TypeTag.Int, accessMod, ES_TypeFlag.NoRefs, sourceUnit, fullyQualifiedName);

        IntSize  = size;
        Unsigned = unsigned;

        TypeInfo.RuntimeSize = size switch {
            ES_IntSize.Int8 => 1,
            ES_IntSize.Int16 => 2,
            ES_IntSize.Int32 => 4,
            ES_IntSize.Int64 => 8,

            _ => throw new NotImplementedException("Size not implemented."),
        };
    }