Conversation
lib/ADL/builder.rb
Outdated
| @@ -1,35 +1,8 @@ | |||
| require_relative "scope" | |||
| require_relative "../Common/scope" | |||
There was a problem hiding this comment.
I am convinced that it is not right to use require_relative. I think it will be better to use
require "Common/scope"
lib/SDL/plod.rb
Outdated
| @@ -0,0 +1,225 @@ | |||
| require_relative '../Common/scope' | |||
lib/SDL/plod.rb
Outdated
| # class Oper | ||
| # attr_accessor :kind, :ret, :opds | ||
|
|
||
| # def initialize(kind, ret, *opds) | ||
| # @kind = kind | ||
| # @ret = ret | ||
| # @opds = opds | ||
| # end | ||
| # end | ||
|
|
||
| # class ConstExpr | ||
| # attr_accessor :type, :kind, :value | ||
|
|
||
| # def initialize(type, value) | ||
| # @type = type | ||
| # @kind = :const | ||
| # @value = value | ||
| # end | ||
| # end | ||
|
|
||
| # class VarExpr | ||
| # attr_accessor :type, :kind, :name | ||
|
|
||
| # def initialize(type, name) | ||
| # @type = type | ||
| # @kind = :var | ||
| # @value = name | ||
| # end | ||
| # end | ||
|
|
||
| # class ExprWrapper | ||
| # attr_accessor :expr | ||
|
|
||
| # class << self | ||
| # attr_accessor :currentScope | ||
| # end | ||
|
|
||
| # @@tmpCounter = 0 | ||
| # @@currentScope = nil | ||
|
|
||
| # def initialize(expr) | ||
| # @expr = expr | ||
| # end | ||
|
|
||
| # def self.setScope(scope) | ||
| # @@currentScope = scope | ||
| # end | ||
|
|
||
| # def self.nthOp(n, kind, retType, *args) | ||
| # var = VarExpr(retType, "tmp_#{@@tmpCounter}".to_sym) | ||
| # @@tmpCounter += 1 | ||
|
|
||
| # @@currentScope < Oper(kind, var, *(args.map { |arg| arg.expr })) | ||
|
|
||
| # return ExprWrapper.new(var) | ||
| # end | ||
|
|
||
| # def self.binOp(lhs, rhs, kind, retType = nil) | ||
| # if lhs.type != rhs.type | ||
| # raise "Bad bin op args" | ||
| # end | ||
|
|
||
| # if retType.nil? | ||
| # retType = lhs.type | ||
| # end | ||
|
|
||
| # return nthOp(2, kind, retType, lhs, rhs) | ||
| # end | ||
|
|
||
| # def+(other); binOp(self, other, :add); end | ||
| # def-(other); binOp(self, other, :sub); end | ||
| # def<<(other); binOp(self, other, :shl); end | ||
| # def<(other); binOp(self, other, :lt, bv(1)); end | ||
| # def>(other); binOp(self, other, :gt, bv(1)); end | ||
| # def^(other); binOp(self, other, :xor); end | ||
| # def>>(other); binOp(self, other, :shr); end | ||
| # def|(other); binOp(self, other, :or) end | ||
| # def&(other); binOp(self, other, :and) end | ||
| # def==(other); binOp(self, other, :eq, bv(1)); end | ||
| # def!=(other); binOp(self, other, :ne, bv(1)); end | ||
| # # def[](r, l); @scope.extract(self, r, l); end | ||
|
|
||
| # end | ||
|
|
||
| # class Statement < Utils::BaseInfo(:retVar, :op, :args) | ||
| # def initialize() | ||
| # super(nil, nil, []) | ||
| # end | ||
| # end | ||
|
|
||
| # class CallHandler | ||
| # attr_accessor :symbolName, :args, :next | ||
|
|
||
| # def initialize(name, *args) | ||
| # @symbolName = name | ||
| # @args = args | ||
| # @next = nil | ||
|
|
||
| # stmt = Statement.new() | ||
| # obj = getTmp() | ||
| # stmt.retVar = obj | ||
| # stmt.op = :getObj | ||
| # stmt.args = [callHandler.symbolName.to_sym] | ||
| # @@scopeInstance << stmt | ||
|
|
||
| # if !callHandler.args.empty? | ||
| # callStmt = Statement.new() | ||
| # stmt.retVar = getTmp() | ||
| # stmt.op = :call | ||
| # stmt.args = [obj] + callHandler.args | ||
| # @@scopeInstance << callStmt | ||
| # end | ||
|
|
||
| # puts @symbolName | ||
| # puts @args | ||
| # end | ||
|
|
||
| # def method_missing(name, *args) | ||
| # @next = CallHandler.new(name, *args) | ||
|
|
||
| # return @next | ||
| # end | ||
| # end | ||
|
|
||
| # module Scope | ||
| # def self.method_missing(name, *args) | ||
| # return ExprWrapper.new(name, *args) | ||
| # end | ||
| # end |
There was a problem hiding this comment.
Why do we need this code?
| require_relative "encoding" | ||
| require_relative "../../ADL/base" | ||
| require_relative "../../Common/base" | ||
| require_relative "../../ADL/builder" | ||
|
|
There was a problem hiding this comment.
Can you fix this too? I think that it is okey to use require_relative for files in the same directory
lib/Common/var.rb
Outdated
| end | ||
|
|
||
| module SimInfra | ||
| module LangInfra |
There was a problem hiding this comment.
Our language is named Protea. Maybe we can use?
module Protea
lib/Devices/ns16550.rb
Outdated
| # Function(:lol, int(:lol), bv(64, :dom), void) { | ||
|
|
||
| # } |
There was a problem hiding this comment.
Remove it please. We will support cuttom functions later.
| def get_field(expr, lsb, type) = stmt(:get_field, [tmpvar(type), expr, lsb]) | ||
|
|
There was a problem hiding this comment.
In my opinion It is a great idea to add get_field statement for scope. I will add this to agenda. However maybe it is unnecessary
lib/SDL/plod.rb
Outdated
| scope = initScope | ||
| scope.instance_eval(&block[2]) | ||
| block[0][block[1]] = scope.to_h | ||
| # puts block[0] |
There was a problem hiding this comment.
remove comment please
| require 'yaml' | ||
|
|
||
| require 'Devices/ns16550' | ||
|
|
||
| puts Devices.getDesc.to_yaml |
There was a problem hiding this comment.
We are going to add cmake build. So I think it is better to wait it shipped and then rewrite current generator.
No description provided.