public override ILType GetResultType(ILGenerationContext context)
 {
     ILType operandType = Operand.GetResultType(context);
     ILBaseType operandBaseType = operandType as ILBaseType;
     if (operandBaseType == null || !Types.IsIntegralType(operandBaseType.Type))
         throw new ParserException("Invalid operation on non-integral type.", TokenIndex, Token);
     return operandBaseType;
 }
 public override ILType GetResultType(ILGenerationContext context)
 {
     ILType operandType = Operand.GetResultType(context);
     ILPointerType pointerType = operandType as ILPointerType;
     if (pointerType == null)
         throw new ParserException("Unable to dereference non-pointer type.", TokenIndex, Token);
     return pointerType.InnerType.Type;
 }
 public override ILType GetResultType(ILGenerationContext context)
 {
     ILType operandType = Operand.GetResultType(context);
     switch (operandType.Category)
     {
         case ILTypeCategory.Base:
             return operandType;
         case ILTypeCategory.Struct:
             throw new ParserException("Invalid operation on struct type.", TokenIndex, Token);
         case ILTypeCategory.Pointer:
             return operandType;
         default:
             throw new InternalCompilerException("Unknown ILType category.");
     }
 }
        public override ILType GetResultType(ILGenerationContext context)
        {
            ILType leftType = Left.GetResultType(context);
            ILType rightType = Right.GetResultType(context);

            if (leftType.Category == ILTypeCategory.Struct || rightType.Category == ILTypeCategory.Struct)
                throw new ParserException("Invalid operation on struct type.", TokenIndex, Token);
            else if (leftType.Category == ILTypeCategory.Pointer && rightType.Category == ILTypeCategory.Pointer)
                throw new ParserException("Cannot perform operation on pointer type and pointer type.", TokenIndex, Token);
            else if (leftType.Category == ILTypeCategory.Pointer && rightType.Category == ILTypeCategory.Base)
                return leftType;
            else if (leftType.Category == ILTypeCategory.Base && rightType.Category == ILTypeCategory.Pointer)
                return rightType;
            else //Both types are base types
                return base.GetResultType(context);
        }
 public override ILType GetResultType(ILGenerationContext context)
 {
     ILType operandType = Operand.GetResultType(context);
     switch (operandType.Category)
     {
         case ILTypeCategory.Base:
             return operandType;
         case ILTypeCategory.Pointer:
             return operandType;
         case ILTypeCategory.Struct:
             throw new ParserException("Invalid operation on struct type.", TokenIndex, Token);
     }
     ILBaseType operandBaseType = operandType as ILBaseType;
     if (operandBaseType == null || !Types.IsIntegralType(operandBaseType.Type))
         throw new ParserException("Invalid operation on non-integral type.", TokenIndex, Token);
     return operandBaseType;
 }
        public override ILType GetResultType(ILGenerationContext context)
        {
            ILType leftType = Left.GetResultType(context);
            ILType rightType = Right.GetResultType(context);

            if (leftType.Category == ILTypeCategory.Struct || rightType.Category == ILTypeCategory.Struct)
            {
                throw new ParserException("Invalid operation on struct type.", TokenIndex, Token);
            }
            if (leftType.Category == ILTypeCategory.Pointer || rightType.Category == ILTypeCategory.Pointer) // Pointer Arithmetic Is Handled In BasicArithmeticBinaryOperatorNode
            {
                throw new ParserException("Invalid operation on pointer type.", TokenIndex, Token);
            }

            ILBaseType leftBaseType = (ILBaseType)leftType;
            ILBaseType rightBaseType = (ILBaseType)rightType;

            var promotedType = Promote(leftBaseType.Type, rightBaseType.Type);

            return new ILBaseType(promotedType);
        }
Пример #7
0
 protected override void GenerateILInternal(ILGenerationContext context)
 {
     context.Output.Write(new ILLoadF { Address = ILAddressingReference.CreateConstant(1.0), Size = FloatOperandSize.Size32 });
 }
 public override ILType GetResultType(ILGenerationContext context)
 {
     return new ILPointerType(new ILBaseType(Language.BaseType.Char));
 }
 public virtual bool IsLValue(ILGenerationContext context) { throw new NotImplementedException("Hit fallback IsLValue method."); }
Пример #10
0
 protected override void GenerateILInternal(ILGenerationContext context)
 {
     Value.GenerateIL(context);
 }
Пример #11
0
 public virtual ILAddressingReference GenerateLValue(ILGenerationContext context) { throw new NotImplementedException("Hit fallback GenerateLValue method."); }
Пример #12
0
 public override ILType GetResultType(ILGenerationContext context)
 {
     return new ILBaseType(BaseType.Char);
 }
Пример #13
0
 public override ILType GetResultType(ILGenerationContext context)
 {
     return Value.GetResultType(context);
 }
Пример #14
0
 public override ILType GetResultType(ILGenerationContext context)
 {
     return new ILBaseType(Language.BaseType.Int);
 }
Пример #15
0
 public override ILType GetResultType(ILGenerationContext context)
 {
     return context.ResolveTypeReference(Type).Type; //TODO: CHECK WHETHER IGNORING MODIFIERS HERE COULD CAUSE ISSUES
 }
Пример #16
0
 protected override void GenerateILInternal(ILGenerationContext context)
 {
     throw new NotImplementedException();
 }
Пример #17
0
 public abstract ILType GetResultType(ILGenerationContext context);
Пример #18
0
 public void RegisterVariable(ILGenerationContext context, string name, ILTypeReference type)
 {
     if (Variables.ContainsKey(name))
         throw new ParserException(string.Format("Duplicate definition for variable \"{0}\".", name), context.CurrentNode.TokenIndex, context.CurrentNode.Token);
 }
Пример #19
0
 public void RegisterStruct(ILGenerationContext context, ILStructType type)
 {
     if (Structs.ContainsKey(type.Name))
         throw new ParserException(string.Format("Duplicate definition for type struct \"{0}\".", type.Name), context.CurrentNode.TokenIndex, context.CurrentNode.Token);
     Structs.Add(type.Name, type);
 }
 public override ILType GetResultType(ILGenerationContext context)
 {
     ILType operandType = Operand.GetResultType(context);
     return new ILPointerType(operandType);
 }
Пример #21
0
 public virtual void GenerateIL(ILGenerationContext context)
 {
     context.CurrentNode = this;
     GenerateILInternal(context);
 }
Пример #22
0
 protected virtual void GenerateILInternal(ILGenerationContext context) //This should be made internal at some point
 {
     throw new NotImplementedException("Hit Node.cs fallback GenerateILInternal.");
 }
Пример #23
0
 public override ILType GetResultType(ILGenerationContext context)
 {
     throw new NotImplementedException();
 }
Пример #24
0
 protected override void GenerateILInternal(ILGenerationContext context)
 {
     context.Output.Write(new ILLoad { Address = ILAddressingReference.CreateConstant(Value), Size = (GeneralOperandSize)Types.GetBaseTypeSize(BaseType.Int) });
 }