ExpressionType TranslateVariable(FieldVariable field) { ExpressionType et = TranslateVariable(field.Var); if (et.Type.Actual is Types.RECORD) { int index = 0; Types.RECORD type = et.Type.Actual as Types.RECORD; for (; type != null; type = type.Tail, ++index) { if (type.FieldName == field.Field) { break; } } if (type != null) { return(new ExpressionType(Translate.TranslateFieldVar(et.Exp, index), type.FieldType.Actual)); } else { Error.Report(field.Pos, "Field '" + field.Field.ToString() + "' does not exist."); return(new ExpressionType(null, Types.Type._unknown)); } } else { Error.Report(field.Pos, "Record type required"); return(new ExpressionType(null, Types.Type._unknown)); } }
public override AstNode Visit(FieldDeclaration node) { // Get the field. FieldVariable field = (FieldVariable)node.GetVariable(); // Get the field type. IChelaType fieldType = field.GetVariableType(); if (!fieldType.IsConstant() || field.IsExternal()) { return(node); // Ignore not constant fields. } // Get the initializer. Expression initializer = node.GetDefaultValue(); if (initializer == null) { Error(node, "constants must have initializers."); } // Don't allow multiple definitions. if (constants.ContainsKey(field)) { Error(node, "multiples definitions of a constant."); } // Store the constant. ConstantData data = new ConstantData(field, initializer); this.constants.Add(field, data); // Return the node. return(node); }
public override AstNode Visit(MemberAccess node) { // This is the same as VariableReference implementation. // Get the node type. IChelaType variableType = node.GetNodeType(); // Ignore type references, namespaces and functions. if (variableType.IsMetaType() || variableType.IsNamespace() || variableType.IsFunctionGroup() || variableType.IsFunction()) { return(node); } // The type must be a reference. variableType = DeReferenceType(variableType); // Now, it must be a constant. if (!variableType.IsConstant()) { Error(node, "constant initialization can't reference no constant variables."); } // The node value, must be the constant variable. FieldVariable constantVar = (FieldVariable)node.GetNodeValue(); // Find the corresponding constant data. ConstantData depData; if (constants.TryGetValue(constantVar, out depData)) { currentConstant.AddDependency(depData); } return(node); }
public override AstNode Visit(EnumConstantDefinition node) { // Get the field. FieldVariable field = node.GetVariable(); // Ignore external constants. if (field.IsExternal()) { return(node); } // Get the initializer. Expression initializer = node.GetValue(); if (initializer == null) { Error(node, "constants must have initializers."); } // Don't allow multiple definitions. if (constants.ContainsKey(field)) { Error(node, "multiples definitions of a constant."); } // Store the constant. ConstantData data = new ConstantData(field, initializer); this.constants.Add(field, data); // Return the node. return(node); }
protected EventVariable(ChelaModule module) : base(module) { this.flags = MemberFlags.Default; this.parentScope = null; this.associatedField = null; }
protected EventVariable(ChelaModule module) : base(module) { this.flags = MemberFlags.Default; this.parentScope = null; this.associatedField = null; }
public void TestFieldVariable_Constructor() { var ws = new Workspace(); var fieldVar = new FieldVariable(null, "name1"); Assert.AreEqual("name1", fieldVar.GetText()); ws.Dispose(); }
public ConstantData(FieldVariable variable, Expression initializer) { this.variable = variable; this.initializer = initializer; this.dependencies = new List <ConstantData> (); this.visited = false; this.visiting = false; }
public EventVariable(string name, MemberFlags flags, IChelaType type, Scope parentScope) : base(type, parentScope.GetModule()) { SetName(name); this.flags = flags; this.parentScope = parentScope; this.associatedField = null; }
public EventVariable(string name, MemberFlags flags, IChelaType type, Scope parentScope) : base(type, parentScope.GetModule()) { SetName(name); this.flags = flags; this.parentScope = parentScope; this.associatedField = null; }
void PrintVariable(FieldVariable v, int d) { SayLn("FieldVariable("); PrintVariable(v.Var, d + 1); SayLn(","); Indent(d + 1); Say(v.Field.ToString()); Say(")"); }
void PrintVariable(FieldVariable v, int d) { SayLn("FieldVariable("); PrintVariable(v.Var, d + 1); SayLn(","); Indent(d + 1); Say(v.Field.ToString()); Say(")"); }
internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header) { // Create the temporal field and register it. FieldVariable field = new FieldVariable(module); module.RegisterMember(field); // Read the name and flags. field.SetName(module.GetString(header.memberName)); field.flags = (MemberFlags)header.memberFlags; // Skip the structure elements. reader.Skip(header.memberSize); }
public void TestFieldVariable_SetValueNoVariable() { Setup(); var fieldVar = new FieldVariable(null, "name1"); fieldVar.SetSourceBlock(MockBlock()); fieldVar.SetValue("id1"); Assert.AreEqual("id1", fieldVar.GetText()); Assert.AreEqual("id1", fieldVar.GetRealValue()); TearDown(); }
public void TestFieldVariable_SetValueMatchName() { Setup(); workspace.CreateVariable("name2", null, "id2"); var fieldVar = new FieldVariable(null, "name1"); fieldVar.SetSourceBlock(MockBlock()); fieldVar.SetValue("name2"); Assert.AreEqual("name2", fieldVar.GetText()); Assert.AreEqual("id2", fieldVar.GetRealValue()); TearDown(); }
private void treeView1_DoubleClick(object sender, EventArgs e) { var tn = this.treeView1.SelectedNode; var id = tn.Tag.ToString(); var list = this.ermsConfig.DefaultNormalERMSConfig.Where(x => x.ParentId == id).ToList(); this.pnlLeft.Controls.Clear(); foreach (var item in list) { var fv = new FieldVariable(); fv.Id = item.Id; fv.Name = item.Key; fv.InitList(this.ValueList, this.ParameterList); fv.Dock = DockStyle.Top; this.pnlLeft.Controls.Add(fv); } }
public void TestFieldVariable_DropdownCreateVariablesExist() { Setup(); workspace.CreateVariable("name1", "", "id1"); workspace.CreateVariable("name2", "", "id2"); var fieldVar = new FieldVariable(null, "name1"); fieldVar.SetSourceBlock(MockBlock()); fieldVar.SetText("name1"); FieldDropdownMenu[] options = fieldVar.GetOptions(); Assert.AreEqual("name1", options[0].Text); Assert.AreEqual("id1", options[0].Value); Assert.AreEqual("name2", options[1].Text); Assert.AreEqual("id2", options[1].Value); TearDown(); }
internal FieldInstance(ScopeMember factory, GenericInstance instance, FieldVariable template) : base(factory.GetModule()) { // Store the factory and the template. this.factory = factory; this.template = template; // Use the factory as the parent scope. this.parentScope = (Scope)factory; // Copy the name and the flags. this.SetName(template.GetName()); this.flags = template.flags; // Copy the slot. this.slot = template.slot; // Instance the type. this.type = template.GetVariableType().InstanceGeneric(instance, GetModule()); // Use the factory as parent scope. this.parentScope = (Scope)factory; }
internal FieldInstance(ScopeMember factory, GenericInstance instance, FieldVariable template) : base(factory.GetModule()) { // Store the factory and the template. this.factory = factory; this.template = template; // Use the factory as the parent scope. this.parentScope = (Scope)factory; // Copy the name and the flags. this.SetName(template.GetName()); this.flags = template.flags; // Copy the slot. this.slot = template.slot; // Instance the type. this.type = template.GetVariableType().InstanceGeneric(instance, GetModule()); // Use the factory as parent scope. this.parentScope = (Scope)factory; }
public override Verb CreateVerb(string[] tokens) { var tokens1Length = tokens[1].Length; Color(position, tokens1Length, IDEColor.EntityType.Variable); Value value; if (tokens[2] == "(") { Color(1, IDEColor.EntityType.Structure); var index = position + tokens1Length + 1; var block = OrangeCompiler.Block(source, ref index, ")", true); overridePosition = index; value = new FieldBlockVariable(block); } else { Color(tokens[2].Length, IDEColor.EntityType.Number); var index = tokens[2].ToInt(); value = new FieldVariable(index); } result.Value = value; return(new Push(value)); }
internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header) { // Create the temporal field and register it. FieldVariable field = new FieldVariable(module); module.RegisterMember(field); // Read the name and flags. field.SetName(module.GetString(header.memberName)); field.flags = (MemberFlags)header.memberFlags; // Skip the structure elements. reader.Skip(header.memberSize); }
public void SetVariable(FieldVariable variable) { this.variable = variable; }