程序支持如下類型:void, char, short, int, float, 指針。
關聯到表達式的操做數,就有:c#
public enum PrimitiveDataType { VoidType = 0x0001, CharType = 0x0002, ShortType = 0x0004, IntType = 0x0008, FloatType = 0x0010, SignedType = 0x0100, UnsignedType = 0x0200, ConstType = 0x1000, PointerType = 0x2000, StructureType = 0x4000, BaseTypeMask = 0x00FF, PointerMask = 0xDFFF };
public struct DataTypeInfo { public PrimitiveDataType Type; public int PointerCount; public PrimitiveDataType BaseType public bool IsPointer public bool IsUnsigned ...
public class Variable : Context { public DataTypeInfo TypeInfo; public int Address; public int PointerAddress; public int ReferenceCount = 0; ...
public class FunctionDefine : Context { private Stack<List<Expression.Operand.Value>> m_parameterStack; public DataTypeInfo ReturnType; public Expression.Operand.Operand ReturnValue; public bool IsVariableArgument; public int ReferenceCount; public int IteratorCount = 0; public List<Context> ArgumentDefinitions; public Block Body; ...
public class ExpressionNode { public Expression.ExpressionToken Token; public ExpressionNode LeftNode; public ExpressionNode RightNode; public override string ToString() { ... } public Operand.Operand Evaluate(Context ctx) { ... } public DataTypeInfo ResultType(Context ctx) { // 表達式結果類型推導 ... } // func ResultType }
類型系統粗就,下一節從運行過程來深刻了解SharpC。ide