This commit is contained in:
Zihan Chen
2017-06-24 01:12:10 -07:00
parent 38b95ec22a
commit d031334b83
8 changed files with 69 additions and 26 deletions
+4
View File
@@ -33540,6 +33540,7 @@ GuiTableComposition
void GuiTableComposition::SetRowOption(vint _row, GuiCellOption option) void GuiTableComposition::SetRowOption(vint _row, GuiCellOption option)
{ {
rowOptions[_row] = option; rowOptions[_row] = option;
UpdateCellBounds();
InvokeOnCompositionStateChanged(); InvokeOnCompositionStateChanged();
ConfigChanged.Execute(GuiEventArgs(this)); ConfigChanged.Execute(GuiEventArgs(this));
} }
@@ -33552,6 +33553,7 @@ GuiTableComposition
void GuiTableComposition::SetColumnOption(vint _column, GuiCellOption option) void GuiTableComposition::SetColumnOption(vint _column, GuiCellOption option)
{ {
columnOptions[_column] = option; columnOptions[_column] = option;
UpdateCellBounds();
InvokeOnCompositionStateChanged(); InvokeOnCompositionStateChanged();
ConfigChanged.Execute(GuiEventArgs(this)); ConfigChanged.Execute(GuiEventArgs(this));
} }
@@ -33565,6 +33567,7 @@ GuiTableComposition
{ {
if (value < 0) value = 0; if (value < 0) value = 0;
cellPadding = value; cellPadding = value;
UpdateCellBounds();
InvokeOnCompositionStateChanged(); InvokeOnCompositionStateChanged();
} }
@@ -43570,6 +43573,7 @@ GuiResource
} }
GuiResourcePrecompileContext context; GuiResourcePrecompileContext context;
context.compilerCallback = callback ? callback->GetCompilerCallback() : nullptr;
context.rootResource = this; context.rootResource = this;
context.resolver = new GuiResourcePathResolver(this, workingDirectory); context.resolver = new GuiResourcePathResolver(this, workingDirectory);
context.targetFolder = new GuiResourceFolder; context.targetFolder = new GuiResourceFolder;
+10 -2
View File
@@ -3256,6 +3256,11 @@ Interfaces:
namespace vl namespace vl
{ {
namespace workflow
{
class IWfCompilerCallback;
}
namespace presentation namespace presentation
{ {
using namespace reflection; using namespace reflection;
@@ -3782,12 +3787,14 @@ Resource Type Resolver
{ {
typedef collections::Dictionary<Ptr<DescriptableObject>, Ptr<DescriptableObject>> PropertyMap; typedef collections::Dictionary<Ptr<DescriptableObject>, Ptr<DescriptableObject>> PropertyMap;
/// <summary>Progress callback.</summary>
workflow::IWfCompilerCallback* compilerCallback = nullptr;
/// <summary>The folder to contain compiled objects.</summary> /// <summary>The folder to contain compiled objects.</summary>
Ptr<GuiResourceFolder> targetFolder; Ptr<GuiResourceFolder> targetFolder;
/// <summary>The root resource object.</summary> /// <summary>The root resource object.</summary>
GuiResource* rootResource; GuiResource* rootResource = nullptr;
/// <summary>Indicate the pass index of this precompiling pass.</summary> /// <summary>Indicate the pass index of this precompiling pass.</summary>
vint passIndex; vint passIndex = -1;
/// <summary>The path resolver. This is only for delay load resource.</summary> /// <summary>The path resolver. This is only for delay load resource.</summary>
Ptr<GuiResourcePathResolver> resolver; Ptr<GuiResourcePathResolver> resolver;
/// <summary>Additional properties for resource item contents</summary> /// <summary>Additional properties for resource item contents</summary>
@@ -3857,6 +3864,7 @@ Resource Type Resolver
class IGuiResourcePrecompileCallback : public virtual IDescriptable, public Description<IGuiResourcePrecompileCallback> class IGuiResourcePrecompileCallback : public virtual IDescriptable, public Description<IGuiResourcePrecompileCallback>
{ {
public: public:
virtual workflow::IWfCompilerCallback* GetCompilerCallback() = 0;
virtual void OnPerPass(vint passIndex) = 0; virtual void OnPerPass(vint passIndex) = 0;
virtual void OnPerResource(vint passIndex, Ptr<GuiResourceItem> resource) = 0; virtual void OnPerResource(vint passIndex, Ptr<GuiResourceItem> resource) = 0;
}; };
+16 -16
View File
@@ -2273,7 +2273,7 @@ namespace vl
} }
} }
void Workflow_GenerateAssembly(GuiResourcePrecompileContext& context, const WString& path, GuiResourceError::List& errors, bool keepMetadata) void Workflow_GenerateAssembly(GuiResourcePrecompileContext& context, const WString& path, GuiResourceError::List& errors, bool keepMetadata, IWfCompilerCallback* compilerCallback)
{ {
auto compiled = Workflow_GetModule(context, path); auto compiled = Workflow_GetModule(context, path);
if (!compiled) if (!compiled)
@@ -2310,12 +2310,12 @@ namespace vl
if (manager->errors.Count() == 0) if (manager->errors.Count() == 0)
{ {
manager->Rebuild(true); manager->Rebuild(true, compilerCallback);
} }
if (manager->errors.Count() == 0) if (manager->errors.Count() == 0)
{ {
compiled->assembly = GenerateAssembly(manager); compiled->assembly = GenerateAssembly(manager, compilerCallback);
compiled->Initialize(true); compiled->Initialize(true);
} }
else else
@@ -2431,7 +2431,7 @@ Shared Script Type Resolver (Script)
switch (context.passIndex) switch (context.passIndex)
{ {
case Workflow_Compile: case Workflow_Compile:
Workflow_GenerateAssembly(context, Path_Shared, errors, false); Workflow_GenerateAssembly(context, Path_Shared, errors, false, context.compilerCallback);
break; break;
} }
} }
@@ -2577,7 +2577,7 @@ Instance Type Resolver (Instance)
types::ResolvingResult resolvingResult; types::ResolvingResult resolvingResult;
resolvingResult.resource = resource; resolvingResult.resource = resource;
resolvingResult.context = obj; resolvingResult.context = obj;
if (auto module = Workflow_GenerateInstanceClass(context, resolvingResult, errors, context.passIndex)) if (auto module = Workflow_GenerateInstanceClass(context, L"<instance>" + obj->className, resolvingResult, errors, context.passIndex))
{ {
Workflow_AddModule(context, Path_TemporaryClass, module, GuiInstanceCompiledWorkflow::TemporaryClass, obj->tagPosition); Workflow_AddModule(context, Path_TemporaryClass, module, GuiInstanceCompiledWorkflow::TemporaryClass, obj->tagPosition);
} }
@@ -2609,9 +2609,9 @@ Instance Type Resolver (Instance)
if (errors.Count() == previousErrorCount) if (errors.Count() == previousErrorCount)
{ {
if (auto ctorModule = Workflow_PrecompileInstanceContext(context, resolvingResult, errors)) if (auto ctorModule = Workflow_PrecompileInstanceContext(context, L"<constructor>" + obj->className, resolvingResult, errors))
{ {
if (auto instanceModule = Workflow_GenerateInstanceClass(context, resolvingResult, errors, context.passIndex)) if (auto instanceModule = Workflow_GenerateInstanceClass(context, L"<instance>" + obj->className, resolvingResult, errors, context.passIndex))
{ {
Workflow_AddModule(context, Path_InstanceClass, ctorModule, GuiInstanceCompiledWorkflow::InstanceClass, obj->tagPosition); Workflow_AddModule(context, Path_InstanceClass, ctorModule, GuiInstanceCompiledWorkflow::InstanceClass, obj->tagPosition);
Workflow_AddModule(context, Path_InstanceClass, instanceModule, GuiInstanceCompiledWorkflow::InstanceClass, obj->tagPosition); Workflow_AddModule(context, Path_InstanceClass, instanceModule, GuiInstanceCompiledWorkflow::InstanceClass, obj->tagPosition);
@@ -2663,14 +2663,14 @@ Instance Type Resolver (Instance)
switch (context.passIndex) switch (context.passIndex)
{ {
case Instance_CompileInstanceTypes: case Instance_CompileInstanceTypes:
Workflow_GenerateAssembly(context, path, errors, false); Workflow_GenerateAssembly(context, path, errors, false, context.compilerCallback);
compiled->modules.Clear(); compiled->modules.Clear();
break; break;
case Instance_CompileEventHandlers: case Instance_CompileEventHandlers:
Workflow_GenerateAssembly(context, path, errors, false); Workflow_GenerateAssembly(context, path, errors, false, context.compilerCallback);
break; break;
case Instance_CompileInstanceClass: case Instance_CompileInstanceClass:
Workflow_GenerateAssembly(context, path, errors, true); Workflow_GenerateAssembly(context, path, errors, true, context.compilerCallback);
break; break;
default:; default:;
} }
@@ -6639,9 +6639,9 @@ FindInstanceLoadingSource
Workflow_PrecompileInstanceContext Workflow_PrecompileInstanceContext
***********************************************************************/ ***********************************************************************/
Ptr<workflow::WfModule> Workflow_PrecompileInstanceContext(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors) Ptr<workflow::WfModule> Workflow_PrecompileInstanceContext(GuiResourcePrecompileContext& precompileContext, const WString& moduleName, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors)
{ {
auto module = Workflow_CreateModuleWithUsings(resolvingResult.context); auto module = Workflow_CreateModuleWithUsings(resolvingResult.context, moduleName);
{ {
auto block = Workflow_InstallCtorClass(resolvingResult, module); auto block = Workflow_InstallCtorClass(resolvingResult, module);
Workflow_GenerateCreating(precompileContext, resolvingResult, block, errors); Workflow_GenerateCreating(precompileContext, resolvingResult, block, errors);
@@ -6922,7 +6922,7 @@ Workflow_GenerateInstanceClass
} }
}; };
Ptr<workflow::WfModule> Workflow_GenerateInstanceClass(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors, vint passIndex) Ptr<workflow::WfModule> Workflow_GenerateInstanceClass(GuiResourcePrecompileContext& precompileContext, const WString& moduleName, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors, vint passIndex)
{ {
bool beforePrecompile = false; bool beforePrecompile = false;
bool needEventHandler = false; bool needEventHandler = false;
@@ -6961,7 +6961,7 @@ Workflow_GenerateInstanceClass
// Instance Class // Instance Class
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////
auto module = Workflow_CreateModuleWithUsings(context); auto module = Workflow_CreateModuleWithUsings(context, moduleName);
auto instanceClass = Workflow_InstallClass(context->className, module); auto instanceClass = Workflow_InstallClass(context->className, module);
{ {
auto typeInfo = MakePtr<TypeDescriptorTypeInfo>(baseType->GetTypeDescriptor(), TypeInfoHint::Normal); auto typeInfo = MakePtr<TypeDescriptorTypeInfo>(baseType->GetTypeDescriptor(), TypeInfoHint::Normal);
@@ -9302,10 +9302,10 @@ namespace vl
Workflow_CreateModuleWithUsings Workflow_CreateModuleWithUsings
***********************************************************************/ ***********************************************************************/
Ptr<workflow::WfModule> Workflow_CreateModuleWithUsings(Ptr<GuiInstanceContext> context) Ptr<workflow::WfModule> Workflow_CreateModuleWithUsings(Ptr<GuiInstanceContext> context, const WString& moduleName)
{ {
auto module = MakePtr<WfModule>(); auto module = MakePtr<WfModule>();
module->name.value = L"<auto-generated>"; module->name.value = moduleName;
vint index = context->namespaces.Keys().IndexOf(GlobalStringKey()); vint index = context->namespaces.Keys().IndexOf(GlobalStringKey());
if (index != -1) if (index != -1)
+3 -3
View File
@@ -799,7 +799,7 @@ WorkflowCompiler (Installation)
WorkflowCompiler (Compile) WorkflowCompiler (Compile)
***********************************************************************/ ***********************************************************************/
extern Ptr<workflow::WfModule> Workflow_CreateModuleWithUsings(Ptr<GuiInstanceContext> context); extern Ptr<workflow::WfModule> Workflow_CreateModuleWithUsings(Ptr<GuiInstanceContext> context, const WString& moduleName);
extern Ptr<workflow::WfClassDeclaration> Workflow_InstallClass(const WString& className, Ptr<workflow::WfModule> module); extern Ptr<workflow::WfClassDeclaration> Workflow_InstallClass(const WString& className, Ptr<workflow::WfModule> module);
extern Ptr<workflow::WfBlockStatement> Workflow_InstallCtorClass(types::ResolvingResult& resolvingResult, Ptr<workflow::WfModule> module); extern Ptr<workflow::WfBlockStatement> Workflow_InstallCtorClass(types::ResolvingResult& resolvingResult, Ptr<workflow::WfModule> module);
@@ -844,8 +844,8 @@ WorkflowCompiler (Compile)
extern InstanceLoadingSource FindInstanceLoadingSource(Ptr<GuiInstanceContext> context, GlobalStringKey namespaceName, const WString& typeName); extern InstanceLoadingSource FindInstanceLoadingSource(Ptr<GuiInstanceContext> context, GlobalStringKey namespaceName, const WString& typeName);
extern InstanceLoadingSource FindInstanceLoadingSource(Ptr<GuiInstanceContext> context, GuiConstructorRepr* ctor); extern InstanceLoadingSource FindInstanceLoadingSource(Ptr<GuiInstanceContext> context, GuiConstructorRepr* ctor);
extern Ptr<workflow::WfModule> Workflow_PrecompileInstanceContext(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors); extern Ptr<workflow::WfModule> Workflow_PrecompileInstanceContext(GuiResourcePrecompileContext& precompileContext, const WString& moduleName, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors);
extern Ptr<workflow::WfModule> Workflow_GenerateInstanceClass(GuiResourcePrecompileContext& precompileContext, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors, vint passIndex); extern Ptr<workflow::WfModule> Workflow_GenerateInstanceClass(GuiResourcePrecompileContext& precompileContext, const WString& moduleName, types::ResolvingResult& resolvingResult, GuiResourceError::List& errors, vint passIndex);
#define WORKFLOW_ENVIRONMENT_VARIABLE_ADD\ #define WORKFLOW_ENVIRONMENT_VARIABLE_ADD\
FOREACH_INDEXER(GlobalStringKey, envVar, index, repr->environmentVariables.Keys())\ FOREACH_INDEXER(GlobalStringKey, envVar, index, repr->environmentVariables.Keys())\
+15 -2
View File
@@ -463,8 +463,11 @@ WfLexicalScopeManager
baseConstructorCallResolvings.Clear(); baseConstructorCallResolvings.Clear();
} }
void WfLexicalScopeManager::Rebuild(bool keepTypeDescriptorNames) #define CALLBACK(EXPR) if (callback) callback->EXPR
void WfLexicalScopeManager::Rebuild(bool keepTypeDescriptorNames, IWfCompilerCallback* callback)
{ {
CALLBACK(OnLoadEnvironment());
Clear(keepTypeDescriptorNames, false); Clear(keepTypeDescriptorNames, false);
if (!globalName) if (!globalName)
{ {
@@ -472,6 +475,7 @@ WfLexicalScopeManager
BuildGlobalNameFromTypeDescriptors(this); BuildGlobalNameFromTypeDescriptors(this);
} }
CALLBACK(OnInitialize(this));
vint errorCount = errors.Count(); vint errorCount = errors.Count();
#define EXIT_IF_ERRORS_EXIST\ #define EXIT_IF_ERRORS_EXIST\
@@ -507,12 +511,15 @@ WfLexicalScopeManager
EXIT_IF_ERRORS_EXIST; EXIT_IF_ERRORS_EXIST;
FOREACH(Ptr<WfModule>, module, modules) FOREACH(Ptr<WfModule>, module, modules)
{ {
CALLBACK(OnValidateModule(module));
ValidateModuleSemantic(this, module); ValidateModuleSemantic(this, module);
} }
#undef EXIT_IF_ERRORS_EXIST #undef EXIT_IF_ERRORS_EXIST
} }
#undef CALLBACK
bool WfLexicalScopeManager::ResolveMember(ITypeDescriptor* typeDescriptor, const WString& name, bool preferStatic, collections::SortedList<ITypeDescriptor*>& searchedTypes, collections::List<ResolveExpressionResult>& results) bool WfLexicalScopeManager::ResolveMember(ITypeDescriptor* typeDescriptor, const WString& name, bool preferStatic, collections::SortedList<ITypeDescriptor*>& searchedTypes, collections::List<ResolveExpressionResult>& results)
{ {
if (searchedTypes.Contains(typeDescriptor)) if (searchedTypes.Contains(typeDescriptor))
@@ -20661,8 +20668,11 @@ GenerateTypeCastInstructions
GenerateAssembly GenerateAssembly
***********************************************************************/ ***********************************************************************/
Ptr<runtime::WfAssembly> GenerateAssembly(analyzer::WfLexicalScopeManager* manager) #define CALLBACK(EXPR) if (callback) callback->EXPR
Ptr<runtime::WfAssembly> GenerateAssembly(analyzer::WfLexicalScopeManager* manager, IWfCompilerCallback* callback)
{ {
CALLBACK(OnGenerateMetadata());
auto assembly = MakePtr<WfAssembly>(); auto assembly = MakePtr<WfAssembly>();
assembly->insBeforeCodegen = new WfInstructionDebugInfo; assembly->insBeforeCodegen = new WfInstructionDebugInfo;
assembly->insAfterCodegen = new WfInstructionDebugInfo; assembly->insAfterCodegen = new WfInstructionDebugInfo;
@@ -20757,16 +20767,19 @@ GenerateAssembly
FOREACH(Ptr<WfModule>, module, manager->GetModules()) FOREACH(Ptr<WfModule>, module, manager->GetModules())
{ {
CALLBACK(OnGenerateCode(module));
FOREACH(Ptr<WfDeclaration>, decl, module->declarations) FOREACH(Ptr<WfDeclaration>, decl, module->declarations)
{ {
GenerateDeclarationInstructions(context, decl); GenerateDeclarationInstructions(context, decl);
} }
} }
CALLBACK(OnGenerateDebugInfo());
assembly->Initialize(); assembly->Initialize();
return assembly; return assembly;
} }
#undef CALLBACK
#undef INSTRUCTION #undef INSTRUCTION
/*********************************************************************** /***********************************************************************
+21 -3
View File
@@ -3296,12 +3296,30 @@ namespace vl
{ {
namespace analyzer namespace analyzer
{ {
class WfLexicalSymbol; class WfLexicalSymbol;
class WfLexicalScope; class WfLexicalScope;
class WfLexicalScopeManager; class WfLexicalScopeManager;
}
/*********************************************************************** /***********************************************************************
Callback
***********************************************************************/
class IWfCompilerCallback : public Interface
{
public:
virtual void OnLoadEnvironment() = 0;
virtual void OnInitialize(analyzer::WfLexicalScopeManager* manager) = 0;
virtual void OnValidateModule(Ptr<WfModule> module) = 0;
virtual void OnGenerateMetadata() = 0;
virtual void OnGenerateCode(Ptr<WfModule> module) = 0;
virtual void OnGenerateDebugInfo() = 0;
};
namespace analyzer
{
/***********************************************************************
Scope Scope
***********************************************************************/ ***********************************************************************/
@@ -3492,7 +3510,7 @@ Scope Manager
void Clear(bool keepTypeDescriptorNames, bool deleteModules); void Clear(bool keepTypeDescriptorNames, bool deleteModules);
/// <summary>Compile.</summary> /// <summary>Compile.</summary>
/// <param name="keepTypeDescriptorNames">Set to false to delete all cache of reflectable C++ types before compiling.</param> /// <param name="keepTypeDescriptorNames">Set to false to delete all cache of reflectable C++ types before compiling.</param>
void Rebuild(bool keepTypeDescriptorNames); void Rebuild(bool keepTypeDescriptorNames, IWfCompilerCallback* callback = nullptr);
bool ResolveMember(ITypeDescriptor* typeDescriptor, const WString& name, bool preferStatic, collections::SortedList<ITypeDescriptor*>& searchedTypes, collections::List<ResolveExpressionResult>& results); bool ResolveMember(ITypeDescriptor* typeDescriptor, const WString& name, bool preferStatic, collections::SortedList<ITypeDescriptor*>& searchedTypes, collections::List<ResolveExpressionResult>& results);
bool ResolveName(WfLexicalScope* scope, const WString& name, collections::List<ResolveExpressionResult>& results); bool ResolveName(WfLexicalScope* scope, const WString& name, collections::List<ResolveExpressionResult>& results);
@@ -3955,7 +3973,7 @@ Code Generation
/// <summary>Generate an assembly from a compiler. [M:vl.workflow.analyzer.WfLexicalScopeManager.Rebuild] should be called before using this function.</summary> /// <summary>Generate an assembly from a compiler. [M:vl.workflow.analyzer.WfLexicalScopeManager.Rebuild] should be called before using this function.</summary>
/// <returns>The generated assembly.</returns> /// <returns>The generated assembly.</returns>
/// <param name="manager">The Workflow compiler.</param> /// <param name="manager">The Workflow compiler.</param>
extern Ptr<runtime::WfAssembly> GenerateAssembly(analyzer::WfLexicalScopeManager* manager); extern Ptr<runtime::WfAssembly> GenerateAssembly(analyzer::WfLexicalScopeManager* manager, IWfCompilerCallback* callback = nullptr);
/// <summary>Compile a Workflow program.</summary> /// <summary>Compile a Workflow program.</summary>
/// <returns>The generated assembly.</returns> /// <returns>The generated assembly.</returns>
BIN
View File
Binary file not shown.
Binary file not shown.