public void GenerateStoreBytecode(ClassesContainer container, ByteBlock context) { switch (InferredSymbolType) { case SymbolType.Local: Variable variable = GetTarget <Variable>(); Symbol symbol = context.SymbolTable.GetSymbol(variable.Name); context.Instructions.Add(new StoreCode(symbol.Id)); break; case SymbolType.ClassMember: Field target = GetTarget <Field>(); context.Instructions.Add(new StoreGlobalCode(container.GetClassId(target.ParentClass), target.Id)); break; case SymbolType.StructMember: target = GetTarget <Field>(); if (Expression.ParentClass == target.ParentClass) { context.Instructions.Add(new StructPushCurrent()); } context.Instructions.Add(new StructStoreMemberCode(target.Id)); break; case SymbolType.ExternalMember: throw new NotImplementedException(); default: break; } }
public SemanticsValidator(Class currentClass, ClassesContainer container) { this.CurrentClass = currentClass; this.Flush(); this.Errors = new List <SemanticalError>(); this.Container = container; }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { int jumpIndex = context.NextOpIndex; IfCondition.GenerateBytecode(container, context); JumpIfFalseCode jumpIfFalse = new JumpIfFalseCode(-1); context.Instructions.Add(jumpIfFalse); foreach (var statement in IfStatements) { statement.GenerateBytecode(container, context); } JumpCode jumpElseIfTrue = new JumpCode(-1); context.Instructions.Add(jumpElseIfTrue); jumpIfFalse.targetIndex = context.NextOpIndex; if (ElseStatements != null) { foreach (var statement in ElseStatements) { statement.GenerateBytecode(container, context); } } jumpElseIfTrue.targetIndex = context.NextOpIndex; }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { if (!Value.Empty) { Value.GenerateBytecode(container, context); } context.Instructions.Add(new ReturnCode()); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { foreach (var parameter in Parameters) { parameter.GenerateBytecode(container, context); } AccessorTree.GenerateBytecode(container, context); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { List <ICode> results = new List <ICode>(); int variableId = context.SymbolTable.Bind(Variable.Name, Variable.RawType); Value.GenerateBytecode(container, context); context.Instructions.Add(new StoreCode(variableId)); }
public IByteElement GetByteElement(ClassesContainer container, IByteElement parent) { ByteBlock meta = new ByteBlock((ByteClass)parent); Value.GenerateBytecode(container, meta); ByteField field = new ByteField((ByteClass)parent, Modifiers, Name, meta); return(field); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { foreach (var parameter in Parameters) { parameter.GenerateBytecode(container, context); } context.Instructions.Add(new NativeCallCode((int)NativeEnum)); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { Class targetClass = container.TryGetClass(Constants.STDVectorClassName); context.Instructions.Add(new StructCreateCode(container.GetClassId(Constants.STDVectorClassName))); foreach (var element in Elements) { element.GenerateBytecode(container, context); } context.Instructions.Add(new VectCreateCode(Elements.Count)); context.Instructions.Add(new CtorCallCode(targetClass.GetCtor().Id, 1)); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { Class targetClass = container[CtorName]; context.Instructions.Add(new StructCreateCode(container.GetClassId(CtorName))); if (StructCtor != null) { foreach (var parameter in Parameters) { parameter.GenerateBytecode(container, context); } context.Instructions.Add(new CtorCallCode(targetClass.GetCtor().Id, Parameters.Count)); } }
public void GenerateBytecode(ClassesContainer container, ByteBlock context) { for (int i = 0; i < Tree.Count - 1; i++) { Tree[i].GenerateLoadBytecode(container, context); } if (Store) { Tree.Last().GenerateStoreBytecode(container, context); } else { Tree.Last().GenerateLoadBytecode(container, context); } }
public IByteElement GetByteElement(NovFile file, ClassesContainer container, IByteElement parent) { ByteClass byteClass = new ByteClass(file, this.ClassName, Type); foreach (var method in this.Methods) { byteClass.Methods.Add((ByteMethod)method.Value.GetByteElement(container, byteClass)); } foreach (var field in this.Fields) { byteClass.Fields.Add((ByteField)field.Value.GetByteElement(container, byteClass)); } return(byteClass); }
public IEnumerable <SemanticalError> ValidateSemantics(ClassesContainer container) { SemanticsValidator validator = new SemanticsValidator(this, container); foreach (var field in this.Fields) { field.Value.ValidateSemantics(validator); validator.Flush(); } foreach (var method in this.Methods) { method.Value.ValidateSemantics(validator); validator.Flush(); } return(validator.GetErrors()); }
public void GenerateBytecode(ClassesContainer container, ByteBlock context) { if (Empty) { context.Instructions.Add(new PushNullCode()); } else { int i = 0; while (i < Tree.Count) { Tree[i].GenerateBytecode(container, context); i++; } } }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { int jumpIndex = context.NextOpIndex; Condition.GenerateBytecode(container, context); JumpIfFalseCode jumpIfFalse = new JumpIfFalseCode(-1); context.Instructions.Add(jumpIfFalse); foreach (var statement in Statements) { statement.GenerateBytecode(container, context); } context.Instructions.Add(new JumpCode(jumpIndex)); jumpIfFalse.targetIndex = context.NextOpIndex; }
public IByteElement GetByteElement(ClassesContainer container, IByteElement parent) { ByteMethod result = new ByteMethod(this.Name, Modifiers, Parameters.Count, (ByteClass)parent); foreach (var parameter in Parameters) { result.ByteBlock.SymbolTable.Bind(parameter.Name, parameter.RawType); } foreach (var statement in Statements) { statement.GenerateBytecode(container, result.ByteBlock); } if (result.ByteBlock.Instructions.Count == 0 || (!(result.ByteBlock.Instructions.Last() is ReturnCode))) { result.ByteBlock.Instructions.Add(new ReturnCode()); } return(result); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { switch (OperatorEnum) { case OperatorsEnum.Plus: context.Instructions.Add(new AddCode()); break; case OperatorsEnum.Minus: context.Instructions.Add(new SubCode()); break; case OperatorsEnum.Multiply: context.Instructions.Add(new MulCode()); break; case OperatorsEnum.Divide: context.Instructions.Add(new DivCode()); break; case OperatorsEnum.Inferior: context.Instructions.Add(new ComparaisonCode(OperatorsEnum.Inferior)); break; case OperatorsEnum.Superior: context.Instructions.Add(new ComparaisonCode(OperatorsEnum.Superior)); break; case OperatorsEnum.Different: context.Instructions.Add(new ComparaisonCode(OperatorsEnum.Different)); break; case OperatorsEnum.Equals: context.Instructions.Add(new ComparaisonCode(OperatorsEnum.Equals)); break; default: throw new Exception(); } }
public void GenerateLoadBytecode(ClassesContainer container, ByteBlock context) { if (Type == AccessorType.Field) { switch (InferredSymbolType) { case SymbolType.Local: Variable variable = GetTarget <Variable>(); Symbol symbol = context.SymbolTable.GetSymbol(variable.Name); context.Instructions.Add(new LoadCode(symbol.Id)); break; case SymbolType.ClassMember: Field target = GetTarget <Field>(); context.Instructions.Add(new LoadGlobalCode(container.GetClassId(target.ParentClass.ClassName), target.Id)); break; case SymbolType.StructMember: target = GetTarget <Field>(); if (Expression.ParentClass == target.ParentClass) { context.Instructions.Add(new StructPushCurrent()); } context.Instructions.Add(new StructLoadMemberCode(target.Id)); break; case SymbolType.ExternalMember: target = GetTarget <Field>(); context.Instructions.Add(new LoadGlobalCode(container.GetClassId(target.ParentClass.ClassName), target.Id)); break; default: break; } } else if (Type == AccessorType.Method) { Method target = GetTarget <Method>(); switch (InferredSymbolType) { case SymbolType.ClassMember: context.Instructions.Add(new MethodCallCode(container.GetClassId(target.ParentClass), target.Id)); break; case SymbolType.StructMember: if (Expression.ParentClass == target.ParentClass) { context.Instructions.Add(new StructPushCurrent()); } context.Instructions.Add(new StructCallMethodCode(target.Id)); break; case SymbolType.ExternalMember: context.Instructions.Add(new MethodCallCode(container.GetClassId(target.ParentClass), target.Id)); break; default: throw new Exception(); } } }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { Expression.GenerateBytecode(container, context); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { Value.GenerateBytecode(container, context); Target.GenerateBytecode(container, context); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { int constantId = context.BindConstant(Value); context.Instructions.Add(new PushConstCode(constantId)); }
public abstract void GenerateBytecode(ClassesContainer container, ByteBlock context);
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { context.Instructions.Add(new PushIntCode(Value)); }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { int value = Value == true ? 1 : 0; context.Instructions.Add(new PushIntCode(value)); // rather push byte ! }
public override void GenerateBytecode(ClassesContainer container, ByteBlock context) { throw new NotImplementedException(); }