public void Process(CodeModel codeModel) { foreach (ModelMethod method in codeModel.Methods.WhereTagsContains(LeafMethodTag)) { method.CallsMethods.Clear(); } }
public static List<CodeClass> GetCodeClasses(CodeModel codeModel) { List<CodeClass> lstCodeClasses = new List<CodeClass>(); foreach (CodeElement tvCodeElementOutter in codeModel.CodeElements) { if (tvCodeElementOutter is CodeNamespace) { try { foreach (CodeElement tvCodeElement in ((CodeNamespace)tvCodeElementOutter).Members) { if (tvCodeElement != null && tvCodeElement is CodeClass) { lstCodeClasses.Add((CodeClass)tvCodeElement); } } } catch (Exception ex) { //ignore Logger.LogException(ex); } } } return lstCodeClasses; }
//private static IMappingEngine MappingEngine //{ // get // { // var containerProvider = DependencyResolver.Current as IContainerProvider; // if (containerProvider != null) // { // return containerProvider.GetService<IMappingEngine>(); // } // return null; // } //} /// <summary> /// Converts the current instance of <see cref="RelatedCodeModel" /> to a <see cref="CodeModel" />. /// </summary> /// <returns>The current instance of <see cref="RelatedCodeModel" /> as a <see cref="CodeModel" />.</returns> public static CodeModel ToCodeModel(this RelatedCodeModel model) { var codeModel = new CodeModel(); codeModel.Code = (model.Dominant ? model.SubordinateCode : model.DominantCode); codeModel.Description = (model.Dominant ? model.SubordinateDescription : model.DominantDescription); codeModel.ShortDescription = (model.Dominant ? model.SubordinateShortDescription : model.DominantShortDescription); return(codeModel); }
public static CodeModel RunExtensions(Trigger trigger, CodeModel codeModel) { /* * foreach (var extension in extensions.Where(each => each.trigger == trugger).SortBy(each => each.Priority)) * codeModel = extension.Transform(codeModel); */ return(codeModel); }
public CodeModel DeleteProgram(CodeModel model) { using (IDbConnection cnn = new SQLiteConnection(GlobalConfig.CnnString(GlobalConfig.db))) { cnn.Execute("Delete from Code where Id = @Id ", model); return(model); } }
public async Task <ActionResult> Post([FromBody] CodeModel code) { code.reg_user = int.Parse(User.Identity.Name); code.reg_dt = DateTime.Now; code.upd_dt = DateTime.Now; await _code.Add(code); return(Ok()); }
public void AddCode(CodeModel code) { if (code == null) { throw new ArgumentNullException(nameof(code)); } _context.Code.Add(code); }
public CodeFile(CodeModel model) : base(new Scope(model)) { if (model == null) { throw new ArgumentNullException("model"); } _model = model; }
/// <summary> /// A type-specific method for code model tranformation. /// Note: This is the method you want to override. /// </summary> /// <param name="codeModel"></param> /// <returns></returns> public override CodeModelJv TransformCodeModel(CodeModel cm) { var codeModel = cm as CodeModelJva; // we're guaranteed to be in our language-specific context here. Settings.Instance.AddCredentials = true; // This extension from general extensions must be run prior to Azure specific extensions. AzureExtensions.ProcessParameterizedHost(codeModel); AzureExtensions.ProcessClientRequestIdExtension(codeModel); AzureExtensions.UpdateHeadMethods(codeModel); AzureExtensions.ProcessGlobalParameters(codeModel); AzureExtensions.FlattenModels(codeModel); AzureExtensions.FlattenMethodParameters(codeModel); ParameterGroupExtensionHelper.AddParameterGroups(codeModel); AddLongRunningOperations(codeModel); AzureExtensions.AddAzureProperties(codeModel); AzureExtensions.SetDefaultResponses(codeModel); // set Parent on responses (required for pageable) foreach (MethodJva method in codeModel.Methods) { foreach (ResponseJva response in method.Responses.Values) { response.Parent = method; } (method.DefaultResponse as ResponseJva).Parent = method; method.ReturnTypeJva.Parent = method; } AzureExtensions.AddPageableMethod(codeModel); // pluralize method groups foreach (var mg in codeModel.Operations) { mg.Name.OnGet += name => name.IsNullOrEmpty() || name.EndsWith("s", StringComparison.OrdinalIgnoreCase) ? name : $"{name}s"; } NormalizePaginatedMethods(codeModel, codeModel.pageClasses); // param order (PATH first) foreach (MethodJva method in codeModel.Methods) { var ps = method.Parameters.ToList(); method.ClearParameters(); foreach (var p in ps.Where(x => x.Location == ParameterLocation.Path)) { method.Add(p); } foreach (var p in ps.Where(x => x.Location != ParameterLocation.Path)) { method.Add(p); } } return(codeModel); }
public void ShortDescriptionTest() { var target = new CodeModel(); const string expected = "ShortDesc"; target.ShortDescription = expected; string actual = target.ShortDescription; Assert.AreEqual(expected, actual); }
public void CodeTest() { var target = new CodeModel(); const string expected = "Test"; target.Code = expected; string actual = target.Code; Assert.AreEqual(expected, actual); }
private static SyntaxNodeOrToken WithParameter( KeyValuePair <string, Argument> argumentDefinition) { var argumentName = argumentDefinition.Key.ToFieldArgumentName(); var argument = argumentDefinition.Value; var typeName = CodeModel.SelectTypeName(argument.Type); return(Parameter(Identifier(argumentName)) .WithType(ParseTypeName(typeName))); }
public void CodePoint_ToString() { ICodeModel codeModel = new CodeModel(); var activity = MessageFactory.Text("hi"); var context = new TurnContext(new TestAdapter(), activity); var dc = new DialogContext(new DialogSet(), context, new DialogState()); ICodePoint codePoint = new CodePoint(codeModel, dc, "test-item", "more"); Assert.Equal(codePoint.ToString(), codePoint.Name); }
public static CodeModel DeactivateCode(CodeModel codeToDeactivate, UserModel beneficient = null) { CodeModel usedCode = codeToDeactivate; usedCode.WasUsed = true; usedCode.IsActive = false; usedCode.CodeBeneficient = beneficient.Id; return(usedCode); }
public override CodeModelRb TransformCodeModel(CodeModel cm) { var codeModel = cm as CodeModelRb; SwaggerExtensions.NormalizeClientModel(codeModel); PopulateAdditionalProperties(codeModel); Flattening(codeModel); return(codeModel); }
public void Process(CodeModel codeModel) { foreach (ModelMethod method in codeModel.Methods.WhereTagsContains(DefaultMethodTag)) { foreach (ModelMethod constructor in method.Type.Methods.Where(m => m.IsConstructor)) { constructor.CallsMethods.Add(method); } } }
public ActionResult Edit(CodeModel model) { if (ModelState.IsValid) { ScriptModel.Update(model); ViewBag.Message = "脚本修改成功"; Model.ScriptRedirect(ViewBag, Url.Action("Index", "Script", new { id = model.siteid })); } return(Edit(model.sid)); }
public void StartDateTest() { var target = new CodeModel(); var expected = new DateTime?(DateTime.Now); target.StartDate = expected; DateTime?actual = target.StartDate; Assert.AreEqual(expected, actual); }
public static SwaggerObject Create(CodeModel codeModel) { var url = new Uri(codeModel.BaseUrl); return(new SwaggerObject( host: url.Host, basePath: url.LocalPath, paths: PathsObject.Create(codeModel.Methods), definitions: DefinitionsObject.Create(codeModel.ModelTypes))); }
public async Task <IActionResult> Create(CodeModel code) { if (ModelState.IsValid == false) { return(View()); } var id = await _codeData.CreateCode(code); return(RedirectToAction("Details", new { codeId = id, categoryId = code.CategoryId })); }
/// <summary>Initializes a new instance of the <see cref="TargetMachine"/> class.</summary> /// <param name="triple">Triple for the target machine</param> /// <param name="cpu">CPU options for the machine</param> /// <param name="features">CPU features for the machine</param> /// <param name="optLevel">General optimization level for machine code generation</param> /// <param name="relocationMode">Relocation mode for machine code generation</param> /// <param name="codeModel">Code model for machine code generation</param> public TargetMachine(Triple triple , string?cpu = null , string?features = null , CodeGenOpt optLevel = CodeGenOpt.Default , RelocationMode relocationMode = RelocationMode.Default , CodeModel codeModel = CodeModel.Default ) : this(Target.InternalCreateTargetMachine(Target.FromTriple(triple), triple, cpu, features, optLevel, relocationMode, codeModel)) { }
public IActionResult Verify(CodeModel model) { if (!TryValidateModel(model, nameof(model))) { ViewBag.email = false; model.confirmCode = ""; return(View("Index", model)); } return(View("Reseted")); }
public void Process(CodeModel codeModel) { // Build RuleRunContext: // (The RuleRunContext allows several rule instances of the same type // to share a cache on a per session base.) RuleRunContext context = new RuleRunContext(); // Build RuleSets: List <RuleSet> ruleSets = new List <RuleSet>(); foreach (XmlNode rulesetNode in this.processorInstance.SelectNodes(@"rulesets/ruleset")) { RuleSet ruleSet = new RuleSet(rulesetNode.Attributes["name"].Value); ruleSets.Add(ruleSet); foreach (XmlNode ruleNode in rulesetNode.SelectNodes("*")) { Type ruleType; if (this.matchingRuleTypes.TryGetValue(ruleNode.Name, out ruleType)) { BaseMatchingRule rule = (BaseMatchingRule)Activator.CreateInstance(ruleType); rule.Context = context; rule.Initialize(ruleNode); ruleSet.Rules.Add(rule); } } } // Apply rulesets: // (The next line can safely be replaced by a regular foreach as this:) foreach (ModelMethod method in codeModel.Methods) //Parallel.ForEach(codeModel.Methods, delegate(ModelMethod method) { foreach (RuleSet ruleSet in ruleSets) { // If tag value already set, no need to evaluate this ruleset anymore... if (method.Tags.Contains(ruleSet.Name)) { continue; } // Test & apply ruleset: if (ruleSet.Matches(method)) { // If rule name is "_skip", move to next method: if (ruleSet.Name == "_skip") { break; } // Apply ruleset: method.Tags.Add(ruleSet.Name); } } }//); // If using regular foreach, remove ");" here }
/// <summary> /// Generate Azure NodeJS client code /// </summary> /// <param name="cm"></param> /// <returns></returns> public override async Task Generate(CodeModel cm) { GeneratorSettingsJs generatorSettings = Singleton <GeneratorSettingsJs> .Instance; var codeModel = cm as CodeModelJsa; if (codeModel == null) { throw new InvalidCastException("CodeModel is not a Azure NodeJS code model."); } codeModel.PopulateFromSettings(generatorSettings); // Service client await GenerateServiceClientJs(() => new AzureServiceClientTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false); //Models if (codeModel.ModelTypes.Any()) { await GenerateModelIndexJs(() => new AzureModelIndexTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false); await GenerateModelIndexDts(() => new AzureModelIndexTemplateTS { Model = codeModel }, generatorSettings).ConfigureAwait(false); // Paged Models foreach (var pageModel in codeModel.PageTemplateModels) { var pageTemplate = new PageModelTemplate { Model = pageModel }; await Write(pageTemplate, GetModelSourceCodeFilePath(generatorSettings, pageModel.Name.ToCamelCase() + ".js")).ConfigureAwait(false); } foreach (var modelType in codeModel.ModelTemplateModels) { await GenerateModelJs(modelType, generatorSettings).ConfigureAwait(false); } } //MethodGroups if (codeModel.MethodGroupModels.Any()) { await GenerateRouteEntryTemplateJs(codeModel, generatorSettings).ConfigureAwait(false); foreach (var methodGroupModel in codeModel.MethodGroupModels) { await GenerateRouteGroupJs(() => new AzureMethodGroupTemplate { Model = methodGroupModel }, generatorSettings).ConfigureAwait(false); } } await GeneratePackageJson(codeModel, generatorSettings).ConfigureAwait(false); await GenerateReadmeMd(() => new AzureReadmeTemplate { Model = codeModel }, generatorSettings).ConfigureAwait(false); await GenerateLicenseTxt(codeModel, generatorSettings).ConfigureAwait(false); }
public async Task <ActionResult <int> > Update(int codeId, CodeModel model) { var result = await _codesService.Update(codeId, model); if (result > 0) { return(Ok(result)); } return(BadRequest(result)); }
public CodeTypeRef StripGenerics(CodeTypeRef member) { try { if (member.AsFullName.Contains("<") == false) { return(member); //No need to attempt to guess, this is not a generic class } //todo check if we need to cast to CodeTypeRef2 here var codeTypeRef2 = member as CodeTypeRef2; if (codeTypeRef2 == null || !codeTypeRef2.IsGeneric) { return(member); } var typeNameAsInCode = DTEHelper.RemoveTaskFromString(codeTypeRef2.AsFullName); typeNameAsInCode = DTEHelper.RemoveNullableStr(typeNameAsInCode); try { CodeModel projCodeModel = ((CodeElement)member.Parent).ProjectItem.ContainingProject.CodeModel; if (projCodeModel == null) { return(member); } var codeType = projCodeModel.CodeTypeFromFullName(typeNameAsInCode); if (codeType != null) { return(projCodeModel.CreateCodeTypeRef(codeType)); } return(member); } catch (COMException ex) { var found = CheckForTypeInOtherPlaces(typeNameAsInCode); if (found != null) { return(found); } } if (member.AsFullName.Contains("Task<")) { return(null); //we failed, might as well throw error } return(member); } catch (Exception ex) { return(member); } }
public void ParseWithCodeModelWithCreateResourceMethod() { CodeModel codeModel = New <CodeModel>(); codeModel.ApiVersion = "2016-01-01"; Parameter body = New <Parameter>(new { Location = ParameterLocation.Body, Type = New <CompositeType>(), }); CompositeType responseBody = New <CompositeType>(); responseBody.Extensions.Add("x-ms-azure-resource", true); const string url = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Mock.Provider/mockResourceNames/{mockResourceName}"; Method method = New <Method>(new { HttpMethod = HttpMethod.Put, ReturnType = new Response(responseBody, null), Url = url, }); method.Add(body); codeModel.Add(method); IDictionary <string, ResourceSchema> schemas = ResourceSchemaParser.Parse(codeModel); Assert.NotNull(schemas); Assert.Equal(1, schemas.Count); ResourceSchema schema = schemas["Mock.Provider"]; Assert.Equal("http://schema.management.azure.com/schemas/2016-01-01/Mock.Provider.json#", schema.Id); Assert.Equal("http://json-schema.org/draft-04/schema#", schema.Schema); Assert.Equal("Mock.Provider", schema.Title); Assert.Equal("Mock Provider Resource Types", schema.Description); Assert.Equal(1, schema.ResourceDefinitions.Count); Assert.Equal("mockResourceNames", schema.ResourceDefinitions.Keys.Single()); Assert.Equal( new JsonSchema() { JsonType = "object", Description = "Mock.Provider/mockResourceNames" } .AddProperty("type", JsonSchema.CreateStringEnum("Mock.Provider/mockResourceNames"), true) .AddProperty("apiVersion", JsonSchema.CreateStringEnum("2016-01-01"), true), schema.ResourceDefinitions["mockResourceNames"]); Assert.NotNull(schema.Definitions); Assert.Equal(0, schema.Definitions.Count); }
/// <summary> /// Changes paginated method signatures to return Page type. /// </summary> /// <param name="serviceClient"></param> /// <param name="pageClasses"></param> public void NormalizePaginatedMethods(CodeModel serviceClient, IDictionary <KeyValuePair <string, string>, string> pageClasses) { if (serviceClient == null) { throw new ArgumentNullException("serviceClient"); } var convertedTypes = new Dictionary <IModelType, IModelType>(); foreach (MethodJva method in serviceClient.Methods.Where(m => m.Extensions.ContainsKey(AzureExtensions.PageableExtension))) { string nextLinkString; string pageClassName = GetPagingSetting(method.Extensions, pageClasses, out nextLinkString); if (string.IsNullOrEmpty(pageClassName)) { continue; } if (string.IsNullOrEmpty(nextLinkString)) { method.Extensions[AzureExtensions.PageableExtension] = null; } foreach (var responseStatus in method.Responses.Where(r => r.Value.Body is CompositeTypeJva).Select(s => s.Key).ToArray()) { var compositType = (CompositeTypeJva)method.Responses[responseStatus].Body; var sequenceType = compositType.Properties.Select(p => p.ModelType).FirstOrDefault(t => t is SequenceTypeJva) as SequenceTypeJva; // if the type is a wrapper over page-able response if (sequenceType != null) { IModelType pagedResult; pagedResult = new SequenceTypeJva { ElementType = sequenceType.ElementType, PageImplType = pageClassName }; convertedTypes[method.Responses[responseStatus].Body] = pagedResult; var resp = New <Response>(pagedResult, method.Responses[responseStatus].Headers) as ResponseJva; resp.Parent = method; method.Responses[responseStatus] = resp; } } if (convertedTypes.ContainsKey(method.ReturnType.Body)) { var resp = New <Response>(convertedTypes[method.ReturnType.Body], method.ReturnType.Headers) as ResponseJva; resp.Parent = method; method.ReturnType = resp; } } SwaggerExtensions.RemoveUnreferencedTypes(serviceClient, new HashSet <string>(convertedTypes.Keys.Cast <CompositeTypeJva>().Select(t => t.Name.ToString()))); }
internal static DialogDebugAdapter MakeDebugger(IDebugTransport transport) { var codeModel = new CodeModel(); var sourceMap = new DebuggerSourceMap(codeModel); var events = new Events <DialogEvents>(); var coercion = new Coercion(); var dataModel = new DataModel(coercion); var debugger = new DialogDebugAdapter(transport, sourceMap, sourceMap, () => { }, events, codeModel, dataModel, NullLogger.Instance, coercion); return(debugger); }
public override CodeModelJv TransformCodeModel(CodeModel cs) { var codeModel = cs as CodeModelJv; // we're guaranteed to be in our language-specific context here. // todo: these should be turned into individual transformers SwaggerExtensions.NormalizeClientModel(codeModel); return(codeModel); }
public async Task <ActionResult> Delete(string codegroup_id, string code_id) { CodeModel code = new CodeModel { codegroup_id = codegroup_id, code_id = code_id }; await _code.Delete(code); return(Ok()); }
public async Task <ActionResult <int> > Add(CodeModel model) { var result = await _codesService.Add(model); if (result > 0) { return(Ok(result)); } return(BadRequest(result)); }
public void OnNode(Node node, ParserRuleContext context, CodeModel.Program program) { var statement = node as FunctionCaller; var functions = new List<FunctionCall>(); foreach(var fun in statement.FunctionCalls) { var found = node.SymbolTable.GetFunction(fun.QualifiedName); if (found.Count != 1) continue; // ambiguity is not our job var declaration = (FunctionDeclaration)found[0]; Check(node.CodeElement, node.SymbolTable, fun, declaration); } }
public void Process(CodeModel codeModel) { foreach (ModelMethod method in codeModel.Methods.WhereTagsContains(DefaultImplementationTag)) { foreach (MethodInfo imethodInfo in method.ImplementedInterfaceMethods) { ModelMethod imethod = codeModel.Methods.ForMethodBase(imethodInfo); if (imethod != null) { imethod.CallsMethods.Add(method); } } } }
public void Process(CodeModel codeModel) { foreach (ModelMethod method in codeModel.Methods) { if (method.IsOverride) { ModelMethod baseMethod = codeModel.Methods.ForMethodBase(method.BaseMethodDefinition); if (baseMethod != null && baseMethod.HasAnyOfTags(BaseImplementationTag)) { baseMethod.CallsMethods.Add(method); } } } }
/// <summary> /// Common internal implementation for all 4 constructors above /// </summary> private FileCompiler(string libraryName, string textName, CobolFile loadedCobolFile, SourceFileProvider sourceFileProvider, IProcessedTokensDocumentProvider documentProvider, ColumnsLayout columnsLayout, ITextDocument textDocument, TypeCobolOptions compilerOptions, CodeModel.SymbolTable customSymbols, bool isCopyFile) { // 1.a Find the Cobol source file CobolFile sourceFile = null; if (textName != null) { if (sourceFileProvider.TryGetFile(libraryName, textName, out sourceFile)) { CobolFile = sourceFile; } else { throw new Exception(String.Format("Could not find a Cobol source file named {0}", textName)); } } // 1.b Register a Cobol source file which was already loaded else if(loadedCobolFile != null) { CobolFile = loadedCobolFile; } // 2.a Load it in a new text document in memory if (textDocument == null) { TextDocument = new ReadOnlyTextDocument(sourceFile.Name, sourceFile.Encoding, columnsLayout, sourceFile.ReadChars()); } // 2.b Load it in an existing text document in memory else if (sourceFile != null) { TextDocument = textDocument; textDocument.LoadChars(sourceFile.ReadChars()); } // 2.c Use a pre-existing text document // - not yet associated with a Cobol source file // - with a Cobol source file already loaded else if (sourceFile == null || loadedCobolFile != null) { TextDocument = textDocument; } // 3. Prepare the data structures used by the different steps of the compiler if (isCopyFile) { CompilationResultsForCopy = new CompilationDocument(TextDocument.Source, TextDocument.Lines, compilerOptions, documentProvider); CompilationResultsForCopy.CustomSymbols = customSymbols; } else { CompilationResultsForProgram = new CompilationUnit(TextDocument.Source, TextDocument.Lines, compilerOptions, documentProvider); CompilationResultsForProgram.CustomSymbols = customSymbols; } CompilerOptions = compilerOptions; }
public void Process(CodeModel codeModel) { foreach (ModelMethod method in codeModel.Methods) { if (method.IsConstructor) { method.Tags.Add("specialmethod"); method.Tags.Add("instanceconstructor"); method.Tags.Add("constructor"); } else if (method.IsStaticConstructor) { method.Tags.Add("specialmethod"); method.Tags.Add("staticconstructor"); method.Tags.Add("constructor"); } else if (method.IsOperator) { method.Tags.Add("specialmethod"); method.Tags.Add("operator"); } else if (method.IsGetAccessor) { method.Tags.Add("specialmethod"); method.Tags.Add("accessor"); method.Tags.Add("get_accessor"); } else if (method.IsSetAccessor) { method.Tags.Add("specialmethod"); method.Tags.Add("accessor"); method.Tags.Add("set_accessor"); } else if (method.IsAnonymous) { method.Tags.Add("anonymous"); } } }
public StfuAndRunCodeCommand(CodeModel model) { this.model = model; }
public ParameterList AsProfile(CodeModel.SymbolTable table) { var profile = new FunctionCallParameterList(); profile.InputParameters = FunctionCallParameterList.CreateParameters(InputParameters, table); profile.InoutParameters = FunctionCallParameterList.CreateParameters(InoutParameters, table); profile.OutputParameters = FunctionCallParameterList.CreateParameters(OutputParameters, table); profile.ReturningParameter = null; return profile; }
/// <summary>Notifies listeners about the creation of a new CodeElement.</summary> public void OnNode(Node node, ParserRuleContext context, CodeModel.Program program) { foreach(var listener in _listeners) { var types = listener.GetNodes(); foreach (var expected in types) { if (TypeCobol.Tools.Reflection.IsTypeOf(node!=null? node.GetType():null, expected)) { listener.OnNode(node, context, program); break; // only notify each listener once for a given CodeElement } } } }
internal static DataType CreateParameter(CallSiteParameter p, CodeModel.SymbolTable table) { DataType type = null; var parameter = p.StorageAreaOrValue; if (parameter.IsLiteral) { if (parameter.NumericValue != null) type = DataType.Numeric; else if (parameter.AlphanumericValue != null) type = DataType.Alphanumeric; else type = DataType.Unknown; } else { var found = table.GetVariable(new URI(parameter.ToString())); foreach(var item in found) { var data = item as Nodes.DataDescription; if (type == null) type = data.DataType; else if (type != data.DataType) type = DataType.Unknown; } if (type == null) type = DataType.Unknown; } return type; }
internal static IList<DataType> CreateParameters(List<CallSiteParameter> parameters, CodeModel.SymbolTable table) { var results = new List<DataType>(); foreach(var parameter in parameters) results.Add(CreateParameter(parameter, table)); return results; }
public void OnNode(Node node, ParserRuleContext context, CodeModel.Program program) { var header = node.CodeElement as FunctionDeclarationHeader; var filesection = node.Get<FileSection>("file"); if (filesection != null) // TCRFUN_DECLARATION_NO_FILE_SECTION DiagnosticUtils.AddError(filesection.CodeElement, "Illegal FILE SECTION in function \""+header.Name+"\" declaration", context); CheckNoGlobalOrExternal(node.Get<DataDivision>("data-division")); CheckParameters(header.Profile, header, context); CheckNoLinkageItemIsAParameter(node.Get<LinkageSection>("linkage"), header.Profile); var functions = node.SymbolTable.GetFunction(header.Name, header.Profile); if (functions.Count > 1) DiagnosticUtils.AddError(header, "A function \""+header.Name.Head+"\" with the same profile already exists in namespace \""+header.Name.Tail+"\".", context); // foreach(var function in functions) { // if (!function.IsProcedure && !function.IsFunction) // DiagnosticUtils.AddError(header, "\""+header.Name.Head+"\" is neither procedure nor function.", context); // } }
public unsafe static TargetMachineRef CreateTargetMachine(TargetRef T, string Triple, string CPU, string Features, CodeGenOptLevel Level, RelocMode Reloc, CodeModel CodeModel) { TargetMachineRef ret = new TargetMachineRef(LLVMPINVOKE.CreateTargetMachine(T.Value, Triple, CPU, Features, (int)Level, (int)Reloc, (int)CodeModel)); return ret; }
// ------------------------------------------------------ public void Process(CodeModel codeModel) { Process(codeModel.CodeElements); }
public void OnNode(Node node, ParserRuleContext context, CodeModel.Program program) { var element = node.CodeElement as VariableWriter; var table = program.SymbolTable; foreach (var pair in element.VariablesWritten) { if (pair.Key == null) continue; // no receiving item var lr = table.GetVariable(pair.Key); if (lr.Count != 1) continue; // ambiguity or not referenced; not my job var receiving = lr[0]; checkReadOnly(node.CodeElement, receiving as Node); } }
public abstract ArrayList Search( CodeModel.Components.SolutionComponent solution );
public void OnNode(Node node, ParserRuleContext context, CodeModel.Program program) { var pdiv = node.CodeElement as ProcedureDivisionHeader; bool isPublicLibrary = false; var elementsInError = new List<CodeElement>(); var errorMessages = new List<string>(); foreach(var child in node.Children) { var ce = child.CodeElement; if (child.CodeElement == null) { elementsInError.Add(node.CodeElement); errorMessages.Add("Illegal default section in library."); } else { var function = child.CodeElement as FunctionDeclarationHeader; if (function != null) { isPublicLibrary = isPublicLibrary || function.Visibility == AccessModifier.Public; } else { elementsInError.Add(child.CodeElement); errorMessages.Add("Illegal non-function item in library"); } } } if (isPublicLibrary) { for(int c = 0; c < errorMessages.Count; c++) DiagnosticUtils.AddError(elementsInError[c], errorMessages[c], context); } }
public void SetCodeModel(CodeModel codeModel) { this.codeModel = codeModel; }
public StfuAndShareCodeCommand(CodeModel viewModel) { _ViewModel = viewModel; _UiDispatcher = Dispatcher.CurrentDispatcher; }
/// <summary> /// Load a Cobol source file in memory /// </summary> public FileCompiler(string libraryName, string textName, SourceFileProvider sourceFileProvider, IProcessedTokensDocumentProvider documentProvider, ColumnsLayout columnsLayout, TypeCobolOptions compilerOptions, CodeModel.SymbolTable customSymbols, bool isCopyFile) : this(libraryName, textName, null, sourceFileProvider, documentProvider, columnsLayout, null, compilerOptions, customSymbols, isCopyFile) { }
public void OnNode([NotNull] Node node, ParserRuleContext context, CodeModel.Program program) { var pdiv = node.CodeElement as ProcedureDivisionHeader; bool isPublicLibrary = false; var elementsInError = new List<CodeElement>(); var errorMessages = new List<string>(); foreach(var child in node.Children) { var ce = child.CodeElement; if (child.CodeElement == null) { elementsInError.Add(node.CodeElement); errorMessages.Add("Illegal default section in library."); } else { var function = child.CodeElement as FunctionDeclarationHeader; if (function != null) { isPublicLibrary = isPublicLibrary || function.Visibility == AccessModifier.Public; } else { elementsInError.Add(child.CodeElement); errorMessages.Add("Illegal non-function item in library"); } } } var pgm = (Nodes.Program)node.Root.GetChildren<ProgramIdentification>()[0]; var copies = pgm.GetChildren<LibraryCopyCodeElement>(); var copy = copies.Count > 0? ((LibraryCopy)copies[0]) : null; if (isPublicLibrary) { // if (copy == null || copy.CodeElement().Name == null) // TCRFUN_LIBRARY_COPY // DiagnosticUtils.AddError(pgm.CodeElement, "Missing library copy in IDENTIFICATION DIVISION.", context); if (pdiv.UsingParameters != null && pdiv.UsingParameters.Count > 0) DiagnosticUtils.AddError(pdiv, "Illegal "+pdiv.UsingParameters.Count+" USING in library PROCEDURE DIVISION.", context); for(int c = 0; c < errorMessages.Count; c++) DiagnosticUtils.AddError(elementsInError[c], errorMessages[c], context); } }
public StfuAndLoadCodeCommand(CodeModel viewModel) { _ViewModel = viewModel; }