-
Notifications
You must be signed in to change notification settings - Fork 116
fix #700 #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #700 #721
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1237,7 +1237,51 @@ private void NewInstance(int argCount) | |
| argValues[i] = BreakVariableLink(argValue); | ||
| } | ||
|
|
||
| var typeName = _operationStack.Pop().AsString(); | ||
| var varType = _operationStack.Pop(); | ||
| var typeName = varType.AsString(); | ||
|
|
||
| // "Type 2" ctor args unboxing subroutine | ||
| do | ||
| { | ||
| if (varType.DataType != DataType.Type && varType.DataType != DataType.String) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| if (argValues.Count() > 1) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| if (varType.DataType == DataType.Type) | ||
| { | ||
| var typeVariable = (TypeTypeValue)((Variable)varType).Value; | ||
| typeName = typeVariable.Value.Name; | ||
| } | ||
|
|
||
| if (argValues.Count() == 0) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| if ((argValues[0] is IEnumerable<IValue>) == false) | ||
| { | ||
| break; | ||
| } | ||
|
|
||
| IEnumerable<IValue> boxedArgs = argValues[0] as IEnumerable<IValue>; | ||
| int argsCount = boxedArgs.Count(); | ||
| IValue[] unboxedArgs = new IValue[argsCount]; | ||
| int i = 0; | ||
| foreach (IValue item in boxedArgs) | ||
| { | ||
| unboxedArgs[i++] = item; | ||
| } | ||
|
|
||
| argValues = unboxedArgs; | ||
|
|
||
| } while (false); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не совсем понятна магия с do.. while(false). Для чего нужен однопроходный цикл? |
||
|
|
||
| var clrType = TypeManager.GetFactoryFor(typeName); | ||
|
|
||
| var ctors = clrType.GetMethods(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,26 +43,33 @@ public StandartTypeManager() | |
| foreach (var item in Enum.GetValues(typeof(DataType))) | ||
| { | ||
| DataType typeEnum = (DataType)item; | ||
| string alias; | ||
| string alias = String.Empty; | ||
| string alterAlias = String.Empty; | ||
| switch (typeEnum) | ||
| { | ||
| case DataType.Undefined: | ||
| alias = "Неопределено"; | ||
| alterAlias = "Undefined"; | ||
| break; | ||
| case DataType.Boolean: | ||
| alias = "Булево"; | ||
| alterAlias = "Boolean"; | ||
| break; | ||
| case DataType.String: | ||
| alias = "Строка"; | ||
| alterAlias = "String"; | ||
| break; | ||
| case DataType.Date: | ||
| alias = "Дата"; | ||
| alterAlias = "Date"; | ||
| break; | ||
| case DataType.Number: | ||
| alias = "Число"; | ||
| alterAlias = "Number"; | ||
| break; | ||
| case DataType.Type: | ||
| alias = "Тип"; | ||
| alterAlias = "Type"; | ||
| break; | ||
| case DataType.Object: | ||
| alias = "Object"; | ||
|
|
@@ -74,6 +81,7 @@ public StandartTypeManager() | |
| var td = new TypeDescriptor() | ||
| { | ||
| Name = alias, | ||
| AlterName = alterAlias, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Поменять на термин "Alias" (см. выше) |
||
| ID = (int)typeEnum | ||
| }; | ||
|
|
||
|
|
@@ -142,6 +150,11 @@ public TypeDescriptor RegisterType(string name, Type implementingClass) | |
| private void RegisterType(TypeDescriptor td, Type implementingClass) | ||
| { | ||
| _knownTypesIndexes.Add(td.Name, td.ID); | ||
| if (td.AlterName != null && td.AlterName != String.Empty) | ||
| { | ||
| _knownTypesIndexes.Add(td.AlterName, td.ID); | ||
| } | ||
|
|
||
| _knownTypes.Add(new KnownType() | ||
| { | ||
| Descriptor = td, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Везде в программе используем для англ. синонима термин Alias. Предлагаю сделать единообразно и в этом случае.