public FunctionTypeBuilder(ByteCodeChunk chunk) { this.chunk = chunk; this.startParameterIndex = (ushort)chunk.functionParamTypes.count; this.parameterCount = 0; this.returnType = new ValueType(TypeKind.Unit); }
public void Reset(Mode mode, ByteCodeChunk chunk) { this.mode = mode; this.chunk = chunk; errors.count = 0; stateFrameStack.count = 0; functionsStartIndex = 0; structTypesStartIndex = 0; }
public void StructSizeTests(string source, int expectedSize) { var c = new Compiler(); var chunk = new ByteCodeChunk(); var errors = c.CompileSource(chunk, null, TestHelper.CompilerMode, new Source(new Uri("source"), source)); Assert.Empty(errors.ToArray()); var type = new ValueType(TypeKind.Struct, chunk.structTypes.count - 1); var typeSize = type.GetSize(chunk); Assert.Equal(expectedSize, typeSize); }
public ValueType GetType(ByteCodeChunk chunk) { var classType = typeof(T); var builder = chunk.BeginClassType(); var result = builder.Build(classType.Name, classType, out var typeIndex); if (result == ClassTypeBuilder.Result.Success) { global::cflat.Marshal.SizeOf <Class <T> > .size = 1; return(new ValueType(TypeKind.NativeClass, typeIndex)); } throw new Marshal.InvalidReflectionException(); }
public void TupleDeclarationTest() { var chunk = new ByteCodeChunk(); var builder = chunk.BeginTupleType(); Assert.Equal(0, chunk.tupleTypes.count); Assert.Equal(0, chunk.tupleElementTypes.count); builder.WithElement(new ValueType(TypeKind.Int)); builder.WithElement(new ValueType(TypeKind.Int)); Assert.Equal(2, chunk.tupleElementTypes.count); var result = builder.Build(out var typeIndex); Assert.Equal(TupleTypeBuilder.Result.Success, result); var type = chunk.tupleTypes.buffer[typeIndex]; Assert.Equal(1, chunk.tupleTypes.count); Assert.Equal(2, chunk.tupleElementTypes.count); Assert.Equal(2, type.size); Assert.Equal(0, type.elements.index); Assert.Equal(2, type.elements.length); builder = chunk.BeginTupleType(); Assert.Equal(1, chunk.tupleTypes.count); Assert.Equal(2, chunk.tupleElementTypes.count); builder.WithElement(new ValueType(TypeKind.Int)); builder.WithElement(new ValueType(TypeKind.Int)); Assert.Equal(4, chunk.tupleElementTypes.count); result = builder.Build(out typeIndex); Assert.Equal(TupleTypeBuilder.Result.Success, result); type = chunk.tupleTypes.buffer[typeIndex]; Assert.Equal(1, chunk.tupleTypes.count); Assert.Equal(2, chunk.tupleElementTypes.count); Assert.Equal(2, type.size); Assert.Equal(0, type.elements.index); Assert.Equal(2, type.elements.length); }
internal void Load(ByteCodeChunk chunk) { this.chunk = chunk; error = Option.None; callFrameStack.count = 0; memory.Reset(); nativeObjects = new Buffer <object> { buffer = new object[chunk.stringLiterals.buffer.Length], count = chunk.stringLiterals.count }; for (var i = 0; i < nativeObjects.count; i++) { nativeObjects.buffer[i] = chunk.stringLiterals.buffer[i]; } debugData.Clear(); }
public ValueType GetType(ByteCodeChunk chunk) { return(new ValueType()); }
public static ClassTypeBuilder BeginClassType(this ByteCodeChunk self) { return(new ClassTypeBuilder(self)); }
public static StructTypeBuilder BeginStructType(this ByteCodeChunk self) { return(new StructTypeBuilder(self)); }
public FunctionDefinitionMarshaler(ByteCodeChunk chunk) { this.chunk = chunk; this.builder = chunk.BeginFunctionType(); this.builder.returnType = global::cflat.Marshal.TypeOf <R>(chunk); }
public ValueType GetType(ByteCodeChunk chunk) { global::cflat.Marshal.SizeOf <Int> .size = 1; return(new ValueType(TypeKind.Int)); }
public ValueType GetType(ByteCodeChunk chunk) { global::cflat.Marshal.SizeOf <MutRef <T> > .size = 1; return(global::cflat.Marshal.TypeOf <T>(chunk).ToReferenceType(true)); }
public StructDefinitionMarshaler(ByteCodeChunk chunk) { this.chunk = chunk; this.builder = chunk.BeginStructType(); }
public static void AddInstruction(this ByteCodeChunk chunk, Instruction instruction) { chunk.Add((byte)instruction); }
public static FunctionTypeBuilder BeginFunctionType(this ByteCodeChunk self) { return(new FunctionTypeBuilder(self)); }
public ValueType GetType(ByteCodeChunk chunk) { return(new StructDefinitionMarshaler <T>(chunk).GetDefinedType()); }
public void Reset() { chunk = new ByteCodeChunk(); compileErrors.count = 0; }
public static ValueType TypeOf <T>(ByteCodeChunk chunk) where T : struct, IMarshalable { return(default(T).GetType(chunk)); }
public static TupleTypeBuilder BeginTupleType(this ByteCodeChunk self) { return(new TupleTypeBuilder(self)); }
public ValueType GetType(ByteCodeChunk chunk) { global::cflat.Marshal.SizeOf <Array <T> > .size = 1; return(global::cflat.Marshal.TypeOf <T>(chunk).ToArrayType()); }
public static void AddInstruction(this ByteCodeChunk chunk, Instruction instruction, ulong value) { chunk.Add((byte)instruction); chunk.AddRange(BitConverter.GetBytes(value)); }
public TupleDefinitionMarshaler(ByteCodeChunk chunk) { this.chunk = chunk; this.builder = chunk.BeginTupleType(); }