コード例 #1
0
ファイル: Compiler.cs プロジェクト: christopherfowers/lslib
        private ValueType DetermineSignature(IRRule rule, IRValue value)
        {
            if (value is IRConstant)
            {
                return DetermineSignature(value as IRConstant);
            }
            else if (value is IRVariable)
            {
                if (value.Type != null)
                {
                    return value.Type;
                }

                var irVar = value as IRVariable;
                var ruleVar = rule.Variables[irVar.Index];
                if (ruleVar.Type != null)
                {
                    return ruleVar.Type;
                }
                else
                {
                    return null;
                }
            }
            else
            {
                throw new ArgumentException("Invalid IR value type");
            }
        }
コード例 #2
0
ファイル: Compiler.cs プロジェクト: christopherfowers/lslib
 private void VerifyIRValueCall(IRRule rule, IRValue value, FunctionSignature signature, Int32 parameterIndex, 
     Int32 conditionIndex, bool not)
 {
     if (value is IRVariable)
     {
         VerifyIRVariableCall(rule, value as IRVariable, signature, parameterIndex, conditionIndex, not);
     }
 }
コード例 #3
0
ファイル: Compiler.cs プロジェクト: christopherfowers/lslib
 private void VerifyIRValue(IRRule rule, IRValue value)
 {
     if (value is IRConstant)
     {
         VerifyIRConstant(value as IRConstant);
     }
     else
     {
         VerifyIRVariable(rule, value as IRVariable);
     }
 }
コード例 #4
0
 private void VerifyIRValue(IRRule rule, IRValue value, FunctionSignature func)
 {
     if (value is IRConstant)
     {
         VerifyIRConstant(value as IRConstant);
     }
     else
     {
         VerifyIRVariable(rule, value as IRVariable, func);
     }
 }
コード例 #5
0
ファイル: Compiler.cs プロジェクト: christopherfowers/lslib
        private void VerifyIRBinaryConditionValue(IRRule rule, IRValue value, Int32 conditionIndex)
        {
            VerifyIRValue(rule, value);

            if (value is IRVariable)
            {
                var variable = value as IRVariable;
                var ruleVar = rule.Variables[variable.Index];
                if (ruleVar.FirstBindingIndex == -1 || ruleVar.FirstBindingIndex >= conditionIndex)
                {
                    Context.Log.Error(variable.Location, 
                        DiagnosticCode.ParamNotBound,
                        "Variable {0} is not bound (when used in a binary expression)", 
                        ruleVar.Name);
                }
            }
        }
コード例 #6
0
ファイル: Compiler.cs プロジェクト: christopherfowers/lslib
        private void VerifyParamCompatibility(FunctionSignature func, int paramIndex, FunctionParam param, IRValue value)
        {
            if (param.Type.IntrinsicTypeId != value.Type.IntrinsicTypeId)
            {
                object paramName = (param.Name != null) ? (object)param.Name : paramIndex;
                Context.Log.Error(value.Location,
                    DiagnosticCode.LocalTypeMismatch,
                    "Parameter {0} of {1} \"{2}\" expects {3}; {4} specified",
                    paramName, func.Type, func.Name, TypeToName(param.Type.IntrinsicTypeId), TypeToName(value.Type.IntrinsicTypeId));
                return;
            }

            if (IsGuidAliasToAliasCast(param.Type, value.Type))
            {
                object paramName = (param.Name != null) ? (object)param.Name : paramIndex;
                Context.Log.Error(value.Location,
                    DiagnosticCode.GuidAliasMismatch,
                    "Parameter {0} of {1} \"{2}\" has GUID type {3}; {4} specified",
                    paramName, func.Type, func.Name, TypeToName(param.Type.TypeId), TypeToName(value.Type.TypeId));
                return;
            }
        }
コード例 #7
0
        private void VerifyParamCompatibility(FunctionSignature func, int paramIndex, FunctionParam param, IRValue value)
        {
            if (param.Type.IntrinsicTypeId != value.Type.IntrinsicTypeId)
            {
                // BG3 allows promoting integer constants to float
                if (Game == TargetGame.BG3 && value is IRConstant &&
                    (param.Type.IntrinsicTypeId == Value.Type.Float || param.Type.IntrinsicTypeId == Value.Type.Integer64) &&
                    value.Type.IntrinsicTypeId == Value.Type.Integer)
                {
                    return;
                }

                object paramName = (param.Name != null) ? (object)param.Name : paramIndex;
                Context.Log.Error(value.Location,
                                  DiagnosticCode.LocalTypeMismatch,
                                  "Parameter {0} of {1} \"{2}\" expects {3}; {4} specified",
                                  paramName, func.Type, func.Name, param.Type.Name, value.Type.Name);
                return;
            }

            if (IsGuidAliasToAliasCast(param.Type, value.Type))
            {
                object paramName = (param.Name != null) ? (object)param.Name : paramIndex;
                Context.Log.Error(value.Location,
                                  DiagnosticCode.GuidAliasMismatch,
                                  "Parameter {0} of {1} \"{2}\" has GUID type {3}; {4} specified",
                                  paramName, func.Type, func.Name, param.Type.Name, value.Type.Name);
                return;
            }
        }