public override void ExplicitVisit(IntegerLiteral node) { var sys_int_name = this.GetSqlNameSys().ChildWellkown("int"); var t = new ModelSematicScalarType() { Name = sys_int_name, SystemDataType = ModelSystemDataType.Int }; var v = new ModelSematicValueScalar() { Type = t, Value = node.Value, IsConst = true }; node.Analyse.ResultType = new SqlCodeType(t); node.Analyse.ResultValue = new SqlCodeResultConst(v); /* * no need for base.ExplicitVisit(node); */ }
public override void ExplicitVisit(SqlDataTypeReference node) { var name = node.Name; var parameters = node.Parameters; SqlName typename = SqlName.From(node.Name); var sqlDataTypeOption = node.SqlDataTypeOption; short length = 0; bool isMax = false; byte precision = 0; byte scale = 0; string collationName = null; foreach (var parameter in parameters) { { if (parameter is MaxLiteral) { isMax = true; continue; } } { if (parameter is IntegerLiteral lengthLiteral) { short.TryParse(lengthLiteral.Value, out length); continue; } } // TODO: float(1,2) // TODO: collationName } if (sqlDataTypeOption != ModelSystemDataType.None) { // happyness var scalarType = new ModelSematicScalarType(); scalarType.Name = typename; scalarType.MaxLength = (isMax) ? ((short)-1) : length; scalarType.Precision = precision; scalarType.Scale = scale; scalarType.SystemDataType = sqlDataTypeOption; scalarType.CollationName = collationName; node.Analyse.ResultType = new SqlCodeType(scalarType); } else { if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Break(); } var resolved = this.scope.ResolveObject(typename, null); if (resolved != null) { if (resolved is ModelSematicType modelType) { node.Analyse.ResultType = new SqlCodeType(modelType); } } /* * var sqlName = SqlName.Parse(name.BaseIdentifier.Value, ObjectLevel.Object); * var sqlSysName = SqlName.Root.Child("sys", ObjectLevel.Schema).Child(sqlName.Name, ObjectLevel.Object); * var sqlCodeType = this.currentScopeRef.Current.ResolveObject(sqlSysName, null) as ISqlCodeType; * SetAnalyseSqlCodeType(node.Analyse, sqlCodeType); */ } }